apache / apache/maven-surefire
[SUREFIRE-1575] Distribute tests ad-hoc across foks
- Dominant language
- Java
- Stars
- 461
- Forks
- 588
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 19
Description
**[Julian Orth](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jorth)** opened **[SUREFIRE-1575](https://issues.apache.org/jira/browse/SUREFIRE-1575?redirect=false)** and commented
Hi,
consider the case where surefire is configured with `forkCount > 1`. Currently the distribution of classes across forks appears to work as follows:
* Divide all included test classes in `forkCount` buckets and write each bucket to a jar
* Start `forkCount` JVMs, each with one of the jars as an argument
* Have each JVM run the tests in its jar
This can cause less than optimal test run times. For example:
* If a significant number of tests is excluded via the `groups` mechanism, all but one JVM might exit immediately, leaving the remaining JVM to execute all included tests.
* If a large number of tests runs in a small amount of time and a small number of tests consume almost 100% of the single-JVM run time, then these expensive tests might be assigned to a single JVM.
Therefore, I would like to suggest the following changes to the distribution process:
* All `forkCount` JVMs are started with the same jar.
* Whenever one of the forks wants to run a test class, it asks the master process for the next test class name via some IPC mechanism. I assume such an IPC mechanism already exists for sending _Running_ and _Tests run_ messages.
* If there is another unrun test class, the master process sends the fully qualified class name, otherwise it notifies the child that there are no more tests to run.
* The child then exits if there are no more test classes or runs the test class.
Via this mechanism, the test run time achieves the theoretically optimal time of `sum(individual test run times) / forkCount + (time of longest runnning test class)`.
I would be willing to implement this.
Julian
---
**Affects:** 2.22.0
Contributor guide
Research direction
Trace the existing fork distribution and the IPC used for _Running_ and _Tests run_ messages. Compare how test classes are assigned to jars and forks, then define the master-child communication needed for on-demand class assignment. Done means forks share the test set, request unrun classes, stop when none remain, and preserve test execution behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100