drivers/docker: fix flaky image coordinator test

The test assertion that we don't have a delete future remaining races with the
code its testing, because the removal of the image and the removal of the
future are not atomic. Move this assertion into a `WaitForResult` to avoid
test flakes which we're seeing on CI on Windows in particular.
This commit is contained in:
Tim Gross 2021-03-31 14:43:37 -04:00
parent 5a182e1d03
commit e76eeeb848
1 changed files with 9 additions and 5 deletions

View File

@ -168,11 +168,15 @@ func TestDockerCoordinator_Pull_Remove(t *testing.T) {
}) })
// Make sure there is no future still // Make sure there is no future still
coordinator.imageLock.Lock() testutil.WaitForResult(func() (bool, error) {
if _, ok := coordinator.deleteFuture[id]; ok { coordinator.imageLock.Lock()
t.Fatal("Got delete future") defer coordinator.imageLock.Unlock()
} _, ok := coordinator.deleteFuture[id]
coordinator.imageLock.Unlock() return !ok, fmt.Errorf("got delete future")
}, func(err error) {
t.Fatalf("err: %v", err)
})
} }
func TestDockerCoordinator_Remove_Cancel(t *testing.T) { func TestDockerCoordinator_Remove_Cancel(t *testing.T) {