use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class MailServiceTest method sendFailedStageExecutionMessageWithEmptyLog.
@Test
public void sendFailedStageExecutionMessageWithEmptyLog() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
Process process = new ProcessBuilder(processId).execute("STAGE1").withSyncTestExecutor().build();
Stage stage = process.getStage("STAGE1").get();
StageEntity.createExecution(pipelineName, processId, stage).setStageState(StageState.ERROR);
StageLogEntity stageLogEntity = new StageLogEntity();
stageLogEntity.setPipelineName(pipelineName);
stageLogEntity.setProcessId(processId);
stageLogEntity.setStageName("STAGE1");
stageLogEntity.setStageLog("");
stageService.saveStageLog(stageLogEntity);
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName(pipelineName);
processEntity.setProcessId(processId);
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
process.setProcessEntity(processEntity);
assertThat(mailService.getStageExecutionSubject(process, stage)).isEqualTo("Pipelite stage (ERROR): " + pipelineName + "/" + processId + "/STAGE1");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"ERROR\",\n" + " \"executionCount\" : 0\n" + "}\n" + "\n" + "Error logs:\n" + "---------------\n");
}
use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class MailServiceTest method sendFailedStageExecutionMessageWithNoLog.
@Test
public void sendFailedStageExecutionMessageWithNoLog() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
Process process = new ProcessBuilder(processId).execute("STAGE1").withSyncTestExecutor().build();
Stage stage = process.getStage("STAGE1").get();
StageEntity.createExecution(pipelineName, processId, stage).setStageState(StageState.ERROR);
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName(pipelineName);
processEntity.setProcessId(processId);
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
process.setProcessEntity(processEntity);
assertThat(mailService.getStageExecutionSubject(process, stage)).isEqualTo("Pipelite stage (ERROR): " + pipelineName + "/" + processId + "/STAGE1");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"ERROR\",\n" + " \"executionCount\" : 0\n" + "}\n" + "\n" + "Error logs:\n" + "---------------\n");
}
use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class ProcessFactory method create.
/**
* Creates a process.
*
* @param processId the process id
* @param registeredPipeline the registered pipeline
* @return the process
* @throws PipeliteException if the new process could not be created
*/
public static Process create(String processId, RegisteredPipeline registeredPipeline) {
if (processId == null) {
throw new PipeliteException("Failed to create process. Missing process id.");
}
if (registeredPipeline == null) {
throw new PipeliteException("Failed to create process. Missing registered pipeline.");
}
String pipelineName = registeredPipeline.pipelineName();
if (pipelineName == null) {
throw new PipeliteException("Failed to create process. Missing pipeline name.");
}
try {
log.atFine().log("Creating %s process %s", pipelineName, processId);
ProcessBuilder processBuilder = new ProcessBuilder(processId);
registeredPipeline.configureProcess(processBuilder);
Process process = processBuilder.build();
if (process == null) {
throw new PipeliteException("Failed to create " + pipelineName + " process " + processId + ". Pipeline returned a null process.");
}
return process;
} catch (Exception ex) {
throw new PipeliteException("Failed to create " + pipelineName + " process " + processId + ". Unexpected exception.", ex);
}
}
use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class ConfigureProcessValidator method validate.
/**
* Validates stage execution graph. Uses 'VALIDATE' as the processId.
*
* @param pipeline the schedule or pipeline to validate
* @return the validation errors
*/
public static List<ValidatorError> validate(RegisteredPipeline pipeline) {
List<ValidatorError> errors = new ArrayList<>();
try {
ProcessBuilder processBuilder = new ProcessBuilder("VALIDATE");
pipeline.configureProcess(processBuilder);
processBuilder.build();
} catch (PipeliteException ex) {
errors.add(new ValidatorError(pipeline.pipelineName(), ex.getMessage()));
}
return errors;
}
use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class DependencyResolverTest method othersActivePendingIndependentOneErrorMaxAndImmediateRetriesLeft.
@Test
public void othersActivePendingIndependentOneErrorMaxAndImmediateRetriesLeft() {
for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
ProcessBuilder builder = createProcessBuilder();
Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR, ExecutorParameters.builder().maximumRetries(1).immediateRetries(1).build()).execute("STAGE2").withSyncTestExecutor().execute("STAGE3").withSyncTestExecutor().build();
Set<Stage> stages = process.getStages();
int stageNumber = 0;
for (Stage stage : process.getStages()) {
if (stageNumber == 0) {
simulateStageExecution(stage, StageState.ERROR);
} else {
simulateStageExecution(stage, stageState);
}
stageNumber++;
}
assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE2", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE3", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE2", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE3", Collections.emptyList());
assertGetDependentStages(process, "STAGE1", Collections.emptyList());
assertGetDependentStages(process, "STAGE2", Collections.emptyList());
assertGetDependentStages(process, "STAGE3", Collections.emptyList());
assertGetPermanentFailedStages(stages, Collections.emptyList());
assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE1", "STAGE2", "STAGE3"));
assertGetEventuallyExecutableStages(process, Arrays.asList("STAGE1", "STAGE2", "STAGE3"));
}
}
Aggregations