1
mirror of https://github.com/rclone/rclone synced 2024-12-17 06:25:56 +01:00

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.
This commit is contained in:
Nick Craig-Wood 2024-08-15 16:23:21 +01:00
parent 6f515ded8f
commit 089c168fb9

View File

@ -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.Nil(t, obj) - FIXME some remotes return the object even on nil
assert.NotNil(t, err) assert.NotNil(t, err)
obj, err := f.NewObject(ctx, file2.Path) retry(t, "FsPutError: test object does not exist", func() error {
assert.Nil(t, obj) obj, err := f.NewObject(ctx, file2.Path)
assert.Equal(t, fs.ErrorObjectNotFound, err) 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) { t.Run("FsPutZeroLength", func(t *testing.T) {