Skip to content

Conversation

@Moisi
Copy link
Contributor

@Moisi Moisi commented Jun 11, 2025

This PR

contains:

  1. enabling Parallel() golang test to detect races in TestNewProvider().
  2. jsonlogic package upgrade which contains a fix to the mentioned race.

Related Issues

No open issue, but this fixes Parallel testing in go test framework.

How to test

using test func TestNewProvider() in providers/flagd/pkg/provider_test.go:

  1. Add t.Parallel() to the first line of the test. and inside the t.Run() function (see first commit).
  2. From the test directory run: go test -race.

This would fail the test like so:

go-sdk-contrib/providers/flagd/pkg$ go test -race
==================
--- FAIL: TestNewProvider (0.00s)
    --- FAIL: TestNewProvider/with_providerID_only_with_in-process_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_custom_sync_provider_and_uri_with_in-process_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_gRPC_DialOptions_override_with_in-process_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_target_uri_with_in-process_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_selector_and_providerID_with_in-process_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_selector_only_with_in-process_resolver (0.01s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_options (0.01s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_OfflineFilePath_with_file_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/with_OfflineFilePath_with_in-process_resolver (0.00s)
        testing.go:1399: race detected during execution of test
    --- FAIL: TestNewProvider/default_port_handling_with_in-process_resolver (0.01s)
        testing.go:1399: race detected during execution of test
FAIL
exit status 1
FAIL	github.com/open-feature/go-sdk-contrib/providers/flagd/pkg	0.034s

Using this PR the same results are:

go test -race
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from localhost:8015"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with offline flags sourced from offlineFilePath"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from myHost:9090"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with a custom sync provider at syncprovider://custom"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from localhost:8015"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with a custom sync provider at testsyncer://custom.uri"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from localhost:8015"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from localhost:8015"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from envoy://localhost:9211/test.service"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with flags sourced from localhost:8015"}
{"level":"info","ts":"2025-06-11T19:11:44+02:00","msg":"operating in in-process mode with offline flags sourced from offlineFilePath"}
PASS
ok  	github.com/open-feature/go-sdk-contrib/providers/flagd/pkg	1.024s

@Moisi Moisi requested review from a team as code owners June 11, 2025 16:41
@Moisi Moisi changed the title manually upgrade jsonlogic to fix race detection fix(deps): update jsonlogic module to fix race detection Jun 11, 2025
@Moisi Moisi force-pushed the collect_bugfix_in_jsonlogic branch 2 times, most recently from 4cc4c1e to f344825 Compare June 11, 2025 16:58
@Moisi Moisi force-pushed the collect_bugfix_in_jsonlogic branch from f344825 to c93398a Compare June 11, 2025 17:13
Copy link
Member

@aepfli aepfli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I am sadly not as experienced with golang, but for me those changes look good and fine. I will wait for a more golang knowledge approval before merge ;)

@sahidvelji sahidvelji merged commit 21f3de0 into open-feature:main Jun 16, 2025
5 checks passed
gioddiggi pushed a commit to gioddiggi/go-sdk-contrib that referenced this pull request Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants