forked from twitter/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.
ConsoleRunner bugfix for @TestSerial and other test cleanups
This change started as just adding tests to show that parallelization is working correctly under Parameterized and BurstJUnit4 test runners, but ended up also finding a bug. - Fix bug in ConsoleRunnerImpl - Don't run parallel methods when test class is annotated with @TestSerial or @TestParallel - Fix testing bug in all Concurrency related tests - reset the concurrency parameters before each test permutation - Fix testing bug in ParallelMethodsDefaultParallelTest1: only wait for 2 tests to start - Fix testing bug that -default-concurrency flag was overwritten in ConsoleRunnerTestBase - Add MockParameterizedTest and friends to show tests running parallel under the Parameterized test runner library - Add MockBurstTest and friends to show tests running parallel under the Burst library - Use assumeThat() to skip test permutations that won't work with specified tests Testing Done: Added several new unit tests CI running at https://travis-ci.org/pantsbuild/pants/builds/140590946 Bugs closed: 3604 Reviewed at https://rbcommons.com/s/twitter/r/4026/
- Loading branch information
1 parent
7a63b45
commit c432f6d
Showing
18 changed files
with
410 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
jar_library(name='burst-junit4', | ||
jars=[ | ||
jar(org='com.squareup.burst', name='burst-junit4', rev='1.1.0'), | ||
], | ||
) |
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
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
43 changes: 43 additions & 0 deletions
43
tests/java/org/pantsbuild/tools/junit/lib/MockBurstParallelClassesAndMethodsTest1.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,43 @@ | ||
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
package org.pantsbuild.tools.junit.lib; | ||
|
||
import com.squareup.burst.BurstJUnit4; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
@RunWith(BurstJUnit4.class) | ||
public class MockBurstParallelClassesAndMethodsTest1 { | ||
private static final int NUM_CONCURRENT_TESTS = 5; | ||
private static final int RETRY_TIMEOUT_MS = 1000; | ||
private static CountDownLatch latch = new CountDownLatch(NUM_CONCURRENT_TESTS); | ||
|
||
private final ColorType colorType; | ||
public enum ColorType { | ||
RED, BLUE | ||
} | ||
|
||
public static void reset() { | ||
latch = new CountDownLatch(NUM_CONCURRENT_TESTS); | ||
} | ||
|
||
public MockBurstParallelClassesAndMethodsTest1(ColorType colorType) { | ||
this.colorType = colorType; | ||
} | ||
|
||
@Test | ||
public void bpcamtest1() throws Exception { | ||
awaitLatch("bpcamtest1:" + colorType.name()); | ||
} | ||
|
||
static void awaitLatch(String methodName) throws Exception { | ||
TestRegistry.registerTestCall(methodName); | ||
latch.countDown(); | ||
assertTrue(latch.await(RETRY_TIMEOUT_MS, TimeUnit.MILLISECONDS)); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/java/org/pantsbuild/tools/junit/lib/MockBurstParallelClassesAndMethodsTest2.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,25 @@ | ||
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
package org.pantsbuild.tools.junit.lib; | ||
|
||
import com.squareup.burst.BurstJUnit4; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(BurstJUnit4.class) | ||
public class MockBurstParallelClassesAndMethodsTest2 { | ||
private final FruitType fruitType; | ||
public enum FruitType { | ||
APPLE, BANANA, CHERRY | ||
} | ||
|
||
public MockBurstParallelClassesAndMethodsTest2(FruitType fruitType) { | ||
this.fruitType = fruitType; | ||
} | ||
|
||
@Test | ||
public void bpcamtest1() throws Exception { | ||
MockBurstParallelClassesAndMethodsTest1.awaitLatch("bpcamtest2:" + fruitType.name()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/java/org/pantsbuild/tools/junit/lib/MockBurstParallelMethodsTest.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,43 @@ | ||
// Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
package org.pantsbuild.tools.junit.lib; | ||
|
||
import com.squareup.burst.BurstJUnit4; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
@RunWith(BurstJUnit4.class) | ||
public class MockBurstParallelMethodsTest { | ||
private static final int NUM_CONCURRENT_TESTS = 6; | ||
private static final int RETRY_TIMEOUT_MS = 1000; | ||
private static CountDownLatch latch = new CountDownLatch(NUM_CONCURRENT_TESTS); | ||
|
||
private final QuarkType quarkType; | ||
public enum QuarkType { | ||
UP, DOWN, STRANGE, CHARM, TOP, BOTTOM | ||
} | ||
|
||
public static void reset() { | ||
latch = new CountDownLatch(NUM_CONCURRENT_TESTS); | ||
} | ||
|
||
public MockBurstParallelMethodsTest(QuarkType quarkType) { | ||
this.quarkType = quarkType; | ||
} | ||
|
||
@Test | ||
public void bpmtest1() throws Exception { | ||
awaitLatch("bpmtest1:" + quarkType.name()); | ||
} | ||
|
||
static void awaitLatch(String methodName) throws Exception { | ||
TestRegistry.registerTestCall(methodName); | ||
latch.countDown(); | ||
assertTrue(latch.await(RETRY_TIMEOUT_MS, TimeUnit.MILLISECONDS)); | ||
} | ||
} |
Oops, something went wrong.