Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
|
@@ -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 |
|
|