From 00b46a8b969ab708f54775ac359135fd5e23ea4d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 18 Nov 2017 18:40:28 +0000 Subject: [PATCH] mounttest: wait for files to disappear from the directory listing --- cmd/mountlib/mounttest/fs.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/mountlib/mounttest/fs.go b/cmd/mountlib/mounttest/fs.go index cf6489e65..02b832a6a 100644 --- a/cmd/mountlib/mounttest/fs.go +++ b/cmd/mountlib/mounttest/fs.go @@ -338,6 +338,16 @@ func (r *Run) rm(t *testing.T, filepath string) { filepath = r.path(filepath) err := os.Remove(filepath) require.NoError(t, err) + + // Wait for file to disappear from listing + for i := 0; i < 10; i++ { + _, err := os.Stat(filepath) + if os.IsNotExist(err) { + return + } + time.Sleep(100 * time.Millisecond) + } + assert.Fail(t, "failed to delete file", filepath) } func (r *Run) rmdir(t *testing.T, filepath string) {