Skip to content

Commit 479665f

Browse files
committed
Add regression test using RealJenkinsRule
1 parent 4169906 commit 479665f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinitionRJRTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jenkinsci.plugins.workflow.cps;
22

33
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
4+
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
45
import org.junit.Rule;
56
import org.junit.Test;
67
import org.jvnet.hudson.test.JenkinsRule;
@@ -21,4 +22,26 @@ private static void doesItSmoke(JenkinsRule r) throws Exception {
2122
p.setDefinition(new CpsFlowDefinition("print Jenkins.get().getRootDir().toString()", false));
2223
r.assertBuildStatusSuccess(p.scheduleBuild2(0));
2324
}
25+
26+
@Test
27+
public void flushLogsOnShutdown() throws Throwable {
28+
rjr.then(CpsFlowDefinitionRJRTest::flushLogsOnShutdownPreRestart);
29+
rjr.then(CpsFlowDefinitionRJRTest::flushLogsOnShutdownPostRestart);
30+
}
31+
32+
private static void flushLogsOnShutdownPreRestart(JenkinsRule r) throws Exception {
33+
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
34+
p.setDefinition(new CpsFlowDefinition("sleep 10\n", true));
35+
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
36+
r.waitForMessage("Sleeping for 10 sec", b);
37+
r.jenkins.doQuietDown();
38+
}
39+
40+
private static void flushLogsOnShutdownPostRestart(JenkinsRule r) throws Exception {
41+
WorkflowJob p = r.jenkins.getItemByFullName("p", WorkflowJob.class);
42+
WorkflowRun b = p.getLastBuild();
43+
r.assertBuildStatusSuccess(r.waitForCompletion(b));
44+
r.assertLogContains("Resuming build at ", b);
45+
r.assertLogContains("Pausing (Preparing for shutdown)", b);
46+
}
2447
}

0 commit comments

Comments
 (0)