Skip to content

Commit 23bdce9

Browse files
committed
stop checking nodes altogether after a dirty shutdown
1 parent 30ae3c7 commit 23bdce9

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/test/java/org/jenkinsci/plugins/workflow/cps/FlowDurabilityTest.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ static void verifySucceededCleanly(Jenkins j, WorkflowRun run) throws Exception
250250
assertHasTimingAction(run.getExecution());
251251
}
252252

253+
/** A minimal check of resuming the job with no node checks, in case of a dirty shutdown.
254+
* Currently dirty shutdowns have the potential to lose the head node ID if they happen at the moment of writing
255+
* it to build.xml
256+
*/
257+
static void verifyDirtyResumed(JenkinsRule rule, WorkflowRun run, String logStart) throws Exception {
258+
assert run.isBuilding();
259+
assertHasTimingAction(run.getExecution());
260+
rule.waitForCompletion(run);
261+
Assert.assertEquals(Result.SUCCESS, run.getResult());
262+
verifyCompletedCleanly(rule.jenkins, run);
263+
//no checking nodes
264+
rule.assertLogContains(logStart, run);
265+
}
266+
253267
/** If it's a {@link SemaphoreStep} we test less rigorously because that blocks async GraphListeners. */
254268
static void verifySafelyResumed(JenkinsRule rule, WorkflowRun run, boolean isSemaphore, String logStart) throws Exception {
255269
assert run.isBuilding();
@@ -716,7 +730,6 @@ public void evaluate() throws Throwable {
716730
WorkflowRun run = createAndRunSleeperJob(story.j.jenkins, jobName, FlowDurabilityHint.MAX_SURVIVABILITY, false);
717731
FlowExecution exec = run.getExecution();
718732
if (exec instanceof CpsFlowExecution) {
719-
((CpsFlowExecution) exec).waitForSuspension(); // till done writing head node ID into build.xml
720733
assert ((CpsFlowExecution) exec).getStorage().isPersistedFully();
721734
}
722735
logStart[0] = JenkinsRule.getLog(run);
@@ -727,7 +740,7 @@ public void evaluate() throws Throwable {
727740
@Override
728741
public void evaluate() throws Throwable {
729742
WorkflowRun run = story.j.jenkins.getItemByFullName(jobName, WorkflowJob.class).getLastBuild();
730-
verifySafelyResumed(story.j, run, false, logStart[0]);
743+
verifyDirtyResumed(story.j, run, logStart[0]);
731744
}
732745
});
733746
}
@@ -746,7 +759,6 @@ public void evaluate() throws Throwable {
746759
FlowExecution exec = run.getExecution();
747760
Assert.assertTrue(((CpsFlowExecution) exec).isResumeBlocked());
748761
if (exec instanceof CpsFlowExecution) {
749-
((CpsFlowExecution) exec).waitForSuspension(); // till done writing head node ID into build.xml
750762
assert ((CpsFlowExecution) exec).getStorage().isPersistedFully();
751763
}
752764
Assert.assertFalse(((CpsFlowExecution) exec).getProgramDataFile().exists());
@@ -761,7 +773,6 @@ public void evaluate() throws Throwable {
761773
public void evaluate() throws Throwable {
762774
WorkflowRun run = story.j.jenkins.getItemByFullName(jobName, WorkflowJob.class).getLastBuild();
763775
verifyFailedCleanly(story.j.jenkins, run);
764-
assertIncludesNodes(nodesOut, run);
765776
}
766777
});
767778
}
@@ -779,7 +790,6 @@ public void evaluate() throws Throwable {
779790
WorkflowRun run = createAndRunSleeperJob(story.j.jenkins, jobName, FlowDurabilityHint.MAX_SURVIVABILITY, false);
780791
FlowExecution exec = run.getExecution();
781792
if (exec instanceof CpsFlowExecution) {
782-
((CpsFlowExecution) exec).waitForSuspension(); // till done writing head node ID into build.xml
783793
assert ((CpsFlowExecution) exec).getStorage().isPersistedFully(); // single node xmls written
784794
}
785795
nodesOut.addAll(new DepthFirstScanner().allNodes(run.getExecution()));
@@ -793,7 +803,6 @@ public void evaluate() throws Throwable {
793803
public void evaluate() throws Throwable {
794804
WorkflowRun run = story.j.jenkins.getItemByFullName(jobName, WorkflowJob.class).getLastBuild();
795805
verifyFailedCleanly(story.j.jenkins, run);
796-
assertIncludesNodes(nodesOut, run);
797806
}
798807
});
799808
}

0 commit comments

Comments
 (0)