Skip to content
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

Merged
merged 16 commits into from
Nov 18, 2023
Merged

Conversation

sleberknight
Copy link
Member

@sleberknight sleberknight commented Nov 16, 2023

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

@sleberknight sleberknight self-assigned this Nov 16, 2023
@sleberknight
Copy link
Member Author

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

@sleberknight sleberknight changed the title Investigate ForkJoinPool init time in GitHub actions Investigate flaky tests in AsyncTest Nov 16, 2023
@sleberknight
Copy link
Member Author

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)
@sleberknight sleberknight linked an issue Nov 18, 2023 that may be closed by this pull request
@sleberknight sleberknight changed the title Investigate flaky tests in AsyncTest Fix flaky tests in AsyncTest Nov 18, 2023
@sleberknight sleberknight marked this pull request as draft November 18, 2023 00:24
@sleberknight sleberknight marked this pull request as ready for review November 18, 2023 02:14
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sleberknight sleberknight merged commit 7b13e28 into master Nov 18, 2023
6 checks passed
@sleberknight sleberknight deleted the 1070-flaky-test-investigation branch November 18, 2023 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate flaky test in AsyncTest
1 participant