From e8599e188a4a71e3cd74169d0445f771c3a035b5 Mon Sep 17 00:00:00 2001 From: Michael Ye Date: Tue, 12 Sep 2023 20:42:53 +0000 Subject: [PATCH] fix flaky TestHandleEBSAckTimeout test for windows --- agent/ebs/watcher_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/agent/ebs/watcher_test.go b/agent/ebs/watcher_test.go index 657931d1b1f..9c1058e911f 100644 --- a/agent/ebs/watcher_test.go +++ b/agent/ebs/watcher_test.go @@ -309,10 +309,17 @@ func TestHandleEBSAckTimeout(t *testing.T) { watcher := newTestEBSWatcher(ctx, taskEngineState, eventChannel, mockDiscoveryClient) watcher.HandleResourceAttachment(ebsAttachment) - time.Sleep(10 * time.Millisecond) - assert.Len(t, taskEngineState.(*dockerstate.DockerTaskEngineState).GetAllEBSAttachments(), 0) - ebsAttachment, ok := taskEngineState.(*dockerstate.DockerTaskEngineState).GetEBSByVolumeId(volumeID) - assert.False(t, ok) + + for { + time.Sleep(time.Millisecond * 5) + if len(taskEngineState.(*dockerstate.DockerTaskEngineState).GetAllEBSAttachments()) == 0 { + // TODO Include a data client check. This will be introduced in a near future PR + _, ok := taskEngineState.(*dockerstate.DockerTaskEngineState).GetEBSByVolumeId(volumeID) + assert.False(t, ok) + break + } + } + } // TestHandleMismatchEBSAttachment tests handling an EBS attachment but found a different volume attached