use of org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint in project workflow-cps-plugin by jenkinsci.
the class ReplayFlowFactoryAction method create.
@Override
public CpsFlowExecution create(FlowDefinition def, FlowExecutionOwner owner, List<? extends Action> actions) throws IOException {
String script = replacementMainScript;
// minimize build.xml size
replacementMainScript = null;
Queue.Executable exec = owner.getExecutable();
FlowDurabilityHint hint = (exec instanceof Run) ? DurabilityHintProvider.suggestedFor(((Run) exec).getParent()) : GlobalDefaultFlowDurabilityLevel.getDefaultDurabilityHint();
return new CpsFlowExecution(script, sandbox, owner, hint);
}
use of org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint in project workflow-cps-plugin by jenkinsci.
the class CpsFlowExecution method createStorage.
private TimingFlowNodeStorage createStorage() throws IOException {
FlowNodeStorage wrappedStorage;
FlowDurabilityHint hint = getDurabilityHint();
wrappedStorage = (hint.isPersistWithEveryStep()) ? new SimpleXStreamFlowNodeStorage(this, getStorageDir()) : new BulkFlowNodeStorage(this, getStorageDir());
return new TimingFlowNodeStorage(wrappedStorage);
}
use of org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint in project workflow-cps-plugin by jenkinsci.
the class FlowDurabilityTest method testCompleteAndLoadBuilds.
/**
* Confirm that for ALL implementations, a run can complete and be loaded if you restart after completion.
*/
@Test
public void testCompleteAndLoadBuilds() throws Exception {
final FlowDurabilityHint[] durabilityHints = FlowDurabilityHint.values();
final WorkflowJob[] jobs = new WorkflowJob[durabilityHints.length];
final String[] logOutput = new String[durabilityHints.length];
// Create and run jobs for each of the durability hints
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
int i = 1;
for (FlowDurabilityHint hint : durabilityHints) {
try {
WorkflowRun run = createAndRunBasicJob(story.j.jenkins, "basicJob-" + hint.toString(), hint, i);
jobs[i - 1] = run.getParent();
SemaphoreStep.success("halt/" + i++, Result.SUCCESS);
story.j.waitForCompletion(run);
story.j.assertBuildStatus(Result.SUCCESS, run);
logOutput[i - 2] = JenkinsRule.getLog(run);
assertHasTimingAction(run.getExecution());
} catch (AssertionError ae) {
System.out.println("Error with durability level: " + hint);
throw ae;
}
}
}
});
// Restart and confirm we can still load them.
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
for (int i = 0; i < durabilityHints.length; i++) {
WorkflowJob j = jobs[i];
try {
WorkflowRun run = j.getLastBuild();
verifySucceededCleanly(story.j.jenkins, run);
Assert.assertEquals(durabilityHints[i], run.getExecution().getDurabilityHint());
Assert.assertEquals(logOutput[i], JenkinsRule.getLog(run));
assertHasTimingAction(run.getExecution());
} catch (AssertionError ae) {
System.out.println("Error with durability level: " + durabilityHints[i]);
throw ae;
}
}
}
});
}
Aggregations