You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Fabio Kenji Kume (JIRA)" <ji...@codehaus.org> on 2013/12/23 20:30:45 UTC

[jira] (SUREFIRE-1048) Surefire does not use the total amount of threads specified by threadCount

Fabio Kenji Kume created SUREFIRE-1048:
------------------------------------------

             Summary: Surefire does not use the total amount of threads specified by threadCount
                 Key: SUREFIRE-1048
                 URL: https://jira.codehaus.org/browse/SUREFIRE-1048
             Project: Maven Surefire
          Issue Type: Bug
          Components: Junit 4.7+ (parallel) support
    Affects Versions: 2.16
            Reporter: Fabio Kenji Kume
         Attachments: surefire-parallel-test.zip

Hello,

We've been using Surefire Plugin's parallel settings since 2.16 in order to run our selenium-based integration tests.
The way we run it is by using the following parameters:

parallel='all', perCoreThreadCount=false, threadCount=20, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0

We are running a Junit Suite using Categories. What we've noticed, though, is that even if we specify the total thread count as 20, we never see that number of tests being run in parallel. We could check that fact by viewing our selenium-grid's console, where we would see that the number of selenium grid nodes that were being used for tests were never the full 20.

We've played around with different threadCount numbers and got the following results:

threadCount / slots being used at selenium-grid

3  / 1
4  / 2
5  / 3
6  / 3
7  / 4
8  / 5
9  / 5
10 / 6
11 / 7
13 / 8

It seems the number of threads being used is never the total of threads specified. 

I've created another project so I could test this around, which is attached to this issue.
In it, I've created a Junit rule that will print the whenever a test starts, and a Test Suite using categories from another testcase. 

When I run it using threadCount = 10, I get the following:

mvn clean test -Dtest=**/ExpSuite.java

reports
[INFO] parallel='all', perCoreThreadCount=false, threadCount=10, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running second.ExpTest
[Mon Dec 23 16:11:15 BRST 2013] START test_1
[Mon Dec 23 16:11:15 BRST 2013] START test_7
[Mon Dec 23 16:11:15 BRST 2013] START test_6
[Mon Dec 23 16:11:15 BRST 2013] START test_3
[Mon Dec 23 16:11:15 BRST 2013] START test_5
[Mon Dec 23 16:11:15 BRST 2013] START test_10
[Mon Dec 23 16:11:15 BRST 2013] START test_4
[Mon Dec 23 16:11:15 BRST 2013] START test_2
[Mon Dec 23 16:15:30 BRST 2013] START test_8
[Mon Dec 23 16:15:32 BRST 2013] START test_9

Seems that last two tests didn't get to run at the same time as the others, since they have very different date values. However, if I run them specifying the exact number of threadCountSuites, threadCountClasses and threadCountMethods, the tests run all in parallel:

[INFO] parallel='all', perCoreThreadCount=false, threadCount=0, useUnlimitedThreads=false, threadCountSuites=10, threadCountClasses=10, threadCountMethods=10

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running second.ExpTest
[Mon Dec 23 15:50:51 BRST 2013] START test_2
[Mon Dec 23 15:50:51 BRST 2013] START test_7
[Mon Dec 23 15:50:51 BRST 2013] START test_8
[Mon Dec 23 15:50:51 BRST 2013] START test_9
[Mon Dec 23 15:50:51 BRST 2013] START test_10
[Mon Dec 23 15:50:51 BRST 2013] START test_1
[Mon Dec 23 15:50:51 BRST 2013] START test_3
[Mon Dec 23 15:50:51 BRST 2013] START test_4
[Mon Dec 23 15:50:51 BRST 2013] START test_6
[Mon Dec 23 15:50:51 BRST 2013] START test_5
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3,320.712 sec - in second.ExpTest

If I try running only the test class (ExpTest), I get the following:

mvn clean test -Dtest=**/ExpTest.java


[INFO] parallel='all', perCoreThreadCount=false, threadCount=10, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running second.ExpTest
[Mon Dec 23 17:07:46 BRST 2013] START test_3
[Mon Dec 23 17:07:46 BRST 2013] START test_8
[Mon Dec 23 17:07:46 BRST 2013] START test_1
[Mon Dec 23 17:07:46 BRST 2013] START test_2
[Mon Dec 23 17:07:46 BRST 2013] START test_7
[Mon Dec 23 17:07:46 BRST 2013] START test_6
[Mon Dec 23 17:07:46 BRST 2013] START test_10
[Mon Dec 23 17:07:46 BRST 2013] START test_5
[Mon Dec 23 17:07:46 BRST 2013] START test_4
[Mon Dec 23 17:12:37 BRST 2013] START test_9
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2,710.144 sec - in second.ExpTest

We still didn't get the 10 threads to run.

I've looked around the source code and it seems to be related to how surefire calculates the ratio of threads that should be allocated to run methods, suites and classes.

Could you help me with this? 

Thank you,
Fabio Kenji

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira