Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1301

baseDir system-property gets overridden by other builder threads if forking is disabled

    Details

    • Type: Documentation
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.19.1
    • Fix Version/s: 2.20
    • Component/s: Maven Surefire Plugin
    • Labels:
      None

      Description

      When running tests in a multi-module project with multiple builder threads and surefire's forkCount set to 0, the threads override each other when setting the baseDir system-property.

      Running the sample project results in the below output with the given commands.
      (Note: First number is the expected path. e.g. 11 => wrapper1; module1)

      Correct

      mvn clean install | grep basedir
      01 basedir=<path>/maven-surefire-example/module1
      02 basedir=<path>/maven-surefire-example/module2
      03 basedir=<path>/maven-surefire-example/module3
      11 basedir=<path>/maven-surefire-example/wrapper1/module1
      12 basedir=<path>/maven-surefire-example/wrapper1/module2
      13 basedir=<path>/maven-surefire-example/wrapper1/module3
      21 basedir=<path>/maven-surefire-example/wrapper2/module1
      22 basedir=<path>/maven-surefire-example/wrapper2/module2
      23 basedir=<path>/maven-surefire-example/wrapper2/module3
      31 basedir=<path>/maven-surefire-example/wrapper3/module1
      32 basedir=<path>/maven-surefire-example/wrapper3/module2
      33 basedir=<path>/maven-surefire-example/wrapper3/module3
      

      Incorrect

      mvn clean install -T 3 | grep basedir
      02 basedir=<path>/maven-surefire-example/module2
      01 basedir=<path>/maven-surefire-example/module2
      03 basedir=<path>/maven-surefire-example/module2
      13 basedir=<path>/maven-surefire-example/wrapper1/module1
      23 basedir=<path>/maven-surefire-example/wrapper1/module1
      11 basedir=<path>/maven-surefire-example/wrapper1/module1
      12 basedir=<path>/maven-surefire-example/wrapper2/module2
      21 basedir=<path>/maven-surefire-example/wrapper2/module2
      22 basedir=<path>/maven-surefire-example/wrapper2/module2
      32 basedir=<path>/maven-surefire-example/wrapper3/module3
      31 basedir=<path>/maven-surefire-example/wrapper3/module3
      33 basedir=<path>/maven-surefire-example/wrapper3/module3
      

      This is correct behaviour from a technical point of view as the system-properties are shared between the threads and the surefire-executions (due to the disabled forking), therefore I opened this issue mainly for documentation purpose.

      This behaviour does not affect our current project anymore due to the removal of the forkCount setting, yet I think that this behaviour should be documented.

        Issue Links

          Activity

          Hide
          tibor17 Tibor Digana added a comment -

          Andreas Gudian
          Hi Andreas, do you have any idea what is the root cause in this issue?

          Show
          tibor17 Tibor Digana added a comment - Andreas Gudian Hi Andreas, do you have any idea what is the root cause in this issue?
          Hide
          agudian Andreas Gudian added a comment -

          @Tibor Digana, a missing note in the docs?

          Obviously we can't provide the right baseDir property in a parallel build when not forking, as Richard described correctly already.
          A good place for adding a note on that could be the forking/parallel page in the documentation.

          Or were you looking for a way to somehow solve this?

          Show
          agudian Andreas Gudian added a comment - @ Tibor Digana , a missing note in the docs? Obviously we can't provide the right baseDir property in a parallel build when not forking, as Richard described correctly already. A good place for adding a note on that could be the forking/parallel page in the documentation. Or were you looking for a way to somehow solve this?
          Hide
          tibor17 Tibor Digana added a comment -

          Richard Raumberger
          You can open a pull request in GitHub and update project documentation:
          https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
          and then I will release the documentation in Version 2.19.2.

          Show
          tibor17 Tibor Digana added a comment - Richard Raumberger You can open a pull request in GitHub and update project documentation: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm and then I will release the documentation in Version 2.19.2.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user rraumberger opened a pull request:

          https://github.com/apache/maven-surefire/pull/131

          SUREFIRE-1301 add note for changing system properties when running parallel builds with disabled forking

          Resolves SUREFIRE-1301(https://issues.apache.org/jira/browse/SUREFIRE-1301).

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/rraumberger/maven-surefire master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/maven-surefire/pull/131.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #131


          commit 059bd029ccfc56a0d9370f9862d4feed5fc07448
          Author: Richard Raumberger <richard.raumberger@gmail.com>
          Date: 2016-11-12T21:06:23Z

          SUREFIRE-1301 add note for changing baseDir property


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user rraumberger opened a pull request: https://github.com/apache/maven-surefire/pull/131 SUREFIRE-1301 add note for changing system properties when running parallel builds with disabled forking Resolves SUREFIRE-1301 ( https://issues.apache.org/jira/browse/SUREFIRE-1301 ). You can merge this pull request into a Git repository by running: $ git pull https://github.com/rraumberger/maven-surefire master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven-surefire/pull/131.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #131 commit 059bd029ccfc56a0d9370f9862d4feed5fc07448 Author: Richard Raumberger <richard.raumberger@gmail.com> Date: 2016-11-12T21:06:23Z SUREFIRE-1301 add note for changing baseDir property
          Hide
          tibor17 Tibor Digana added a comment -

          Richard Raumberger
          Thx for the PR.
          Have you tried to pass a value of $

          {project.basedir}

          in <systemPropertyVariables> ?
          The key of sys prop is up to you.

          Show
          tibor17 Tibor Digana added a comment - Richard Raumberger Thx for the PR. Have you tried to pass a value of $ {project.basedir} in <systemPropertyVariables> ? The key of sys prop is up to you.
          Hide
          rraumberger Richard Raumberger added a comment - - edited

          Tibor Digana
          Yeah, I tried that.
          Lead to the same result.

          I noticed something different, though...
          When running mvn clean test -T 3 via CLI, the tests run and the described situation occurs.
          When I ran the same command with IntelliJ's bundled Maven it fails with parallel maven execution is not compatible with surefire forkCount 0, which actually prevents this situation from occurring.

          It seems like this is connected to the used maven version.
          Standalone-installation: Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
          IntelliJ-Bundled: Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100)

          It seems like this condition is not working properly with 3.3.9.

          Show
          rraumberger Richard Raumberger added a comment - - edited Tibor Digana Yeah, I tried that. Lead to the same result. I noticed something different, though... When running mvn clean test -T 3 via CLI, the tests run and the described situation occurs. When I ran the same command with IntelliJ's bundled Maven it fails with parallel maven execution is not compatible with surefire forkCount 0 , which actually prevents this situation from occurring. It seems like this is connected to the used maven version. Standalone-installation: Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00) IntelliJ-Bundled: Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100) It seems like this condition is not working properly with 3.3.9.
          Hide
          tibor17 Tibor Digana added a comment -

          Richard Raumberger
          Good job!
          I will merge your PR but you can report an issue in https://issues.apache.org/jira/browse/MNG including a project ZIP able to reproduce it.

          Show
          tibor17 Tibor Digana added a comment - Richard Raumberger Good job! I will merge your PR but you can report an issue in https://issues.apache.org/jira/browse/MNG including a project ZIP able to reproduce it.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/maven-surefire/pull/131

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/maven-surefire/pull/131
          Show
          tibor17 Tibor Digana added a comment - https://git-wip-us.apache.org/repos/asf?p=maven-surefire.git;a=commitdiff;h=059bd029ccfc56a0d9370f9862d4feed5fc07448
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-surefire #1644 (See https://builds.apache.org/job/maven-surefire/1644/)
          SUREFIRE-1301 add note for changing baseDir property (richard.raumberger: rev 059bd029ccfc56a0d9370f9862d4feed5fc07448)

          • (edit) maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-surefire #1644 (See https://builds.apache.org/job/maven-surefire/1644/ ) SUREFIRE-1301 add note for changing baseDir property (richard.raumberger: rev 059bd029ccfc56a0d9370f9862d4feed5fc07448) (edit) maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
          Show
          rraumberger Richard Raumberger added a comment - Tibor Digana No ZIP needed. https://issues.apache.org/jira/browse/MNG-6117

            People

            • Assignee:
              tibor17 Tibor Digana
              Reporter:
              rraumberger Richard Raumberger
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development