From e76eeeb848a41db53e29b6121fda94332192c1fb Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 31 Mar 2021 14:43:37 -0400 Subject: [PATCH] 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. --- drivers/docker/coordinator_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/docker/coordinator_test.go b/drivers/docker/coordinator_test.go index 524e5c04e..eddda78bd 100644 --- a/drivers/docker/coordinator_test.go +++ b/drivers/docker/coordinator_test.go @@ -168,11 +168,15 @@ func TestDockerCoordinator_Pull_Remove(t *testing.T) { }) // Make sure there is no future still - coordinator.imageLock.Lock() - if _, ok := coordinator.deleteFuture[id]; ok { - t.Fatal("Got delete future") - } - coordinator.imageLock.Unlock() + testutil.WaitForResult(func() (bool, error) { + coordinator.imageLock.Lock() + defer coordinator.imageLock.Unlock() + _, ok := coordinator.deleteFuture[id] + return !ok, fmt.Errorf("got delete future") + }, func(err error) { + t.Fatalf("err: %v", err) + }) + } func TestDockerCoordinator_Remove_Cancel(t *testing.T) {