-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support parallelization in junit-vintage-engine #4135
Support parallelization in junit-vintage-engine #4135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting the draft! I left a bunch of comments. 🙂
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
Signed-off-by: yongjunhong <[email protected]>
c25db8c
to
e12b155
Compare
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
Issue: junit-team#3717 Signed-off-by: yongjunhong <[email protected]>
If the parallelization work is completed, I would appreciate it if you could take a look at the Open Question in the PR description 😀 |
@YongGoose The last two weeks were very busy. I should be able to get to your PRs early next week, though. Cheers! |
I think it should be similar to the configuration parameters in Jupiter. Thus, I'd suggest we use |
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Show resolved
Hide resolved
Issue: junit-team#2229 Signed-off-by: yongjunhong <[email protected]>
Issue: junit-team#2229 Signed-off-by: yongjunhong <[email protected]>
That's a great idea! I made this change in e0312cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a next step, could you please add some tests?
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java
Outdated
Show resolved
Hide resolved
…ntageTestEngine.java Co-authored-by: Marc Philipp <[email protected]>
Issue: junit-team#2229 Signed-off-by: yongjunhong <[email protected]>
@marcphilipp In this test case, the return value of
private boolean executeInParallel(VintageEngineDescriptor engineDescriptor,
EngineExecutionListener engineExecutionListener, ExecutionRequest request) {
ExecutorService executorService = Executors.newFixedThreadPool(getThreadPoolSize(request));
RunnerExecutor runnerExecutor = new RunnerExecutor(engineExecutionListener);
List<CompletableFuture<Void>> futures = new ArrayList<>();
for (Iterator<TestDescriptor> iterator = engineDescriptor.getModifiableChildren().iterator(); iterator.hasNext();) {
TestDescriptor descriptor = iterator.next();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
runnerExecutor.execute((RunnerTestDescriptor) descriptor);
}, executorService);
futures.add(future);
iterator.remove();
}
@Test
void successfulParallelTest(TestReporter reporter) {
var events = executeInParallelSuccessfully(3, SuccessfulParallelTestCase.class).list();
var startedTimestamps = getTimestampsFor(events, event(test(), started()));
var finishedTimestamps = getTimestampsFor(events, event(test(), finishedSuccessfully()));
reporter.publishEntry("startedTimestamps", startedTimestamps.toString());
reporter.publishEntry("finishedTimestamps", finishedTimestamps.toString());
assertThat(startedTimestamps).hasSize(3);
assertThat(finishedTimestamps).hasSize(3);
}
@RunWith(Enclosed.class)
public class JUnit4ParallelTestCase {
public static class SuccessfulParallelTestCase {
static AtomicInteger sharedResource;
static CountDownLatch countDownLatch;
@BeforeClass
public static void initialize() {
sharedResource = new AtomicInteger();
countDownLatch = new CountDownLatch(3);
}
@Test
public void firstTest() throws Exception {
incrementAndBlock(sharedResource, countDownLatch);
}
@Test
public void secondTest() throws Exception {
incrementAndBlock(sharedResource, countDownLatch);
}
@Test
public void thirdTest() throws Exception {
incrementAndBlock(sharedResource, countDownLatch);
}
}
... Question
I believe the commit will make it easier to understand. 1484347 While implementing recursion, I noticed something unusual. When fetching If that’s the case, it seems unavoidable to modify the internal code to implement parallel execution of Alternatively, we could proceed with the current approach instead of |
de8fbce
to
1484347
Compare
Do you mean that running the children of a JUnit 4 actually has a feature that allows running methods in parallel. It works for all subclasses of |
Exactly!
I'll work on it in the next PR along with the issue once this PR is complete!
I was actually considering this issue, so thank you for the detailed suggestion!👍🏻 |
Issue: junit-team#2229 Signed-off-by: yongjunhong <[email protected]>
1484347
to
b196388
Compare
I implemented it by extracting and comparing thread names when executing test classes. b196388 I understand that in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add an entry to the release notes and a section to the User Guide (as a new section in the "Migrating from JUnit 4" chapter)
...gine/src/test/java/org/junit/vintage/engine/execution/ParallelExecutionIntegrationTests.java
Outdated
Show resolved
Hide resolved
Sounds like a great idea. Thank you🙂 |
Issue: junit-team#4135 Signed-off-by: yongjunhong <[email protected]>
Issue: junit-team#4135 Signed-off-by: yongjunhong <[email protected]>
I hope I did it well this time... I have a question while writing the release notes. Shouldn't the details of this PR also be included in the release notes?
|
d6fd75e
to
6b88011
Compare
Issue: junit-team#2229 Signed-off-by: yongjunhong <[email protected]>
6b88011
to
e572ab3
Compare
Additionally, once this PR is merged, I will create an issue regarding that comment and start working on it! |
Good catch! Indeed, that was an oversight on my part which I've now rectified in 4f926ed. |
...gine/src/test/java/org/junit/vintage/engine/execution/ParallelExecutionIntegrationTests.java
Outdated
Show resolved
Hide resolved
80c882c
to
9264d18
Compare
9264d18
to
52ec88b
Compare
Thanks, you did! I polished your work a bit anyway because we're quite particular. Don't worry about it! 🙂 |
This reverts commit 5f9917b.
@YongGoose Once again, thank you for your contribution! 🙇 |
Overview
Resolves #2229
This PR implements parallel execution support for the JUnit Vintage engine, addressing issue #2229.
concurrent execution
of test descriptors when parallel execution is enabled.planned
)Open Question
I haven’t yet worked on the part that handles reading configuration parameters, such as whether
parallel execution
should be enabled or the number of threads to be used.Is there a specific configuration format or approach you would recommend for this?
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations