-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit the number of concurrently executing tests via a property
JUnit Jupiter (and The JUnit Platform) now support limiting the maximum number of concurrently executing tests via the `junit.jupiter.execution.parallel.config.fixed.max-pool-size` property. With Java 9+ the `ForkJoinPool` used by JUnit can be configured with a maximum pool size. While the number of concurrently executing tests may exceed the configured parallelism when tests become blocked, it will not exceed the maximum pool size. With the following configuration: ```properties junit.jupiter.execution.parallel.enabled=true junit.jupiter.execution.parallel.config.strategy=fixed junit.jupiter.execution.parallel.mode.default=concurrent junit.jupiter.execution.parallel.config.fixed.parallelism=2 ``` This example will report between 2-5 tests running concurrently. ```java class ExampleTest { private static final AtomicInteger running = new AtomicInteger(); @beforeeach void increment() { System.out.println("Running " + running.incrementAndGet()); } @AfterEach void decrement() { running.decrementAndGet(); } static IntStream numbers() { return IntStream.range(0, 1000); } @ParameterizedTest @MethodSource("numbers") void test(int i) throws ExecutionException, InterruptedException { Runnable sleep = () -> { try { Thread.sleep(600); } catch (InterruptedException e) { throw new RuntimeException(e); } }; ForkJoinPool.commonPool().submit(sleep).get(); } } ``` By also configuring the `max-pool-size` we can ensure the concurrently executing test does not exceed the configured 2. ```properties junit.jupiter.execution.parallel.config.fixed.max-pool-size=2 ``` Additionally, because the `ForkJoinPool` will by default reject tasks that would exceed the maximum pool size the `junit.jupiter.execution.parallel.config.fixed.saturate` property has been added and will default to `true`. There appears to be no reason to ever set this `false` but it is there should someone depend on the old behaviour. These changes were intentionally not made to the `dynamic` strategy to limit the scope of this pull request. While I can reasonably predict what behaviour users of the `fixed` strategy might expect, I can not say the same about the `dynamic` strategy. Fixes: #3026 Fixes: #2545 Fixes: #1858
- Loading branch information
1 parent
2332b18
commit dccc0c7
Showing
7 changed files
with
185 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
documentation/src/docs/asciidoc/release-notes/release-notes-5.10.0-M1.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[[release-notes-5.10.0-M1️]] | ||
== 5.10.0-M1️ | ||
|
||
*Date of Release:* ❓ | ||
|
||
*Scope:* ❓ | ||
|
||
For a complete list of all _closed_ issues and pull requests for this release, consult the | ||
link:{junit5-repo}+/milestone/5.10.0-M1️?closed=1+[5.10.0-M1️] milestone page in the JUnit repository on | ||
GitHub. | ||
|
||
|
||
[[release-notes-5.10.0-M1️-junit-platform]] | ||
=== JUnit Platform | ||
|
||
==== Bug Fixes | ||
|
||
* ❓ | ||
|
||
==== Deprecations and Breaking Changes | ||
|
||
* ❓ | ||
|
||
==== New Features and Improvements | ||
|
||
* Support limiting the number of concurrently executing tests via a property | ||
|
||
[[release-notes-5.10.0-M1️-junit-jupiter]] | ||
=== JUnit Jupiter | ||
|
||
==== Bug Fixes | ||
|
||
* ❓ | ||
|
||
==== Deprecations and Breaking Changes | ||
|
||
* The `fixed` parallel execution strategy will allow the thread pool to be saturated by | ||
default | ||
|
||
==== New Features and Improvements | ||
|
||
* Added the `junit.jupiter.execution.parallel.config.fixed.max-pool-size` configuration | ||
property. | ||
* Added the `junit.jupiter.execution.parallel.config.fixed.saturate` configuration | ||
property. | ||
|
||
[[release-notes-5.10.0-M1️-junit-vintage]] | ||
=== JUnit Vintage | ||
|
||
==== Bug Fixes | ||
|
||
* ❓ | ||
|
||
==== Deprecations and Breaking Changes | ||
|
||
* ❓ | ||
|
||
==== New Features and Improvements | ||
|
||
* ❓ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters