jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven Surefire
  • SUREFIRE-799

Allow test parallelisation when forkMode=always

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.10
  • Fix Version/s: 2.12
  • Component/s: process forking
  • Labels:
    None
  • Environment:
    all
  • Complexity:
    Intermediate

Description

Surefire already allows:

  • forking
  • parallelization within a JVM

Mixing both features would mean forking multiple JVM instead of only one.
It would allow to parallelize tests that need to be executed in a separate JVM (i.e.: with forkMode=always). Usually these tests take longer than the simple ones. In our case, 40% of the tests are executed in 4 minutes, the other 60% need two hours. So it's obviously more interesting to parallelize the former, but these ones need to fork.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    surefire_799_212_trunk.patch
    08/Dec/11 3:16 PM
    8 kB
    nkeywal
  2. Text File
    surefire_799.v2.patch
    16/Dec/11 10:50 AM
    15 kB
    nkeywal

Issue Links

is related to

New Feature - A new feature of the product, which has yet to be developed. SUREFIRE-751 Support parallel/fork mode similar to http://maven-junit-plugin.kenai.com/

  • Major - Major loss of function.
  • Open - The issue is open and ready for the assignee to start work on it.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Kristian Rosenvold added a comment - 26/Nov/11 11:21 AM

Both parallel forks, balanced parallel forks and reusable forks are part of the long term plan (which is written on the backside of a napkin I have lying around here somewhere - if I haven't lost it). Unfortunately I will not be implementing this until the overall complexity of the surefire forking logic is reduced to a minimum. This has been an ongoing process since at least version 2.8 and will probably continue for a few more versions after 2.11. If anyone wants to take a shot at this, go ahead. Just be warned the code is still changing quite alot in this section.

Show
Kristian Rosenvold added a comment - 26/Nov/11 11:21 AM Both parallel forks, balanced parallel forks and reusable forks are part of the long term plan (which is written on the backside of a napkin I have lying around here somewhere - if I haven't lost it). Unfortunately I will not be implementing this until the overall complexity of the surefire forking logic is reduced to a minimum. This has been an ongoing process since at least version 2.8 and will probably continue for a few more versions after 2.11. If anyone wants to take a shot at this, go ahead. Just be warned the code is still changing quite alot in this section.
Hide
Permalink
Kristian Rosenvold added a comment - 26/Nov/11 3:28 PM

This request half-overlaps this issue.

Show
Kristian Rosenvold added a comment - 26/Nov/11 3:28 PM This request half-overlaps this issue.
Hide
Permalink
nkeywal added a comment - 08/Dec/11 3:22 PM

I've been to implement it, it seems to fit well with surefire architecture (changes are in one file only).
I used to system property to configure the number of parallel process, but I think this can be changed easily.

Show
nkeywal added a comment - 08/Dec/11 3:22 PM I've been to implement it, it seems to fit well with surefire architecture (changes are in one file only). I used to system property to configure the number of parallel process, but I think this can be changed easily.
Hide
Permalink
Kristian Rosenvold added a comment - 11/Dec/11 11:28 AM

This is a cool patch It needs a few minor modifications; I think the regular "threadCount" parameter should be used, and the forkMode should be "perthread".

It also needs an integration test, you should be able to modify (or make a new project based on)
surefire-integration-tests/src/test/resources/runorder-parallel and a test implementation in XmlReporterRunTimeIT.

(I think you can just modify the existing to accept forkMode as a -D parameter instead of hard-coding)

I will be releasing 2.11.1 soon, but I'll schedule this patch for 2.12 if you fix this stuff.

Show
Kristian Rosenvold added a comment - 11/Dec/11 11:28 AM This is a cool patch It needs a few minor modifications; I think the regular "threadCount" parameter should be used, and the forkMode should be "perthread". It also needs an integration test, you should be able to modify (or make a new project based on) surefire-integration-tests/src/test/resources/runorder-parallel and a test implementation in XmlReporterRunTimeIT. (I think you can just modify the existing to accept forkMode as a -D parameter instead of hard-coding) I will be releasing 2.11.1 soon, but I'll schedule this patch for 2.12 if you fix this stuff.
Hide
Permalink
nkeywal added a comment - 12/Dec/11 3:40 AM

Ok, will do. Do you have something in mind for 2.12 release date?

Show
nkeywal added a comment - 12/Dec/11 3:40 AM Ok, will do. Do you have something in mind for 2.12 release date?
Hide
Permalink
Kristian Rosenvold added a comment - 12/Dec/11 5:16 AM

"Early next year"

Show
Kristian Rosenvold added a comment - 12/Dec/11 5:16 AM "Early next year"
Hide
Permalink
nkeywal added a comment - 16/Dec/11 10:52 AM

v2 includes:

  • integration test with surefire-integration-tests/src/test/resources/runorder-parallel
  • forkMode is "perThread"
  • use threadCount
Show
nkeywal added a comment - 16/Dec/11 10:52 AM v2 includes:
  • integration test with surefire-integration-tests/src/test/resources/runorder-parallel
  • forkMode is "perThread"
  • use threadCount
Hide
Permalink
Kristian Rosenvold added a comment - 22/Dec/11 3:57 PM

Fixed in r1222474, thanks for the patch!

I made some adjustments to the patch, and you may want to look over those.

Show
Kristian Rosenvold added a comment - 22/Dec/11 3:57 PM Fixed in r1222474, thanks for the patch! I made some adjustments to the patch, and you may want to look over those.
Hide
Permalink
Alexey Yudichev added a comment - 24/Jan/12 12:04 PM

This is not yet in https://repository.apache.org/content/groups/snapshots/org/apache/maven/plugins/maven-surefire-plugin/2.12-SNAPSHOT/maven-surefire-plugin-2.12-20120119.191905-28.jar by the looks of it as I'm getting:

Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12-SNAPSHOT:test failed: Fork mode perThread is not a legal value

Any chance you can deploy a snapshot with this patch in?

Show
Alexey Yudichev added a comment - 24/Jan/12 12:04 PM This is not yet in https://repository.apache.org/content/groups/snapshots/org/apache/maven/plugins/maven-surefire-plugin/2.12-SNAPSHOT/maven-surefire-plugin-2.12-20120119.191905-28.jar by the looks of it as I'm getting: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12-SNAPSHOT:test failed: Fork mode perThread is not a legal value Any chance you can deploy a snapshot with this patch in?
Hide
Permalink
nkeywal added a comment - 24/Jan/12 12:11 PM

Kristian renamed it to "perthread" in the trunk. It works well for us.

Show
nkeywal added a comment - 24/Jan/12 12:11 PM Kristian renamed it to "perthread" in the trunk. It works well for us.
Hide
Permalink
Alexey Yudichev added a comment - 25/Jan/12 4:30 AM - edited

Thanks nkeywal, one question if you don't mind. I want surefire to fork X JVMs and then spread the tests across them evenly without re-launching new JVM for every test. Looks like this:

<configuration>
    <forkMode>perthread</forkMode>
    <threadCount>2</threadCount>
</configuration>

runs at most 2 JVMs but still launches new JVM instance for every test. Is it possible to reuse JVMs? Our integration tests are heavy to initialise and their initialisation is statically defined, so to avoid re-initialisation there should be JVM reuse.

Show
Alexey Yudichev added a comment - 25/Jan/12 4:30 AM - edited Thanks nkeywal, one question if you don't mind. I want surefire to fork X JVMs and then spread the tests across them evenly without re-launching new JVM for every test. Looks like this:
<configuration>
    <forkMode>perthread</forkMode>
    <threadCount>2</threadCount>
</configuration>
runs at most 2 JVMs but still launches new JVM instance for every test. Is it possible to reuse JVMs? Our integration tests are heavy to initialise and their initialisation is statically defined, so to avoid re-initialisation there should be JVM reuse.
Hide
Permalink
nkeywal added a comment - 25/Jan/12 5:02 AM

Yes, I confirm it will relaunch a new jvm for each test. Kristian's comment above says "reusable forks" are in the roadmap. It's not something we need, so I didn't look at it when I implemented the patch. BTW you can parallelize the tests with forkMode=once, and in this case the jvm is not recreated.

Show
nkeywal added a comment - 25/Jan/12 5:02 AM Yes, I confirm it will relaunch a new jvm for each test. Kristian's comment above says "reusable forks" are in the roadmap. It's not something we need, so I didn't look at it when I implemented the patch. BTW you can parallelize the tests with forkMode=once, and in this case the jvm is not recreated.
Hide
Permalink
Alexey Yudichev added a comment - 25/Jan/12 5:45 AM

Yes, but forkMode=once will only parallelise tests within same JVM using multiple threads, which will not work for us as our tests are inherently not thread safe. We need "1 thread multiple JVMs" type of parallelisation with JVM reuse. I'll think of some workaround in this case.

Show
Alexey Yudichev added a comment - 25/Jan/12 5:45 AM Yes, but forkMode=once will only parallelise tests within same JVM using multiple threads, which will not work for us as our tests are inherently not thread safe. We need "1 thread multiple JVMs" type of parallelisation with JVM reuse. I'll think of some workaround in this case.
Hide
Permalink
Kristian Rosenvold added a comment - 25/Jan/12 6:15 AM

Re-using VM's is a planned feature, but someone has to implement it

Show
Kristian Rosenvold added a comment - 25/Jan/12 6:15 AM Re-using VM's is a planned feature, but someone has to implement it
Hide
Permalink
Martin Burger added a comment - 10/Feb/12 7:36 AM

JUnit test parallelization with forkMode=always is supposed to work now?

On my machine (I use Maven Surefire 2.12), with 'always' tests are not run in parallel (although log messages on the console suggest parallel test execution). When I use 'perthread' as forkMode instead, tests are actually run in parallel.

Show
Martin Burger added a comment - 10/Feb/12 7:36 AM JUnit test parallelization with forkMode=always is supposed to work now? On my machine (I use Maven Surefire 2.12), with 'always' tests are not run in parallel (although log messages on the console suggest parallel test execution). When I use 'perthread' as forkMode instead, tests are actually run in parallel.
Hide
Permalink
Kristian Rosenvold added a comment - 10/Feb/12 7:46 AM

always is linear, single threaded as before.

Show
Kristian Rosenvold added a comment - 10/Feb/12 7:46 AM always is linear, single threaded as before.

People

  • Assignee:
    Kristian Rosenvold
    Reporter:
    nkeywal
Vote (0)
Watch (1)

Dates

  • Created:
    26/Nov/11 8:59 AM
    Updated:
    10/Feb/12 7:46 AM
    Resolved:
    22/Dec/11 3:57 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.