From 089c168fb9e87fe3090da1b3c1d12b998fb7e318 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 15 Aug 2024 16:23:21 +0100 Subject: [PATCH] fstests: attempt to fix flaky serve s3 test Sometimes (particularly on macOS amd64) the serve s3 test fails with TestIntegration/FsMkdir/FsPutError where it wasn't expecting to get an object but it did. This is likely caused by a race between the serve s3 goroutine deleting the half uploaded file and the fstests code looking for it to not exist. This fix treats it like any other eventual consistency problem and retries the check using the test framework. --- fstest/fstests/fstests.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go index be43a015a..2e840cd0c 100644 --- a/fstest/fstests/fstests.go +++ b/fstest/fstests/fstests.go @@ -762,9 +762,15 @@ func Run(t *testing.T, opt *Opt) { // assert.Nil(t, obj) - FIXME some remotes return the object even on nil assert.NotNil(t, err) - obj, err := f.NewObject(ctx, file2.Path) - assert.Nil(t, obj) - assert.Equal(t, fs.ErrorObjectNotFound, err) + retry(t, "FsPutError: test object does not exist", func() error { + obj, err := f.NewObject(ctx, file2.Path) + if err == nil { + return fserrors.RetryErrorf("object is present") + } + assert.Nil(t, obj) + assert.Equal(t, fs.ErrorObjectNotFound, err) + return nil + }) }) t.Run("FsPutZeroLength", func(t *testing.T) {