Skip to content

Commit cab4b81

Browse files
authored
[chore][extension/k8sleaderelector] Fix race in TestExtension (#43525)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Moved the check causing race conditions #### Link to tracking issue Fixes [43423](#43423) <!--Describe what testing was performed and which tests were added.--> #### Testing You can test this locally running `GOMAXPROCS=1 go test -race -v -run TestExtension -count=100` from main results in ``` Error: Should be true Test: TestExtension ``` and then from this pr branch the test PASS
1 parent f8ccb9b commit cab4b81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extension/k8sleaderelector/extension_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ func TestExtension(t *testing.T) {
6767
require.NoError(t, err)
6868
require.NotNil(t, lease)
6969
require.Equal(t, expectedLeaseDurationSeconds, lease.Spec.LeaseDurationSeconds)
70+
require.True(t, onStartLeadingInvoked.Load())
7071
}, 10*time.Second, 100*time.Millisecond)
7172

72-
require.True(t, onStartLeadingInvoked.Load())
7373
require.NoError(t, leaderElection.Shutdown(ctx))
7474
}
7575

0 commit comments

Comments
 (0)