-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
test: fix flaky Snapshotter test #21878
Conversation
WalkthroughWalkthroughThe changes involve updates to the test function Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (2)
x/auth/ante/unorderedtx/snapshotter_test.go (2)
52-54
: Approve changes with a minor suggestionThe replacement of
time.Sleep
calls withrequire.Eventually
is a significant improvement that addresses the flaky test issue. This change makes the test more robust and less dependent on fixed timing.Consider updating the comment on line 53 to better reflect the new waiting mechanism:
- // the loop runs every 5 seconds, so we need to wait for that + // Wait for the background purge loop to complete (runs every 5 seconds)This change would make the comment more accurate and informative in the context of the new implementation.
Additional Instances of
time.Sleep
Found in Test FilesThe search revealed several instances of
time.Sleep
in the following test files:
store/rootmulti/store_test.go
store/snapshots/helpers_test.go
store/v2/snapshots/store_test.go
store/v2/root/migrate_test.go
baseapp/baseapp_test.go
Refactoring these tests to replace fixed sleep durations with adaptive waiting mechanisms can further improve the reliability and stability of the test suite.
Analysis chain
Line range hint
1-70
: Overall improvement with potential for further enhancementThe changes successfully address the flaky test issue by replacing fixed sleep durations with a more adaptive waiting mechanism. This improvement aligns well with the PR objectives and enhances the test's reliability.
Consider extending this improvement to other parts of the test suite where similar timing-dependent assertions are made. This could further enhance the overall stability of the test suite.
To identify other potential candidates for similar improvements, we can search for other uses of
time.Sleep
in test files:This will help identify other test files that might benefit from a similar refactoring approach.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for time.Sleep usage in test files rg --type go -g '*_test.go' 'time\.Sleep' -C 3Length of output: 3445
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- x/auth/ante/unorderedtx/snapshotter_test.go (1 hunks)
Additional context used
Path-based instructions (1)
x/auth/ante/unorderedtx/snapshotter_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
(cherry picked from commit bc3ddfa)
Co-authored-by: Alexander Peters <[email protected]>
Description
Part of #21804
Sometimes the pruning job started by the test is not completed before the test reaches the checkpoint (L55 before).
By refactoring this part to the await pattern and increasing the max timeout to 6s, the test should become stable and faster in the optimal scenario.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit