Skip to content
Permalink
Browse files

Fix [JENKINS-49961] by avoiding an unsafe save operation when togglin…

…g ResumeEnabled if the FlowExecutionOwner is not yet set
  • Loading branch information
svanoort committed Mar 6, 2018
1 parent 57bda81 commit 0ebe94916353f873715c06b642fb744969f1db0c
@@ -62,7 +62,7 @@
</pluginRepository>
</pluginRepositories>
<properties>
<jenkins.version>2.60.3</jenkins.version>
<jenkins.version>2.62</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
<git-plugin.version>3.1.0</git-plugin.version>
@@ -141,7 +141,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.11.2</version>
<version>2.17</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -345,7 +345,6 @@ public boolean isResumeBlocked() {
public void setResumeBlocked(boolean resumeBlocked) {
if (this.resumeBlocked != resumeBlocked) {
this.resumeBlocked = resumeBlocked;
saveOwner();
}
}

@@ -723,10 +723,10 @@ public void testResumeBlocked() throws Exception {
public void evaluate() throws Throwable {
Jenkins jenkins = story.j.jenkins;
WorkflowRun run = createAndRunSleeperJob(story.j.jenkins, jobName, FlowDurabilityHint.MAX_SURVIVABILITY);
run.getParent().setResumeBlocked(true);
FlowExecution exec = run.getExecution();
if (exec instanceof CpsFlowExecution) {
assert ((CpsFlowExecution) exec).getStorage().isPersistedFully();
((CpsFlowExecution)exec).setResumeBlocked(true);
}
logStart[0] = JenkinsRule.getLog(run);
nodesOut.addAll(new DepthFirstScanner().allNodes(run.getExecution()));
@@ -744,6 +744,40 @@ public void evaluate() throws Throwable {
});
}

@Test
@Issue("JENKINS-49961")
public void testResumeBlockedAddedAfterRunStart() throws Exception {
final String jobName = "survivesEverything";
final String[] logStart = new String[1];
final List<FlowNode> nodesOut = new ArrayList<FlowNode>();

story.addStepWithDirtyShutdown(new Statement() {
@Override
public void evaluate() throws Throwable {
Jenkins jenkins = story.j.jenkins;
WorkflowRun run = createAndRunSleeperJob(story.j.jenkins, jobName, FlowDurabilityHint.MAX_SURVIVABILITY);
run.getParent().setResumeBlocked(false);
FlowExecution exec = run.getExecution();
if (exec instanceof CpsFlowExecution) {
assert ((CpsFlowExecution) exec).getStorage().isPersistedFully();
}
logStart[0] = JenkinsRule.getLog(run);
nodesOut.addAll(new DepthFirstScanner().allNodes(run.getExecution()));
nodesOut.sort(FlowScanningUtils.ID_ORDER_COMPARATOR);
run.getParent().setResumeBlocked(true);
}
});

story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
WorkflowRun run = story.j.jenkins.getItemByFullName(jobName, WorkflowJob.class).getLastBuild();
verifyFailedCleanly(story.j.jenkins, run);
assertIncludesNodes(nodesOut, run);
}
});
}

/** Test interrupting build by randomly dying at unpredictable times. */
@Test
@Ignore //Too long to run as part of main suite

0 comments on commit 0ebe949

Please sign in to comment.
You can’t perform that action at this time.