Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50422

RestartableJenkinsRule gets a new rootDir for each step when using @LocalData


    • Similar Issues:



      When using RestartJenkinsRule, one expects to keep using the same JENKINS_HOME.
      This is the case normally, but not when using both RestartableJenkinsRule and @LocalData.

      Expected behaviour

      Jenkins.getRootDir() should stay the same during the execution of a given test, not be a new one for each step.

      How to reproduce

      I have created a test project to help understand/reproduce, but this is very easy to do.

      • Create a test class with a @Rule RestartableJenkinsRule story ...
      • Put the following in a test: story.then(rule -> System.out.println("ROOTDIR: "+rule.jenkins.getRootDir()));

      You will see that the printing above will display different, or the same values, if you respectively use or do not use @LocalData.



      Currrently fails (as expected) this way:

      [INFO] Running InjectedTest
      [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.03 s - in InjectedTest
      [INFO] Running io.jenkins.plugins.ZeTest
      [ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.455 s <<< FAILURE! - in io.jenkins.plugins.ZeTest
      [ERROR] withLocalData(io.jenkins.plugins.ZeTest)  Time elapsed: 1.75 s  <<< FAILURE!
              at org.junit.Assert.fail(Assert.java:86)
              at org.junit.Assert.assertTrue(Assert.java:41)
              at org.junit.Assert.assertTrue(Assert.java:52)
              at io.jenkins.plugins.ZeTest.lambda$withLocalData$3(ZeTest.java:47)
              at org.jvnet.hudson.test.RestartableJenkinsRule$3.evaluate(RestartableJenkinsRule.java:135)
              at org.jvnet.hudson.test.RestartableJenkinsRule$5.evaluate(RestartableJenkinsRule.java:162)
              at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:548)
              at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
              at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.lang.Thread.run(Thread.java:748)
      [INFO] Results:
      [ERROR] Failures:
      [ERROR]   ZeTest.lambda$withLocalData$3:47
      [ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0
      [INFO] ------------------------------------------------------------------------
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 18.022 s
      [INFO] Finished at: 2018-03-27T10:27:33+02:00
      [INFO] Final Memory: 52M/832M
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project localdata-jenkinsrule: There are test failures.
      [ERROR] Please refer to /home/tiste/localdata/localdata-jenkinsrule/target/surefire-reports for the individual test results.
      [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
      [ERROR] -> [Help 1]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException



          There are no comments yet on this issue.


            • Assignee:
              olivergondza Oliver Gondža
              batmat Baptiste Mathus
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: