use of pipelite.process.Process in project pipelite by enasequence.
the class ProcessRunnerTest method evaluateProcessStateWithRetries.
private void evaluateProcessStateWithRetries(StageState firstStageState, StageState secondStageState, ProcessState state) {
int firstStageExecutions = firstStageState != null ? 1 : 0;
int secondStageExecutions = secondStageState != null ? 1 : 0;
Process process = twoIndependentStagesProcess(firstStageState, secondStageState, firstStageExecutions, secondStageExecutions, 1, 1);
assertThat(ProcessRunner.evaluateProcessState(process)).isEqualTo(state);
}
use of pipelite.process.Process in project pipelite by enasequence.
the class MailServiceTest method sendStageExecutionMessage.
@Test
public void sendStageExecutionMessage() {
Process process = new ProcessBuilder("PROCESS_ID").execute("STAGE1").withSyncTestExecutor().build();
Stage stage = process.getStage("STAGE1").get();
StageEntity.createExecution("PIPELINE_NAME", "PROCESS_ID", stage);
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName("PIPELINE_NAME");
processEntity.setProcessId("PROCESS_ID");
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
process.setProcessEntity(processEntity);
assertThat(mailService.getStageExecutionSubject(process, stage)).isEqualTo("Pipelite stage (PENDING): PIPELINE_NAME/PROCESS_ID/STAGE1");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"PROCESS_ID\",\n" + " \"pipelineName\" : \"PIPELINE_NAME\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"PROCESS_ID\",\n" + " \"pipelineName\" : \"PIPELINE_NAME\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"PENDING\",\n" + " \"executionCount\" : 0\n" + "}\n");
}
use of pipelite.process.Process 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.Process 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.Process in project pipelite by enasequence.
the class RetryServiceTest method retryFailedProcessNoPermanentlyFailedStages.
@Test
public void retryFailedProcessNoPermanentlyFailedStages() {
String processId = PipeliteIdCreator.processId();
RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(PIPELINE_NAME);
Process process = ProcessFactory.create(processId, registeredPipeline);
// Save failed process
process.setProcessEntity(processService.createExecution(PIPELINE_NAME, processId, 1));
processService.startExecution(process.getProcessEntity());
processService.endExecution(process, ProcessState.FAILED);
// Check failed process
ProcessEntity processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
// Save completed stage
Stage stage = process.getStage(STAGE_NAME).get();
stageService.createExecution(PIPELINE_NAME, processId, stage);
stageService.startExecution(stage);
stageService.endExecution(stage, StageExecutorResult.success());
// Check completed stage
StageEntity stageEntity = stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get();
assertThat(stageEntity.getStageState()).isEqualTo(StageState.SUCCESS);
// Retry
retryService.retry(PIPELINE_NAME, processId);
processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getPriority()).isEqualTo(1);
assertThat(processEntity.getExecutionCount()).isEqualTo(1);
assertThat(processEntity.getStartTime()).isNotNull();
// Made null
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
// Check that stage state is unchanged
stageEntity.equals(stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get());
}
Aggregations