-
Notifications
You must be signed in to change notification settings - Fork 1
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 tests in AsyncTest #1076
Conversation
This relates to #1070 Pretty sure it has nothing to do with ForkJoinPool init time and that it is due to tasks from previous tests that used the common pool and which are still executing and blocking the new tests...which then causes them to exceed the timeout and fail |
I don't really understand why this only happens when running in GitHub actions - I'm using the same JDK on my laptop and when using Gitpod, so only thing I can think of is differences in the JVM behavior on different operating systems, e.g. on my MacBook Pro versus in Gitpod versus in GitHub Actions. |
* Replace hard-coded test names by using TestInfo in setUp * Delete the commented-out code * Remove logging from shouldTimeout_WhenTaskTakesLongerThan_MaxTimeout in WithMaxTimeout nested class; I realized that above those we wait until the future with timeout has completed exceptionally, so the logs were not helpful
Wrap assertions in a try and cancel in a finally
Of course, they always pass when running locally on my MacBook Pro or even in Gitpod. I don't get why I can never make them fail locally, but they consistently fail when running in GitHib actions without the cancellations.
* Remove the RetryingTest annotations * Remove javadocs on formerly retrying tests, since they are no longer retrying tests (and we hope now always pass in GitHub actions where they were flaky)
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Ensure that the tests all pass consistently by canceling the futures in the tests
where we expect to timeout before the tasks complete. Without canceling them,
tests which call methods in Async that use the common ForkJoinPool can be
blocked by tasks that are still executing from previous tests! So, in the three tests
where waitFor/waitForAll/waitForAllIgnoringTypes time out before the tasks complete,
wrap the assertions in a try/finally and cancel the futures in the finally block. This
commit also removes the RetryingTest annotations on the four tests which had them
and replaces them with the standard JUnit Test annotation. Hopefully this will be
the last time we ever need to deal with flaky tests in Async.
Closes #1070