19972: Fix racy test case.
[arvados.git] / services / keep-balance / balance_run_test.go
index fb1c74d2fe4adfb178fcd1a44a2ceba3a0e1e4e9..aeed517d094e93bf2b67a4a65a6cae0396847874 100644 (file)
@@ -663,7 +663,10 @@ func (s *runSuite) TestRunForever(c *check.C) {
        // first run should also send 4 empty trash lists at
        // startup. We should complete all four runs in much less than
        // a second.
-       for t0 := time.Now(); pullReqs.Count() < 16 && time.Since(t0) < 10*time.Second; {
+       for t0 := time.Now(); time.Since(t0) < 10*time.Second; {
+               if pullReqs.Count() >= 16 && trashReqs.Count() == pullReqs.Count()+4 {
+                       break
+               }
                time.Sleep(time.Millisecond)
        }
        cancel()