-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Describe the bug
The TestS3WatcherTestSuite/TestStart test in contrib/vfsevents intermittently fails with an unexpected mock method call error. The test passes on retry, indicating a race condition in the test setup.
To Reproduce
- Run the vfsevents test suite in CI:
go test -v ./contrib/vfsevents/... - The
TestS3WatcherTestSuite/TestStarttest occasionally fails - Re-running the same test succeeds
Expected behavior
The test should pass consistently without flakiness.
Error Output
--- FAIL: TestS3WatcherTestSuite (0.26s)
--- FAIL: TestS3WatcherTestSuite/TestStart (0.00s)
mock.go:361:
assert: mock: I don't know what to return because the method call was unexpected.
Either do Mock.On("ReceiveMessage").Return(...) first, or remove the ReceiveMessage() call.
This method was unexpected:
ReceiveMessage(*context.cancelCtx,*sqs.ReceiveMessageInput)
0: &context.cancelCtx{...err:atomic.Value{v:(*errors.errorString)...}}
1: &sqs.ReceiveMessageInput{QueueUrl:(*string)(0x14000909c70), MaxNumberOfMessages:10, ...}
Additional context
The error shows ReceiveMessage was called with a canceled context, suggesting a race between:
- The watcher goroutine making a
ReceiveMessagecall afterStart()is invoked - The test canceling/stopping the watcher before mock expectations are fully exercised
Potential fixes:
- Add mock expectation for
ReceiveMessagethat handles the post-cancellation call - Ensure context cancellation is checked before calling SQS methods
- Use
mock.Anythingfor context matching to handle different context states - Add synchronization between test setup and watcher goroutine startup
Reactions are currently unavailable