[JIRA] (JENKINS-50422) RestartJenkinsRule gets a new rootDir for each step when using @LocalData

0 views
Skip to first unread message

batmat@batmat.net (JIRA)

unread,
Mar 27, 2018, 4:23:02 AM3/27/18
to jenkinsc...@googlegroups.com
Baptiste Mathus created an issue
 
Jenkins / Bug JENKINS-50422
RestartJenkinsRule gets a new rootDir for each step when using @LocalData
Issue Type: Bug Bug
Assignee: Oliver Gondža
Components: jenkins-test-harness
Created: 2018-03-27 08:22
Environment: JTH 2.34
Priority: Major Major
Reporter: Baptiste Mathus

 Issue

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.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

batmat@batmat.net (JIRA)

unread,
Mar 27, 2018, 4:30:03 AM3/27/18
to jenkinsc...@googlegroups.com
Baptiste Mathus updated an issue
Change By: Baptiste Mathus
h3. Issue

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}}.

h3. Expected behaviour


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

h3. 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}}.


h4. Reproducer
https://github.com/batmat/localdata-jenkinsrule

Currrently fails (as _expected_) this way:

{noformat}
...
[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!
java.lang.AssertionError
        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]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   ZeTest.lambda$withLocalData$3:47
[INFO]
[ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[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]
[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]
[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]
[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
{noformat}
Reply all
Reply to author
Forward
0 new messages