forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update junit-runner to version 1.0.9 and test new experimental runner…
… logic - Bumps junit-runner to version 1.0.9 to include new experimental runner logic - Bump removal version of `--default-parallel` to 1.3.0 (since this never made it into 1.0.0 and the deprecation cycle is to last 2 minor versions) - Don't pass -default-parallel down to the runner any more - Adds a test to insure that the deprecated `--default-parallel` option still works. - The old "ParallelMethods" Junit tests were really testing the "ParallelClassesAndMethods" logic. Renamed them. - Created new "ParallelMethods" Junit tests both in testprojects and the Junit runner mock tests. - Updated the concurrency integration test to run both with the legacy and experimental runner. - Added caveat about using test sharding with the PARALLEL_METHODS - Cleanup comments that referenced the old -parallel-methods and deprecated -default-parallel option Testing Done: CI green at https://travis-ci.org/pantsbuild/pants/builds/134707560 Bugs closed: 3493 Reviewed at https://rbcommons.com/s/twitter/r/3925/
- Loading branch information
1 parent
8beda3e
commit 5bd0053
Showing
18 changed files
with
368 additions
and
82 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
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
21 changes: 21 additions & 0 deletions
21
testprojects/tests/java/org/pantsbuild/testproject/parallelclassesandmethods/BUILD
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,21 @@ | ||
# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
junit_tests(name='parallelclassesandmethods', | ||
sources=globs('*.java'), | ||
dependencies=[ | ||
'3rdparty:junit', | ||
], | ||
concurrency='PARALLEL_CLASSES_AND_METHODS', | ||
threads=4, | ||
) | ||
|
||
# This target runs the same tests as the one above, but doesn't have the concurrency settings. | ||
# Relies on the test.junit options being set as follows: | ||
# --test-junit-default-concurrency=PARALLEL_CLASSES_AND_METHODS --test-junit-parallel-threads=4 | ||
junit_tests(name='cmdline', | ||
sources=globs('*.java'), | ||
dependencies=[ | ||
'3rdparty:junit', | ||
], | ||
) |
50 changes: 50 additions & 0 deletions
50
.../testproject/parallelclassesandmethods/ParallelClassesAndMethodsDefaultParallelTest1.java
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,50 @@ | ||
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
package org.pantsbuild.testproject.parallelclassesandmethods; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* This test is designed to exercise the test.junit task argument: | ||
* --test-junit-default-concurrency=PARALLEL_CLASSES_AND_METHODS | ||
* <P> | ||
* There is a similar test under tests/java/ to test the junit-runner standalone. | ||
* <p> | ||
* For all methods in ParallelClassesAndMethodsDefaultParallelTest1 and | ||
* ParallelClassesAndMethodsDefaultParallelTest2 to succeed all of the test methods must be | ||
* running at the same time. Also, both classes must be running at the same time. | ||
* Intended to test the flags: | ||
* <pre> | ||
* --test-junit-default-concurrency=PARALLEL_CLASSES_AND_METHODS--test-junit-parallel-threads=4 | ||
* <pre> | ||
* when running with just these two classes as specs. | ||
* <p> | ||
* Runs in on the order of 10 milliseconds locally, but it may take longer on a CI machine to spin | ||
* up 4 threads, so it has a generous timeout set. | ||
*/ | ||
public class ParallelClassesAndMethodsDefaultParallelTest1 { | ||
private static final int NUM_CONCURRENT_TESTS = 4; | ||
private static final int RETRY_TIMEOUT_MS = 3000; | ||
private static CountDownLatch latch = new CountDownLatch(NUM_CONCURRENT_TESTS); | ||
|
||
@Test | ||
public void pbdptest11() throws Exception { | ||
awaitLatch("pbdptest11"); | ||
} | ||
|
||
@Test | ||
public void pbdptest12() throws Exception { | ||
awaitLatch("pbdptest12"); | ||
} | ||
|
||
static void awaitLatch(String methodName) throws Exception { | ||
System.out.println("start " + methodName); | ||
latch.countDown(); | ||
assertTrue(latch.await(RETRY_TIMEOUT_MS, TimeUnit.MILLISECONDS)); | ||
System.out.println("end " + methodName); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../testproject/parallelclassesandmethods/ParallelClassesAndMethodsDefaultParallelTest2.java
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,21 @@ | ||
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
package org.pantsbuild.testproject.parallelclassesandmethods; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* See {@link ParallelClassesAndMethodsDefaultParallelTest1} | ||
*/ | ||
public class ParallelClassesAndMethodsDefaultParallelTest2 { | ||
|
||
@Test | ||
public void pbdptest21() throws Exception { | ||
ParallelClassesAndMethodsDefaultParallelTest1.awaitLatch("pbdptest21"); | ||
} | ||
|
||
@Test | ||
public void pbdptest22() throws Exception { | ||
ParallelClassesAndMethodsDefaultParallelTest1.awaitLatch("pbdptest22"); | ||
} | ||
} |
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
Oops, something went wrong.