Add support for non-fork-join test executor #3685
Open
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.
Overview
Since there wasn't much feedback in #3108, I figured I'd open a PR with what I have to see if it helps. I reiterate some comments from the linked issue and add some more info.
The idea is to allow a different executor with a fixed thread pool to execute actual tests in parallel in order to avoid potential conflicts with user code if they also rely on the JVM's fork-join APIs. The default would remain as before. Users could then change the executor via configuration.
I wrote a couple of TODOs, but they're both related to my understanding of
CONCURRENT
execution mode semantics. The current implementation checks execution mode in bothsubmit
andforkConcurrentTasks
+executeNonConcurrentTasks
, but in both scenarios, if the task is not concurrent, it executes it in the current thread, and that doesn't know if some other thread in the pool has stolen work and is executing another test, so is it really guaranteeing that no other test is running at the same time?I added a method
ExclusiveTask#await
and use it instead ofjoin
injoinConcurrentTasksInReverseOrderToEnableWorkStealing
- if the task should execute in aForkJoinWorkerThread
,await
delegates tojoin
, otherwise it delegates tocompute
. If I don't do it like this, the tests execute fine and are even show as PASSED in the terminal, but after that everything stalls and all threads in the fork-join pool remain parked, and I cannot figure out why. I tried to reproduce this outside of a JUnit 5 session and I couldn't.I added
FixedThreadsParallelExecutionIntegrationTests
as an almost identical copy ofParallelExecutionIntegrationTests
but using the fixed thread pool for test execution, and I can see that there are a lot of failures. I spent some time looking through the logic to see if I could figure out how it's set up, but I couldn't make much progress, I would appreciate feedback if I'm understanding the tests incorrectly. I will point out something more about this in the comments below.I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations