-
Notifications
You must be signed in to change notification settings - Fork 178
fix: make random test deterministic to avoid flakiness #4334
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
base: master
Are you sure you want to change the base?
fix: make random test deterministic to avoid flakiness #4334
Conversation
|
Warning Rate limit exceeded@karishka1222 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 52 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
""" WalkthroughThe change introduces a global Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
CodeRabbit Configuration File (
|
🚀 Performance AnalysisAll benchmarks are within the acceptable range. No critical degradation detected (threshold is 100%). Please refer to the detailed report for more information. Click to see the detailed report
✅ Performance gain: |
|
@yegor256 Hello, can you check this pull request, please |
|
@maxonfjvipon thoughts? |
| [] +> tests-two-random-numbers-not-equal | ||
| not. > @ | ||
| random.pseudo.eq random.pseudo | ||
| (random 123).fixed.eq (random 456).fixed |
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.
@karishka1222 actually, this test done his job pretty well, it tests that two pseudo random numbers which are relied on system time, are actually different.
So there's no need to change the test because it does not solve the original problem: sometimes we get the same seed in random.pseudo on windows. I think it's a bug in random.pseudo implementation.
So let's fix it and make it more trustable?
|
@maxonfjvipon I've kept the original test as it was. To fix the root cause, I changed random.pseudo to include a global counter in the seed calculation. |
|
@maxonfjvipon check, please |
Fix Flaky Random Test
What was done:
tests_two_random_numbers_not_equalthat was failing due to identical system time between consecutive callsWhy this fixes the issue:
random.pseudo.eq random.pseudowhich could fail when system time didn't change between calls(random 123).fixed.eq (random 456).fixedwhich is deterministic and always produces different resultsEOrandom_testsTest.tests_two_random_numbers_not_equal:419expected: <true> but was: <false> #4184Testing:
Resolves: #4184
Summary by CodeRabbit