Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SUREFIRE [1048] Surefire does not use the total amount of threads spe…

…cified by threadCount
  • Loading branch information...
commit 0abc1d5a3f2495155e86fdb77f16f48cef543cc9 1 parent 9ef1843
@Tibor17 authored
Showing with 381 additions and 190 deletions.
  1. +26 −4 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
  2. +2 −0  surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderParameterNames.java
  3. +17 −6 surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
  4. +1 −1  surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
  5. +3 −3 surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
  6. +74 −52 ...e-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ParallelComputerFactory.java
  7. +60 −15 ...roviders/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
  8. +43 −0 surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/RunnerCounter.java
  9. +46 −0 surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java
  10. +4 −4 ...e-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
  11. +104 −104 ...oviders/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ParallelComputerFactoryTest.java
  12. +1 −1  surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
View
30 ...-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -495,6 +495,17 @@
protected String parallel;
/**
+ * (JUnit 4.7 / provider only) The thread counts do not exceed the number of parallel suite, class runners and
+ * average number of methods per class if set to <strong>true</strong>.
+ * <p/>
+ * True by default.
+ *
+ * @since 2.17
+ */
+ @Parameter( property = "parallelOptimized", defaultValue = "true" )
+ protected boolean parallelOptimized;
+
+ /**
* (JUnit 4.7 provider) The attribute thread-count-suites allows you to specify the concurrency in test suites, i.e.:
* <ul>
* <li>number of threads executing JUnit test suites if <code>threadCount</code> is 0 or unspecified</li>
@@ -1147,12 +1158,14 @@ private void convertJunitCoreParameters() throws MojoExecutionException
Double.toString( getParallelTestsTimeoutInSeconds() ) );
getProperties().setProperty( ProviderParameterNames.PARALLEL_TIMEOUTFORCED_PROP,
Double.toString( getParallelTestsTimeoutForcedInSeconds() ) );
+ getProperties().setProperty( ProviderParameterNames.PARALLEL_OPTIMIZE_PROP,
+ Boolean.toString( isParallelOptimized() ) );
String message =
"parallel='" + usedParallel + '\'' + ", perCoreThreadCount=" + getPerCoreThreadCount() + ", threadCount="
+ usedThreadCount + ", useUnlimitedThreads=" + getUseUnlimitedThreads() +
", threadCountSuites=" + getThreadCountSuites() + ", threadCountClasses=" + getThreadCountClasses() +
- ", threadCountMethods=" + getThreadCountMethods();
+ ", threadCountMethods=" + getThreadCountMethods() + ", parallelOptimized=" + isParallelOptimized();
getLog().info( message );
}
@@ -1926,6 +1939,7 @@ private String getConfigChecksum()
checksum.add( getPerCoreThreadCount() );
checksum.add( getUseUnlimitedThreads() );
checksum.add( getParallel() );
+ checksum.add( isParallelOptimized() );
checksum.add( isTrimStackTrace() );
checksum.add( getRemoteRepositories() );
checksum.add( isDisableXmlReport() );
@@ -2740,12 +2754,22 @@ public void setParallel( String parallel )
this.parallel = parallel;
}
+ public boolean isParallelOptimized()
+ {
+ return parallelOptimized;
+ }
+
+ @SuppressWarnings( "UnusedDeclaration" )
+ public void setParallelOptimized( boolean parallelOptimized )
+ {
+ this.parallelOptimized = parallelOptimized;
+ }
+
public int getThreadCountSuites()
{
return threadCountSuites;
}
- @SuppressWarnings( "UnusedDeclaration" )
public void setThreadCountSuites( int threadCountSuites )
{
this.threadCountSuites = threadCountSuites;
@@ -2756,7 +2780,6 @@ public int getThreadCountClasses()
return threadCountClasses;
}
- @SuppressWarnings( "UnusedDeclaration" )
public void setThreadCountClasses( int threadCountClasses )
{
this.threadCountClasses = threadCountClasses;
@@ -2767,7 +2790,6 @@ public int getThreadCountMethods()
return threadCountMethods;
}
- @SuppressWarnings( "UnusedDeclaration" )
public void setThreadCountMethods( int threadCountMethods )
{
this.threadCountMethods = threadCountMethods;
View
2  surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderParameterNames.java
@@ -41,4 +41,6 @@
public static final String PARALLEL_TIMEOUTFORCED_PROP = "paralleltimeoutforced";
+ public static final String PARALLEL_OPTIMIZE_PROP = "paralleloptimization";
+
}
View
23 ...refire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
@@ -28,7 +28,7 @@
/**
* @author Kristian Rosenvold
*/
-class JUnitCoreParameters
+public final class JUnitCoreParameters
{
public static final String PARALLEL_KEY = ProviderParameterNames.PARALLEL_PROP;
@@ -48,6 +48,8 @@
public static final String PARALLEL_TIMEOUTFORCED_KEY = ProviderParameterNames.PARALLEL_TIMEOUTFORCED_PROP;
+ public static final String PARALLEL_OPTIMIZE = ProviderParameterNames.PARALLEL_OPTIMIZE_PROP;
+
private final String parallel;
private final Boolean perCoreThreadCount;
@@ -66,6 +68,8 @@
private final Boolean useUnlimitedThreads;
+ private final boolean parallelOptimization;
+
public JUnitCoreParameters( Properties properties )
{
parallel = properties.getProperty( PARALLEL_KEY, "none" ).toLowerCase();
@@ -79,6 +83,7 @@ public JUnitCoreParameters( Properties properties )
Math.max( Double.valueOf( properties.getProperty( PARALLEL_TIMEOUT_KEY, "0" ) ), 0 );
parallelTestsTimeoutForcedInSeconds =
Math.max( Double.valueOf( properties.getProperty( PARALLEL_TIMEOUTFORCED_KEY, "0" ) ), 0 );
+ parallelOptimization = Boolean.valueOf( properties.getProperty( PARALLEL_OPTIMIZE, "true" ) );
}
private static Collection<String> lowerCase( String... elements )
@@ -96,7 +101,7 @@ private boolean isAllParallel()
return "all".equals( parallel );
}
- public boolean isParallelMethod()
+ public boolean isParallelMethods()
{
return isAllParallel() || lowerCase( "both", "methods", "suitesAndMethods", "classesAndMethods" ).contains(
parallel );
@@ -114,12 +119,12 @@ public boolean isParallelSuites()
}
/**
- * @deprecated Instead use the expression ( {@link #isParallelMethod()} && {@link #isParallelClasses()} ).
+ * @deprecated Instead use the expression ( {@link #isParallelMethods()} && {@link #isParallelClasses()} ).
*/
@Deprecated
public boolean isParallelBoth()
{
- return isParallelMethod() && isParallelClasses();
+ return isParallelMethods() && isParallelClasses();
}
public Boolean isPerCoreThreadCount()
@@ -169,7 +174,12 @@ public boolean isNoThreading()
public boolean isAnyParallelitySelected()
{
- return isParallelSuites() || isParallelClasses() || isParallelMethod();
+ return isParallelSuites() || isParallelClasses() || isParallelMethods();
+ }
+
+ public boolean isParallelOptimization()
+ {
+ return parallelOptimization;
}
@Override
@@ -177,6 +187,7 @@ public String toString()
{
return "parallel='" + parallel + '\'' + ", perCoreThreadCount=" + perCoreThreadCount + ", threadCount="
+ threadCount + ", useUnlimitedThreads=" + useUnlimitedThreads + ", threadCountSuites=" + threadCountSuites
- + ", threadCountClasses=" + threadCountClasses + ", threadCountMethods=" + threadCountMethods;
+ + ", threadCountClasses=" + threadCountClasses + ", threadCountMethods=" + threadCountMethods
+ + ", parallelOptimization=" + parallelOptimization;
}
}
View
2  ...surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -163,7 +163,7 @@ else if ( forkTestSet instanceof Class )
private boolean isParallelMethodsAndTypes()
{
- return jUnitCoreParameters.isParallelMethod() && isParallelTypes();
+ return jUnitCoreParameters.isParallelMethods() && isParallelTypes();
}
private boolean isParallelTypes()
View
6 .../surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
@@ -55,7 +55,7 @@ public static void execute( TestsToRun testsToRun, JUnitCoreParameters jUnitCore
}
else
{
- exeuteLazy( testsToRun, filter, computer, junitCore );
+ executeLazy( testsToRun, filter, computer, junitCore );
}
if ( computer instanceof ParallelComputer )
@@ -85,7 +85,7 @@ private static void executeEager( TestsToRun testsToRun, Filter filter, Computer
createRequestAndRun( filter, computer, junitCore, tests );
}
- private static void exeuteLazy( TestsToRun testsToRun, Filter filter, Computer computer, JUnitCore junitCore )
+ private static void executeLazy( TestsToRun testsToRun, Filter filter, Computer computer, JUnitCore junitCore )
throws TestSetFailedException
{
// in order to support LazyTestsToRun, the iterator must be used
@@ -119,7 +119,7 @@ private static Computer createComputer( JUnitCoreParameters parameters )
{
return parameters.isNoThreading()
? Computer.serial()
- : ParallelComputerFactory.createParallelComputer( parameters );
+ : ParallelComputerFactory.createParallelComputer( parameters, parameters.isParallelOptimization() ? null : null );//todo resolve
}
private static class FilteringRequest
View
126 ...re-junit47/src/main/java/org/apache/maven/surefire/junitcore/ParallelComputerFactory.java
@@ -21,6 +21,7 @@
import org.apache.maven.surefire.junitcore.pc.ParallelComputer;
import org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder;
+import org.apache.maven.surefire.junitcore.pc.RunnerCounter;
import org.apache.maven.surefire.testset.TestSetFailedException;
import java.util.concurrent.TimeUnit;
@@ -59,10 +60,10 @@ static void setDefaultAvailableProcessors()
ParallelComputerFactory.availableProcessors = Runtime.getRuntime().availableProcessors();
}
- static ParallelComputer createParallelComputer( JUnitCoreParameters params )
+ static ParallelComputer createParallelComputer( JUnitCoreParameters params, RunnerCounter counts )
throws TestSetFailedException
{
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, counts );
ParallelComputerBuilder builder = new ParallelComputerBuilder();
if ( params.isParallelSuites() )
@@ -75,7 +76,7 @@ static ParallelComputer createParallelComputer( JUnitCoreParameters params )
resolveClassesConcurrency( builder, concurrency.classes );
}
- if ( params.isParallelMethod() )
+ if ( params.isParallelMethods() )
{
resolveMethodsConcurrency( builder, concurrency.methods );
}
@@ -86,7 +87,7 @@ static ParallelComputer createParallelComputer( JUnitCoreParameters params )
return builder.buildComputer( timeout, timeoutForced, TimeUnit.NANOSECONDS );
}
- static Concurrency resolveConcurrency( JUnitCoreParameters params )
+ static Concurrency resolveConcurrency( JUnitCoreParameters params, RunnerCounter counts )
throws TestSetFailedException
{
if ( !params.isAnyParallelitySelected() )
@@ -108,26 +109,23 @@ static Concurrency resolveConcurrency( JUnitCoreParameters params )
{
return concurrencyForUnlimitedThreads( params );
}
- else
+ else if ( hasThreadCount( params ) )
{
- if ( hasThreadCount( params ) )
+ if ( hasThreadCounts( params ) )
{
- if ( hasThreadCounts( params ) )
- {
- return isLeafUnspecified( params )
- ? concurrencyFromAllThreadCountsButUnspecifiedLeafCount( params )
- : concurrencyFromAllThreadCounts( params );
- }
- else
- {
- return estimateConcurrency( params );
- }
+ return isLeafUnspecified( params )
+ ? concurrencyFromAllThreadCountsButUnspecifiedLeafCount( params, counts )
+ : concurrencyFromAllThreadCounts( params );
}
else
{
- return concurrencyFromThreadCounts( params );
+ return estimateConcurrency( params, counts );
}
}
+ else
+ {
+ return concurrencyFromThreadCounts( params );
+ }
}
private static long secondsToNanos( double seconds )
@@ -194,50 +192,74 @@ private static Concurrency concurrencyForUnlimitedThreads( JUnitCoreParameters p
Concurrency concurrency = new Concurrency();
concurrency.suites = params.isParallelSuites() ? threadCountSuites( params ) : 0;
concurrency.classes = params.isParallelClasses() ? threadCountClasses( params ) : 0;
- concurrency.methods = params.isParallelMethod() ? threadCountMethods( params ) : 0;
+ concurrency.methods = params.isParallelMethods() ? threadCountMethods( params ) : 0;
concurrency.capacity = Integer.MAX_VALUE;
return concurrency;
}
- private static Concurrency estimateConcurrency( JUnitCoreParameters params )
+ private static Concurrency estimateConcurrency( JUnitCoreParameters params, RunnerCounter counts )
{
- Concurrency concurrency = new Concurrency();
- concurrency.suites = params.isParallelSuites() ? params.getThreadCountSuites() : 0;
- concurrency.classes = params.isParallelClasses() ? params.getThreadCountClasses() : 0;
- concurrency.methods = params.isParallelMethod() ? params.getThreadCountMethods() : 0;
- concurrency.capacity = params.getThreadCount();
-
- // estimate parallel thread counts
- double ratio = 1d / countParallelEntities( params );
- int threads = multiplyByCoreCount( params, ratio * concurrency.capacity );
- concurrency.suites = params.isParallelSuites() ? threads : 0;
- concurrency.classes = params.isParallelClasses() ? threads : 0;
- concurrency.methods = params.isParallelMethod() ? threads : 0;
- if ( countParallelEntities( params ) == 1 )
+ final Concurrency concurrency = new Concurrency();
+ final int parallelEntities = countParallelEntities( params );
+ concurrency.capacity = multiplyByCoreCount( params, params.getThreadCount() );
+ if ( parallelEntities == 1 || counts == null || counts.classes == 0 )
{
- concurrency.capacity = 0;
+ // Estimate parallel thread counts.
+ double ratio = 1d / parallelEntities;
+ int threads = multiplyByCoreCount( params, ratio * params.getThreadCount() );
+ concurrency.suites = params.isParallelSuites() ? threads : 0;
+ concurrency.classes = params.isParallelClasses() ? threads : 0;
+ concurrency.methods = params.isParallelMethods() ? threads : 0;
+ if ( parallelEntities == 1 )
+ {
+ concurrency.capacity = 0;
+ }
+ else
+ {
+ adjustLeaf( params, concurrency );
+ }
}
else
{
- concurrency.capacity = multiplyByCoreCount( params, concurrency.capacity );
+ // Try to allocate suites+classes+methods within threadCount,
+ concurrency.suites = params.isParallelSuites() ? multiplyByCoreCount( params, counts.suites ) : 0;
+ concurrency.classes = params.isParallelClasses() ? multiplyByCoreCount( params, counts.classes ) : 0;
+ concurrency.methods =
+ params.isParallelMethods() ? multiplyByCoreCount( params, counts.methods / counts.classes ) : 0;
+ double sum = (double) concurrency.suites + concurrency.classes + concurrency.methods;
+ if ( concurrency.capacity < sum && sum != 0 )
+ {
+ // otherwise allocate them using the weighting factor < 1.
+ double weight = concurrency.capacity / sum;
+ concurrency.suites *= weight;
+ concurrency.classes *= weight;
+ concurrency.methods *= weight;
+ adjustPrecisionInLeaf( params, concurrency );
+ }
adjustLeaf( params, concurrency );
}
return concurrency;
}
- private static Concurrency concurrencyFromAllThreadCountsButUnspecifiedLeafCount( JUnitCoreParameters params )
+ private static Concurrency concurrencyFromAllThreadCountsButUnspecifiedLeafCount( JUnitCoreParameters params,
+ RunnerCounter counts )
{
Concurrency concurrency = new Concurrency();
concurrency.suites = params.isParallelSuites() ? params.getThreadCountSuites() : 0;
+ concurrency.suites = params.isParallelSuites() ? multiplyByCoreCount( params, concurrency.suites ) : 0;
concurrency.classes = params.isParallelClasses() ? params.getThreadCountClasses() : 0;
- concurrency.methods = params.isParallelMethod() ? params.getThreadCountMethods() : 0;
- concurrency.capacity = params.getThreadCount();
+ concurrency.classes = params.isParallelClasses() ? multiplyByCoreCount( params, concurrency.classes ) : 0;
+ concurrency.methods = params.isParallelMethods() ? params.getThreadCountMethods() : 0;
+ concurrency.methods = params.isParallelMethods() ? multiplyByCoreCount( params, concurrency.methods ) : 0;
+ concurrency.capacity = multiplyByCoreCount( params, params.getThreadCount() );
+
+ if ( counts != null )
+ {
+ concurrency.suites = (int) Math.min( Math.min( concurrency.suites, counts.suites ), Integer.MAX_VALUE );
+ concurrency.classes = (int) Math.min( Math.min( concurrency.classes, counts.classes ), Integer.MAX_VALUE );
+ }
setLeafInfinite( params, concurrency );
- concurrency.suites = params.isParallelSuites() ? multiplyByCoreCount( params, concurrency.suites ) : 0;
- concurrency.classes = params.isParallelClasses() ? multiplyByCoreCount( params, concurrency.classes ) : 0;
- concurrency.methods = params.isParallelMethod() ? multiplyByCoreCount( params, concurrency.methods ) : 0;
- concurrency.capacity = multiplyByCoreCount( params, concurrency.capacity );
return concurrency;
}
@@ -247,7 +269,7 @@ private static Concurrency concurrencyFromAllThreadCounts( JUnitCoreParameters p
Concurrency concurrency = new Concurrency();
concurrency.suites = params.isParallelSuites() ? params.getThreadCountSuites() : 0;
concurrency.classes = params.isParallelClasses() ? params.getThreadCountClasses() : 0;
- concurrency.methods = params.isParallelMethod() ? params.getThreadCountMethods() : 0;
+ concurrency.methods = params.isParallelMethods() ? params.getThreadCountMethods() : 0;
concurrency.capacity = params.getThreadCount();
double all = sumThreadCounts( concurrency );
@@ -257,7 +279,7 @@ private static Concurrency concurrencyFromAllThreadCounts( JUnitCoreParameters p
concurrency.classes = params.isParallelClasses() ? multiplyByCoreCount( params, concurrency.capacity * (
concurrency.classes / all ) ) : 0;
- concurrency.methods = params.isParallelMethod() ? multiplyByCoreCount( params, concurrency.capacity * (
+ concurrency.methods = params.isParallelMethods() ? multiplyByCoreCount( params, concurrency.capacity * (
concurrency.methods / all ) ) : 0;
concurrency.capacity = multiplyByCoreCount( params, concurrency.capacity );
@@ -270,7 +292,7 @@ private static Concurrency concurrencyFromThreadCounts( JUnitCoreParameters para
Concurrency concurrency = new Concurrency();
concurrency.suites = params.isParallelSuites() ? threadCountSuites( params ) : 0;
concurrency.classes = params.isParallelClasses() ? threadCountClasses( params ) : 0;
- concurrency.methods = params.isParallelMethod() ? threadCountMethods( params ) : 0;
+ concurrency.methods = params.isParallelMethods() ? threadCountMethods( params ) : 0;
concurrency.capacity = (int) Math.min( sumThreadCounts( concurrency ), Integer.MAX_VALUE );
return concurrency;
}
@@ -288,7 +310,7 @@ private static int countParallelEntities( JUnitCoreParameters params )
count++;
}
- if ( params.isParallelMethod() )
+ if ( params.isParallelMethods() )
{
count++;
}
@@ -297,7 +319,7 @@ private static int countParallelEntities( JUnitCoreParameters params )
private static void adjustPrecisionInLeaf( JUnitCoreParameters params, Concurrency concurrency )
{
- if ( params.isParallelMethod() )
+ if ( params.isParallelMethods() )
{
concurrency.methods = concurrency.capacity - concurrency.suites - concurrency.classes;
}
@@ -309,7 +331,7 @@ else if ( params.isParallelClasses() )
private static void adjustLeaf( JUnitCoreParameters params, Concurrency concurrency )
{
- if ( params.isParallelMethod() )
+ if ( params.isParallelMethods() )
{
concurrency.methods = Integer.MAX_VALUE;
}
@@ -321,7 +343,7 @@ else if ( params.isParallelClasses() )
private static void setLeafInfinite( JUnitCoreParameters params, Concurrency concurrency )
{
- if ( params.isParallelMethod() )
+ if ( params.isParallelMethods() )
{
concurrency.methods = Integer.MAX_VALUE;
}
@@ -339,7 +361,7 @@ private static boolean isLeafUnspecified( JUnitCoreParameters params )
{
int maskOfParallel = params.isParallelSuites() ? 4 : 0;
maskOfParallel |= params.isParallelClasses() ? 2 : 0;
- maskOfParallel |= params.isParallelMethod() ? 1 : 0;
+ maskOfParallel |= params.isParallelMethods() ? 1 : 0;
int maskOfConcurrency = params.getThreadCountSuites() > 0 ? 4 : 0;
maskOfConcurrency |= params.getThreadCountClasses() > 0 ? 2 : 0;
@@ -361,9 +383,9 @@ private static double sumThreadCounts( Concurrency concurrency )
private static boolean hasThreadCounts( JUnitCoreParameters jUnitCoreParameters )
{
- return jUnitCoreParameters.getThreadCountSuites() > 0 ||
- jUnitCoreParameters.getThreadCountClasses() > 0 ||
- jUnitCoreParameters.getThreadCountMethods() > 0;
+ return jUnitCoreParameters.isParallelSuites() && jUnitCoreParameters.getThreadCountSuites() > 0 ||
+ jUnitCoreParameters.isParallelClasses() && jUnitCoreParameters.getThreadCountClasses() > 0 ||
+ jUnitCoreParameters.isParallelMethods() && jUnitCoreParameters.getThreadCountMethods() > 0;
}
private static boolean hasThreadCount( JUnitCoreParameters jUnitCoreParameters )
View
75 ...junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.maven.surefire.junitcore.JUnitCoreParameters;
import org.junit.internal.runners.ErrorReportingRunner;
import org.junit.runner.Description;
import org.junit.runner.Runner;
@@ -33,7 +34,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -64,16 +65,20 @@
* @author Tibor Digana (tibor17)
* @since 2.16
*/
-public class ParallelComputerBuilder
+public final class ParallelComputerBuilder
{
static final int TOTAL_POOL_SIZE_UNDEFINED = 0;
- private final Map<Type, Integer> parallelGroups = new HashMap<Type, Integer>( 3 );
+ private final Map<Type, Integer> parallelGroups = new EnumMap<Type, Integer>( Type.class );
private boolean useSeparatePools;
private int totalPoolSize;
+ private JUnitCoreParameters parameters;
+
+ private boolean optimize;
+
/**
* Calling {@link #useSeparatePools()}.
*/
@@ -85,6 +90,12 @@ public ParallelComputerBuilder()
parallelGroups.put( Type.METHODS, 0 );
}
+ public ParallelComputerBuilder( JUnitCoreParameters parameters )
+ {
+ this();
+ this.parameters = parameters;
+ }
+
public ParallelComputerBuilder useSeparatePools()
{
totalPoolSize = TOTAL_POOL_SIZE_UNDEFINED;
@@ -116,6 +127,12 @@ public ParallelComputerBuilder useOnePool( int totalPoolSize )
return this;
}
+ public ParallelComputerBuilder optimize( boolean optimize )
+ {
+ this.optimize = optimize;
+ return this;
+ }
+
public ParallelComputerBuilder parallelSuites()
{
return parallel( Type.SUITES );
@@ -203,12 +220,14 @@ public ParallelComputer buildComputer( long timeout, long timeoutForced, TimeUni
private final Map<Type, Integer> allGroups;
+ private long nestedClassesChildren;
+
private volatile Scheduler master;
private PC( long timeout, long timeoutForced, TimeUnit timeoutUnit )
{
super( timeout, timeoutForced, timeoutUnit );
- allGroups = new HashMap<Type, Integer>( ParallelComputerBuilder.this.parallelGroups );
+ allGroups = new EnumMap<Type, Integer>( ParallelComputerBuilder.this.parallelGroups );
poolCapacity = ParallelComputerBuilder.this.totalPoolSize;
splitPool = ParallelComputerBuilder.this.useSeparatePools;
}
@@ -226,7 +245,16 @@ public Runner getSuite( RunnerBuilder builder, Class<?>[] cls )
{
super.getSuite( builder, cls );
populateChildrenFromSuites();
- return setSchedulers();
+
+ WrappedRunners suiteSuites = wrapRunners( suites );
+ WrappedRunners suiteClasses = wrapRunners( classes );
+
+ long suitesCount = suites.size();
+ long classesCount = classes.size() + nestedClasses.size();
+ long methodsCount = suiteClasses.embeddedChildrenCount + nestedClassesChildren;
+ tryOptimize( suitesCount, classesCount, methodsCount );
+
+ return setSchedulers( suiteSuites.wrappingSuite, suiteClasses.wrappingSuite );
}
@Override
@@ -252,28 +280,45 @@ protected Runner getRunner( RunnerBuilder builder, Class<?> testClass )
return runner;
}
- private <T extends Runner> ParentRunner wrapRunners( Collection<T> runners )
+ private void tryOptimize( long suites, long classes, long methods )
+ {
+ //todo remove statement, we will rely on single non-default constructor. Final class.
+ final JUnitCoreParameters parameters = ParallelComputerBuilder.this.parameters;
+ if ( ParallelComputerBuilder.this.optimize && parameters != null )
+ {
+ ;//todo
+ }
+ }
+
+ private <T extends Runner> WrappedRunners wrapRunners( Collection<T> runners )
throws InitializationError
{
+ long childrenCounter = 0;
ArrayList<Runner> runs = new ArrayList<Runner>();
for ( T runner : runners )
{
- if ( runner != null && hasChildren( runner ) )
+ if ( runner != null )
{
- runs.add( runner );
+ int children = countChildren( runner );
+ childrenCounter += children;
+ if ( children != 0 )
+ {
+ runs.add( runner );
+ }
}
}
- return runs.isEmpty() ? null : new Suite( null, runs )
+ Suite wrapper = runs.isEmpty() ? null : new Suite( null, runs )
{
};
+ return new WrappedRunners( wrapper, childrenCounter );
}
- private boolean hasChildren( Runner runner )
+ private int countChildren( Runner runner )
{
Description description = runner.getDescription();
Collection children = description == null ? null : description.getChildren();
- return children != null && !children.isEmpty();
+ return children == null ? 0 : children.size();
}
private ExecutorService createPool( int poolSize )
@@ -344,7 +389,7 @@ private int totalPoolSize()
}
}
- private Runner setSchedulers()
+ private Runner setSchedulers( ParentRunner suiteSuites, ParentRunner suiteClasses )
throws InitializationError
{
int parallelSuites = allGroups.get( Type.SUITES );
@@ -354,7 +399,6 @@ private Runner setSchedulers()
ExecutorService commonPool = splitPool || poolSize == 0 ? null : createPool( poolSize );
master = createMaster( commonPool, poolSize );
- ParentRunner suiteSuites = wrapRunners( suites );
if ( suiteSuites != null )
{
// a scheduler for parallel suites
@@ -370,7 +414,6 @@ private Runner setSchedulers()
}
// schedulers for parallel classes
- ParentRunner suiteClasses = wrapRunners( classes );
ArrayList<ParentRunner> allSuites = new ArrayList<ParentRunner>( suites );
allSuites.addAll( nestedSuites );
if ( suiteClasses != null )
@@ -507,7 +550,9 @@ public void apply( Object child )
}
else if ( child instanceof ParentRunner )
{
- nestedClasses.add( (ParentRunner) child );
+ ParentRunner parentRunner = (ParentRunner) child;
+ nestedClasses.add( parentRunner );
+ nestedClassesChildren += parentRunner.getDescription().getChildren().size();
}
}
View
43 .../surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/RunnerCounter.java
@@ -0,0 +1,43 @@
+package org.apache.maven.surefire.junitcore.pc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Counts number of JUnit suites, classes and methods.
+ *
+ * @author tibor17 (Tibor Digana)
+ * @see ParallelComputerBuilder
+ * @since 2.17
+ */
+final public class RunnerCounter//todo needs refactoring, remove public
+{
+ public final long suites;
+
+ public final long classes;
+
+ public final long methods;
+
+ RunnerCounter( long suites, long classes, long methods )
+ {
+ this.suites = suites;
+ this.classes = classes;
+ this.methods = methods;
+ }
+}
View
46 ...surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java
@@ -0,0 +1,46 @@
+package org.apache.maven.surefire.junitcore.pc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.runners.ParentRunner;
+
+/**
+ * We need to wrap runners in a suite and count children of these runners.
+ * <p/>
+ * Old JUnit versions do not cache children after the first call of
+ * {@link org.junit.runners.ParentRunner#getChildren()}.
+ * Due to performance reasons, the children have to be observed just once.
+ *
+ * @author tibor17 (Tibor Digana)
+ * @see ParallelComputerBuilder
+ * @since 2.17
+ */
+final class WrappedRunners
+{
+ final ParentRunner wrappingSuite;
+
+ final long embeddedChildrenCount;
+
+ WrappedRunners( ParentRunner wrappingSuite, long embeddedChildrenCount )
+ {
+ this.wrappingSuite = wrappingSuite;
+ this.embeddedChildrenCount = embeddedChildrenCount;
+ }
+}
View
8 ...re-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
@@ -32,9 +32,9 @@
public void testIsParallelMethod()
throws Exception
{
- assertFalse( getTestSetClasses().isParallelMethod() );
- assertTrue( getTestSetMethods().isParallelMethod() );
- assertTrue( getTestSetBoth().isParallelMethod() );
+ assertFalse( getTestSetClasses().isParallelMethods() );
+ assertTrue( getTestSetMethods().isParallelMethods() );
+ assertTrue( getTestSetBoth().isParallelMethods() );
}
public void testIsParallelClasses()
@@ -148,6 +148,6 @@ private JUnitCoreParameters getTestSetMethods()
private boolean isParallelMethodsAndClasses( JUnitCoreParameters jUnitCoreParameters )
{
- return jUnitCoreParameters.isParallelMethod() && jUnitCoreParameters.isParallelClasses();
+ return jUnitCoreParameters.isParallelMethods() && jUnitCoreParameters.isParallelClasses();
}
}
View
208 ...unit47/src/test/java/org/apache/maven/surefire/junitcore/ParallelComputerFactoryTest.java
@@ -89,7 +89,7 @@ public void unknownParallel()
{
Properties properties = new Properties();
exception.expect( TestSetFailedException.class );
- resolveConcurrency( new JUnitCoreParameters( properties ) );
+ resolveConcurrency( new JUnitCoreParameters( properties ), null );
}
@Test
@@ -99,9 +99,9 @@ public void unknownThreadCountSuites()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "suites" ) );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -111,9 +111,9 @@ public void unknownThreadCountClasses()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "classes" ) );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -123,9 +123,9 @@ public void unknownThreadCountMethods()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "methods" ) );
assertFalse( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -135,9 +135,9 @@ public void unknownThreadCountBoth()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "both" ) );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -147,9 +147,9 @@ public void unknownThreadCountAll()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "all" ) );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -159,9 +159,9 @@ public void unknownThreadCountSuitesAndClasses()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "suitesAndClasses" ) );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -171,9 +171,9 @@ public void unknownThreadCountSuitesAndMethods()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "suitesAndMethods" ) );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Test
@@ -183,9 +183,9 @@ public void unknownThreadCountClassesAndMethods()
JUnitCoreParameters params = new JUnitCoreParameters( parallel( "classesAndMethods" ) );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
exception.expect( TestSetFailedException.class );
- resolveConcurrency( params );
+ resolveConcurrency( params, null );
}
@Theory
@@ -197,10 +197,10 @@ public void useUnlimitedThreadsSuites( int cpu )
properties.setProperty( PARALLEL_KEY, "suites" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( Integer.MAX_VALUE ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -208,10 +208,10 @@ public void useUnlimitedThreadsSuites( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -227,10 +227,10 @@ public void useUnlimitedThreadsClasses( int cpu )
properties.setProperty( PARALLEL_KEY, "classes" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -238,10 +238,10 @@ public void useUnlimitedThreadsClasses( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "5" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 5 * cpu ) );
@@ -257,10 +257,10 @@ public void unlimitedThreadsMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "methods" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -268,10 +268,10 @@ public void unlimitedThreadsMethods( int cpu )
properties.setProperty( THREADCOUNTMETHODS_KEY, "5" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -287,10 +287,10 @@ public void unlimitedThreadsSuitesAndClasses( int cpu )
properties.setProperty( PARALLEL_KEY, "suitesAndClasses" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( Integer.MAX_VALUE ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -299,10 +299,10 @@ public void unlimitedThreadsSuitesAndClasses( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "15" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 15 * cpu ) );
@@ -318,10 +318,10 @@ public void unlimitedThreadsSuitesAndMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "suitesAndMethods" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( Integer.MAX_VALUE ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -330,10 +330,10 @@ public void unlimitedThreadsSuitesAndMethods( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "15" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -349,10 +349,10 @@ public void unlimitedThreadsClassesAndMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "classesAndMethods" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -361,10 +361,10 @@ public void unlimitedThreadsClassesAndMethods( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "5" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "15" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 5 * cpu ) );
@@ -380,10 +380,10 @@ public void unlimitedThreadsAll( int cpu )
properties.setProperty( PARALLEL_KEY, "all" );
properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( Integer.MAX_VALUE ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -393,10 +393,10 @@ public void unlimitedThreadsAll( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "15" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "30" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 15 * cpu ) );
@@ -412,10 +412,10 @@ public void threadCountSuites( int cpu )
properties.setProperty( PARALLEL_KEY, "suites" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 0 ) );
assertThat( concurrency.suites, is( 3 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -431,10 +431,10 @@ public void threadCountClasses( int cpu )
properties.setProperty( PARALLEL_KEY, "classes" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 0 ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 3 * cpu ) );
@@ -450,10 +450,10 @@ public void threadCountMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "methods" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 0 ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -469,10 +469,10 @@ public void threadCountBoth( int cpu )
properties.setProperty( PARALLEL_KEY, "both" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( (int) ( ( 3d / 2 ) * cpu ) ) );
@@ -488,10 +488,10 @@ public void threadCountClassesAndMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "classesAndMethods" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( (int) ( ( 3d / 2 ) * cpu ) ) );
@@ -507,10 +507,10 @@ public void threadCountSuitesAndMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "suitesAndMethods" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
assertThat( concurrency.suites, is( (int) ( ( 3d / 2 ) * cpu ) ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -526,10 +526,10 @@ public void threadCountSuitesAndClasses( int cpu )
properties.setProperty( PARALLEL_KEY, "suitesAndClasses" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
assertThat( concurrency.suites, is( (int) ( ( 3d / 2 ) * cpu ) ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -545,10 +545,10 @@ public void threadCountAll( int cpu )
properties.setProperty( PARALLEL_KEY, "all" );
properties.setProperty( THREADCOUNT_KEY, "3" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
assertThat( concurrency.suites, is( cpu ) );
assertThat( concurrency.classes, is( cpu ) );
@@ -567,10 +567,10 @@ public void everyThreadCountSuitesAndClasses( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "34" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "66" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
int concurrentSuites = (int) ( 0.34d * concurrency.capacity );
assertThat( concurrency.suites, is( concurrentSuites ) );
@@ -590,10 +590,10 @@ public void everyThreadCountSuitesAndMethods( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "34" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "66" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
int concurrentSuites = (int) ( 0.34d * concurrency.capacity );
assertThat( concurrency.suites, is( concurrentSuites ) );
@@ -613,10 +613,10 @@ public void everyThreadCountClassesAndMethods( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "34" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "66" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
int concurrentClasses = (int) ( 0.34d * concurrency.capacity );
@@ -637,10 +637,10 @@ public void everyThreadCountAll( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "34" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "49" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 3 * cpu ) );
int concurrentSuites = (int) ( 0.17d * concurrency.capacity );
int concurrentClasses = (int) ( 0.34d * concurrency.capacity );
@@ -660,10 +660,10 @@ public void reusableThreadCountSuitesAndClasses( int cpu )
properties.setProperty( THREADCOUNT_KEY, "6" );
properties.setProperty( THREADCOUNTSUITES_KEY, "2" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 6 * cpu ) );
assertThat( concurrency.suites, is( 2 * cpu ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -681,10 +681,10 @@ public void reusableThreadCountSuitesAndMethods( int cpu )
properties.setProperty( THREADCOUNT_KEY, "6" );
properties.setProperty( THREADCOUNTSUITES_KEY, "2" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 6 * cpu ) );
assertThat( concurrency.suites, is( 2 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -702,10 +702,10 @@ public void reusableThreadCountClassesAndMethods( int cpu )
properties.setProperty( THREADCOUNT_KEY, "6" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "2" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 6 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 2 * cpu ) );
@@ -724,10 +724,10 @@ public void reusableThreadCountAll( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "2" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "4" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 14 * cpu ) );
assertThat( concurrency.suites, is( 2 * cpu ) );
assertThat( concurrency.classes, is( 4 * cpu ) );
@@ -743,10 +743,10 @@ public void suites( int cpu )
properties.setProperty( PARALLEL_KEY, "suites" );
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 5 * cpu ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -762,10 +762,10 @@ public void classes( int cpu )
properties.setProperty( PARALLEL_KEY, "classes" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "5" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 5 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 5 * cpu ) );
@@ -781,10 +781,10 @@ public void methods( int cpu )
properties.setProperty( PARALLEL_KEY, "methods" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "5" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 5 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -802,10 +802,10 @@ public void suitesAndClasses( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "15" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 20 * cpu ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 15 * cpu ) );
@@ -817,10 +817,10 @@ public void suitesAndClasses( int cpu )
properties.setProperty( PARALLEL_KEY, "suitesAndClasses" );
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertFalse( params.isParallelMethod() );
+ assertFalse( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( Integer.MAX_VALUE ) );
@@ -838,10 +838,10 @@ public void suitesAndMethods( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "15" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 20 * cpu ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -853,10 +853,10 @@ public void suitesAndMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "suitesAndMethods" );
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertFalse( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 0 ) );
@@ -874,10 +874,10 @@ public void classesAndMethods( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "5" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "15" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 20 * cpu ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 5 * cpu ) );
@@ -889,10 +889,10 @@ public void classesAndMethods( int cpu )
properties.setProperty( PARALLEL_KEY, "classesAndMethods" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "5" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertFalse( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 0 ) );
assertThat( concurrency.classes, is( 5 * cpu ) );
@@ -911,10 +911,10 @@ public void all( int cpu )
properties.setProperty( THREADCOUNTCLASSES_KEY, "15" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "30" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- Concurrency concurrency = resolveConcurrency( params );
+ Concurrency concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( 50 * cpu ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 15 * cpu ) );
@@ -927,10 +927,10 @@ public void all( int cpu )
properties.setProperty( THREADCOUNTSUITES_KEY, "5" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "15" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( 5 * cpu ) );
assertThat( concurrency.classes, is( 15 * cpu ) );
@@ -940,10 +940,10 @@ public void all( int cpu )
properties.setProperty( PARALLEL_KEY, "all" );
properties.setProperty( THREADCOUNTCLASSES_KEY, "15" );
params = new JUnitCoreParameters( properties );
- concurrency = resolveConcurrency( params );
+ concurrency = resolveConcurrency( params, null );
assertTrue( params.isParallelSuites() );
assertTrue( params.isParallelClasses() );
- assertTrue( params.isParallelMethod() );
+ assertTrue( params.isParallelMethods() );
assertThat( concurrency.capacity, is( Integer.MAX_VALUE ) );
assertThat( concurrency.suites, is( Integer.MAX_VALUE ) );
assertThat( concurrency.classes, is( 15 * cpu ) );
@@ -958,7 +958,7 @@ public void withoutShutdown()
properties.setProperty( PARALLEL_KEY, "methods" );
properties.setProperty( THREADCOUNTMETHODS_KEY, "2" );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- ParallelComputer pc = createParallelComputer( params );
+ ParallelComputer pc = createParallelComputer( params, null );
Result result = new JUnitCore().run( pc, TestClass.class );
long timeSpent = runtime.stop();
@@ -982,7 +982,7 @@ public void shutdown()
properties.setProperty( THREADCOUNTMETHODS_KEY, "2" );
properties.setProperty( PARALLEL_TIMEOUT_KEY, Double.toString( 2.5d ) );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- ParallelComputer pc = createParallelComputer( params );
+ ParallelComputer pc = createParallelComputer( params, null );
new JUnitCore().run( pc, TestClass.class );
long timeSpent = runtime.stop();
@@ -1004,7 +1004,7 @@ public void forcedShutdown()
properties.setProperty( THREADCOUNTMETHODS_KEY, "2" );
properties.setProperty( PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 2.5d ) );
JUnitCoreParameters params = new JUnitCoreParameters( properties );
- ParallelComputer pc = createParallelComputer( params );
+ ParallelComputer pc = createParallelComputer( params, null );
new JUnitCore().run( pc, TestClass.class );
long timeSpent = runtime.stop();
View
2  ...s/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
@@ -162,7 +162,7 @@ public void testFinished( Description description )
throws Exception
{
throw new RuntimeException(
- "This Exception will cause Surefire to receive a internal JUnit Description and fail" );
+ "This Exception will cause Surefire to receive an internal JUnit Description and fail." );
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.