deploymentwatcher: fix test data race.

This commit is contained in:
James Rasell
2021-06-11 11:55:21 +02:00
parent 398d81ccf1
commit 9a25e89b00

View File

@@ -614,8 +614,17 @@ func TestWatcher_AutoPromoteDeployment(t *testing.T) {
// Start the deployment
w.SetEnabled(true, m.state)
testutil.WaitForResult(func() (bool, error) { return 1 == len(w.watchers), nil },
func(err error) { require.Equal(t, 1, len(w.watchers), "Should have 1 deployment") })
testutil.WaitForResult(func() (bool, error) {
w.l.RLock()
defer w.l.RUnlock()
return 1 == len(w.watchers), nil
},
func(err error) {
w.l.RLock()
defer w.l.RUnlock()
require.Equal(t, 1, len(w.watchers), "Should have 1 deployment")
},
)
// Mark the canaries healthy
req := &structs.DeploymentAllocHealthRequest{