maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henryk Sarat (JIRA)" <j...@codehaus.org>
Subject [jira] (SUREFIRE-1059) Running tests in parallel seems to ignore threadCount
Date Wed, 05 Feb 2014 23:56:03 GMT
Henryk Sarat created SUREFIRE-1059:
--------------------------------------

             Summary: Running tests in parallel seems to ignore threadCount
                 Key: SUREFIRE-1059
                 URL: https://jira.codehaus.org/browse/SUREFIRE-1059
             Project: Maven Surefire
          Issue Type: Bug
            Reporter: Henryk Sarat
            Priority: Blocker


I'm trying to run 6 tests in parallel in 2 threads. However, it seems like as man threads
launch at one time instead of just 2. My proof here is via the Thread Id that I print out
and because the test finishes in around 18seconds. I expect the test to finish in about 38
seconds. I got to this number because I have 6 methods that sleep for 10 seconds each. If
2 threads run in parallel, then the total run time should be 6methods/2threads = 30 seconds
(there there is about 8 seconds of build time of everything else). Am I doing something wrong?
This is really blocking me from proceeding because I can't control my resources correctly
and I'm sure other people might be feeling this pain.

POM File:

{code}
   <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <parallel>methods</parallel>

                    <threadCount>2</threadCount>
                    <forkCount>2</forkCount>

                    <systemPropertyVariables>
                        <propertyName>propertyValue</propertyName>
                        <buildDirectory>${project.build.directory}</buildDirectory>
                        <build.id>${build.id}</build.id>
                        <environment>${environment}</environment>
                        <skipEnrollment>${skipEnrollment}</skipEnrollment>
                        <sendMail>${sendMail}</sendMail>
                        <jiraCC>${jiraCC}</jiraCC>
                        <headless>${headless}</headless>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
{code}

JUnit:

{code}
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.11</version>
        </dependency>
{code}

Java test class:

{code}
public class FourthTest {
    @Test
    public void testOne() throws InterruptedException, ExecutionException, IOException {
        for(int i =0;i<10;i++) {
            Thread.sleep(1000);
            System.out.println("one --- " + Thread.currentThread().getId());

        }
    }

    @Test
    public void testTwo() throws InterruptedException, ExecutionException, IOException {
        for(int i =0;i<10;i++) {
            Thread.sleep(1000);
            System.out.println("two --- " + Thread.currentThread().getId());
        }
    }

    @Test
    public void testThree() throws InterruptedException, ExecutionException, IOException {
        for(int i =0;i<10;i++) {
            Thread.sleep(1000);
            System.out.println("three --- " + Thread.currentThread().getId());
        }
    }

    @Test
    public void testFour() throws InterruptedException, ExecutionException, IOException {
        for(int i =0;i<10;i++) {
            Thread.sleep(1000);
            System.out.println("four --- " + Thread.currentThread().getId());
        }
    }


    @Test
    public void testFive() throws InterruptedException, ExecutionException, IOException {
        for(int i =0;i<10;i++) {
            Thread.sleep(1000);
            System.out.println("five --- " + Thread.currentThread().getId());
        }
    }

                                                                           volatile static
boolean a = false;
    @Test
    public void testSix() throws InterruptedException, ExecutionException, IOException {
        for(int i =0;i<10;i++) {
            Thread.sleep(1000);
            System.out.println("six --- " + Thread.currentThread().getId());
            //if (!a){(new Exception()).printStackTrace(System.out);a=true;}
    }
    }
}
{code}

command line: 
{code}
mvn clean install test -Dtest=FourthTest -T 2
{code}

Output
{code}
[INFO] Scanning for projects...
[INFO] Building with 2 threads
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mobile 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ mobile ---
[INFO] Deleting 
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ mobile ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform
dependent!
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build
is platform dependent!
[INFO] skip non existing resourceDirectory 
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mobile ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform
dependent!
[INFO] Compiling 51 source files to 
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ mobile ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build
is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ mobile ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform
dependent!
[INFO] Compiling 23 source files to 
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ mobile ---
[INFO] Surefire report directory: 
[INFO] parallel='methods', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false,
threadCountSuites=0, threadCountClasses=0, threadCountMethods=0

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.blah.ios.FourthTest
three --- 11
three --- 11
three --- 11
three --- 11
three --- 11
three --- 11
three --- 11
three --- 11
three --- 11
three --- 11
six --- 9
six --- 9
six --- 9
six --- 9
six --- 9
six --- 9
six --- 9
six --- 9
six --- 9
six --- 9
four --- 13
four --- 13
four --- 13
four --- 13
four --- 13
four --- 13
four --- 13
four --- 13
four --- 13
four --- 13
one --- 8
one --- 8
one --- 8
one --- 8
one --- 8
one --- 8
one --- 8
one --- 8
one --- 8
one --- 8
five --- 12
five --- 12
five --- 12
five --- 12
five --- 12
five --- 12
five --- 12
five --- 12
five --- 12
five --- 12
two --- 10
two --- 10
two --- 10
two --- 10
two --- 10
two --- 10
two --- 10
two --- 10
two --- 10
two --- 10
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 60.101 sec - in com.blah.ios.FourthTest

Results :

Tests run: 6, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ mobile ---
[INFO] Building jar: /Users/XX/Documents/XXXXXX/XXXX/XXX/target/mobile-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ mobile ---
[INFO] Installing /Users/XX/Documents/bboxprojects/XXXXXXX/XXXX/target/mobile-1.0-SNAPSHOT.jar
to /Users/XXXXXX/.m2/repository/com/XXXXX/automation/XXXXX/1.0-SNAPSHOT/mobile-1.0-SNAPSHOT.jar
[INFO] Installing /Users/XXXXXX/Documents/XXXXX/XXXX/mobile/pom.xml to /Users/XXXXX/.m2/repository/com/XXXXX/XXXX/mobile/1.0-SNAPSHOT/mobile-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ mobile ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform
dependent!
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build
is platform dependent!
[INFO] skip non existing resourceDirectory /Users/XXXXXX/Documents/XXXXX/XXXX/XXXXX/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mobile ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform
dependent!
[INFO] Compiling 1 source file to /Users/XXXXX/Documents/XXXX/XXXX/XXX/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ mobile ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build
is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ mobile ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ mobile ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.363s (Wall Clock)
[INFO] Finished at: Wed Feb 05 15:44:25 PST 2014
[INFO] Final Memory: 29M/122M
[INFO] ------------------------------------------------------------------------
{code}



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Mime
View raw message