Skip to content

Commit

Permalink
Race Flake in TestControllerSyncFleetAutoscaler() (#3260)
Browse files Browse the repository at this point in the history
Weird that this has more consistently failed with the Go race condition
checker failing on this test recently -- but it's a test we wrote a
while ago!

The flake was that the test added a Reactor to the mock _after_ the
Informer system had been started - which caused a race condition inside
the Fake client system as different systems interacted with the mock.

Changing the order fixes the issue!
  • Loading branch information
markmandel authored Jul 12, 2023
1 parent 89173a8 commit d034f02
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/fleetautoscalers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,14 @@ func TestControllerSyncFleetAutoscaler(t *testing.T) {
t.Parallel()

c, m := newFakeController()
ctx, cancel := agtesting.StartInformers(m, c.fleetSynced, c.fleetAutoscalerSynced)
defer cancel()

m.AgonesClient.AddReactor("get", "fleetautoscalers", func(action k8stesting.Action) (bool, runtime.Object, error) {
ga := action.(k8stesting.GetAction)
return true, nil, k8serrors.NewNotFound(corev1.Resource("gameserver"), ga.GetName())
})

ctx, cancel := agtesting.StartInformers(m, c.fleetSynced, c.fleetAutoscalerSynced)
defer cancel()

require.NoError(t, c.syncFleetAutoscaler(ctx, "default/fas-1"))
})
}
Expand Down

0 comments on commit d034f02

Please sign in to comment.