-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix flaky SearchCancellationIT tests to avoid race condition #5656
Fix flaky SearchCancellationIT tests to avoid race condition #5656
Conversation
Signed-off-by: Daniel Widdis <widdis@gmail.com>
@@ -241,7 +241,8 @@ public void testCancellationDuringQueryPhaseUsingRequestParameter() throws Excep | |||
.execute(); | |||
awaitForBlock(plugins); | |||
// sleep for cancellation timeout to ensure scheduled cancellation task is actually executed |
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.
This comment is no longer accurate. How about a static sleepForTimeout()
or similar method so you only have to write the comment once?
Also, any idea why 2 seconds is used everywhere here? Would be great to make that something shorter (like 100ms) to speed up the test.
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.
But I was having so much fun copying and pasting with The Key. Sure, I'll make a static call. Not sure what the best minimum should be, but I'm guessing I could make it 1 second at least?
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.
Sure. You'll make it twice as fast!
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ Coverage Diff @@
## main #5656 +/- ##
============================================
+ Coverage 70.96% 71.10% +0.14%
- Complexity 58550 58648 +98
============================================
Files 4760 4760
Lines 279515 279515
Branches 40348 40348
============================================
+ Hits 198367 198762 +395
+ Misses 65037 64576 -461
- Partials 16111 16177 +66
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
* Add waiting time to account for Thread.sleep inaccuracy Signed-off-by: Daniel Widdis <widdis@gmail.com> (cherry picked from commit d248643) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…5657) * Add waiting time to account for Thread.sleep inaccuracy Signed-off-by: Daniel Widdis <widdis@gmail.com> (cherry picked from commit d248643) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Daniel Widdis <widdis@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…5657) * Add waiting time to account for Thread.sleep inaccuracy Signed-off-by: Daniel Widdis <widdis@gmail.com> (cherry picked from commit d248643) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Daniel Widdis <widdis@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Daniel Widdis widdis@gmail.com
Description
Thread.sleep()
does not sleep for precise amounts:Tests in the
SearchCancellationIT
class relied on sleeping for exactly the cancellation timeout, which creates potential race conditions and occasional test failures.This PR adds an extra 100ms of sleep time before checking the cancellation status.
Issues Resolved
Fixes #2242
Fixes #2311
Fixes #2763
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.