use of pipelite.entity.ProcessEntity 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.entity.ProcessEntity 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.entity.ProcessEntity 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.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method isRetryProcessWithFailedProcess.
@Test
public void isRetryProcessWithFailedProcess() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
int priority = 1;
ProcessEntity processEntity = processService.createExecution(pipelineName, processId, priority);
processEntity.endExecution(ProcessState.FAILED);
processService.saveProcess(processEntity);
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
assertThat(processService.isRetryProcess(pipelineName, processId)).isTrue();
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method testPendingProcesses.
@Test
public void testPendingProcesses() {
ProcessEntity p1 = createProcessEntity(1, ZonedDateTime.now().minusDays(5));
ProcessEntity p2 = createProcessEntity(2, ZonedDateTime.now().minusDays(4));
ProcessEntity p3 = createProcessEntity(3, ZonedDateTime.now().minusDays(3));
ProcessEntity p4 = createProcessEntity(4, ZonedDateTime.now().minusDays(2));
ProcessEntity p5 = createProcessEntity(5, ZonedDateTime.now().minusDays(1));
List<ProcessEntity> fifoProcesses = Arrays.asList(p1, p2, p3, p4, p5);
List<ProcessEntity> priorityProcesses = Arrays.asList(p5, p4, p3, p2, p1);
// Test lower max process count
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.PRIORITY, 2, fifoProcesses, priorityProcesses)).containsExactly(p5, p4);
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.FIFO, 2, fifoProcesses, priorityProcesses)).containsExactly(p1, p2);
// Test higher max process count
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.PRIORITY, 50, fifoProcesses, priorityProcesses)).containsExactly(p5, p4, p3, p2, p1);
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.FIFO, 50, fifoProcesses, priorityProcesses)).containsExactly(p1, p2, p3, p4, p5);
// Test prefer priority
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.PREFER_PRIORITY, 5, fifoProcesses, priorityProcesses)).containsExactly(p1, p5, p4, p3, p2);
// Test prefer fifo
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.PREFER_FIFO, 5, fifoProcesses, priorityProcesses)).containsExactly(p1, p2, p3, p5, p4);
// Test balanced
assertThat(ProcessService.getPendingProcesses(ProcessQueuePriorityPolicy.BALANCED, 5, fifoProcesses, priorityProcesses)).containsExactly(p1, p2, p5, p4, p3);
}
Aggregations