-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: race condition with cleanup and parallel #96
Comments
it seems like this also might impact the general writing/updating of snapshots - I've been finding while working on google/osv-scanner#889 that I have to run the suite twice to ensure all snapshots are updated |
Hey 👋 sorry I have been off sick. But will have a look asap when I am back. Thanks for the investigation and creating this issue. |
Hey no worries - you focus on getting better :) For now I've written a python script that ill post shortly to do the sorting and cleanup which seems to be working well |
Hey I am partially back 😄 . I have rewritten this message three times thinking i knew what the problem is 😅 This time I think I know. I think the problem lies at https://github.com/gkampitakis/go-snaps/blob/main/snaps/snapshot.go#L131 not being protected with a lock. Will try to verify my theory the coming days and create a pr if you want to test it with. Needs some thinking the way I am handling locking there. Again thank you for opening this issue and sorry for the inconvenience. |
awesome stuff! fwiw this is the Python script I wrote:
(I want to share it somewhere since it won't even need to go into a PR now 😅) |
Sorry for the need of the script. Hope the change solves this problem 😄 Feel free to reopen the issue if you still notice an error. |
Description
It seems there's a race condition with cleaning up snapshots when using parallel tests that means if a snapshot changes there's a chance any of the snapshots in the same file could be duplicates, moved around, etc.
Steps to Reproduce
Run with
UPDATE_SNAPS=true go test ./...
:Running it multiple times will compound the result:
Note that you can reproduce this without the looping, it just makes it a lot easier - but importantly my
TestMain
here is not interfering with the cleanup function.Commenting out the
t.Parallel
calls resolves the issueExpected Behavior
The snapshot order is stable, and snapshots are not duplicated.
The text was updated successfully, but these errors were encountered: