Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[RateLimiter] bug #42194 fix: sliding window policy to use microtime#43677
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| $this->assertFalse($new->isExpired()); | ||
| } | ||
| publicfunctiontestCreateFromPreviousWindowUsesMicrotime() |
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.
These tests consistently pass after the changes. The old code would inconsistently fail, though (depend on themicrotome(true) result at the moment of running the test.
jlekowski commentedOct 23, 2021
Nyholm left a comment
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.
Thank you
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedOct 24, 2021
Thank you@jlekowski. |
chalasr commentedOct 24, 2021
This PR introduced a randomly failing testhttps://github.com/symfony/symfony/runs/3990643552?check_suite_focus=true#step:8:987.@jlekowski could you please have a look? |
jlekowski commentedOct 24, 2021
@chalasr, I'll have a look at it. Thanks for letting me know. |
…se microtime - fix test (jlekowski)This PR was merged into the 5.4 branch.Discussion----------[RateLimiter] bug#42194 fix: sliding window policy to use microtime - fix test| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets |Fix#42194 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License | MIT| Doc PR | symfony/symfony-docs#... <!-- required for new features -->As pointed out in the comment#43677 (comment), `RateLimitTest::testWaitUsesMicrotime()` fails intermittently.I have looked at all `PHPUnit` actions since the test was introduced and interestingly, the fails only occurred during `7.2` test, and the time difference was always ~1.3s.Commits-------e616963 bug#42194 [RateLimiter] fix: sliding window policy to use microtime - fix test
Other parts of
RateLimiterusemicrotime(), while sliding window policy usestime()instead. That means the window may expire only up to 0.(9) seconds after the interval. Below an example that fails (window not expired) majority of the times (window is expired only if it starts e.g. at 1634992063.4999 and is checked at 1634992065.5000 - withtime()rounding it would be 3 seconds).