Skip to content

Commit 556e0be

Browse files
committed
Fix flakey test that expects storage to be cleaned up in a timely manner
Signed-off-by: James Munnelly <[email protected]>
1 parent 4ec29c9 commit 556e0be

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/integration/ready_to_request_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,18 @@ func TestFailsIfNotReadyToRequest_ContinueOnNotReadyDisabled(t *testing.T) {
185185
t.Errorf("Expected timeout to be returned from NodePublishVolume but got: %v", err)
186186
}
187187

188-
files, err := store.ReadFiles("test-vol")
189-
if err != nil {
190-
t.Errorf("failed to read files: %v", err)
191-
}
192-
if len(files["ca"]) > 0 {
193-
t.Errorf("unexpected CA data: %v", files["ca"])
194-
}
195-
if len(files["cert"]) > 0 {
196-
t.Errorf("unexpected certificate data: %v", files["cert"])
188+
// allow 1s for the cleanup functions in NodePublishVolume to be run
189+
// without this pause, the test can flake due to the storage backend not
190+
// being cleaned up of the persisted metadata file.
191+
ctx, cancel2 := context.WithTimeout(context.Background(), time.Second)
192+
defer cancel2()
193+
if wait.PollUntil(time.Millisecond*100, func() (bool, error) {
194+
_, err := store.ReadFiles("test-vol")
195+
if err != storage.ErrNotFound {
196+
return false, nil
197+
}
198+
return true, nil
199+
}, ctx.Done()); err != nil {
200+
t.Errorf("failed to wait for storage backend to return NotFound: %v", err)
197201
}
198202
}

0 commit comments

Comments
 (0)