Repository navigation
[10.x] Fix timing sensitive flaky test - #48664
Merged
taylorotwell merged 1 commit intoOct 9, 2023
Merged
Conversation
KentarouTakeda
force-pushed
the
fix-timing-sensitive-flaky-test
branch
from
October 7, 2023 09:54
9a6d146 to
9de304b
Compare
timacdonald
pushed a commit
to timacdonald/framework
that referenced
this pull request
Oct 24, 2023
This was referenced Jan 16, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed the issue where the Queue retry time test, when using the Redis Driver, would occasionally fail.
For example, #48662 (comment) also seems to have encountered this problem.
An earlier attempt was made to address this problem by retrying the test itself, as seen in commit e0d8e3d .
However, it was not a fundamental solution.
In the test, we specified a delay of 10 minutes and asserted that the actual delay was 600 seconds . However, due to the time elapsed during the test execution, the test may rarely reach 599 seconds and fail. I solved this problem by fixing the time using
Carbon::setTestNow()at the beginning of the test.Before the fix, the test would fail after about 30 to 100 attempts. After the fix, I tried it 10,000 times and it didn't fail.
Note
It actually asserts for more than 600 seconds. This is because redis-server calculates the retry time, so it cannot be controlled with setTestNow().
framework/src/Illuminate/Redis/Limiters/DurationLimiter.php
Lines 103 to 114 in cddb4f3