Search in sources :

Example 6 with ProcessEntity

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");
}
Also used : ProcessBuilder(pipelite.process.builder.ProcessBuilder) ProcessEntity(pipelite.entity.ProcessEntity) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with ProcessEntity

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");
}
Also used : StageLogEntity(pipelite.entity.StageLogEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ProcessEntity(pipelite.entity.ProcessEntity) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with ProcessEntity

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");
}
Also used : ProcessBuilder(pipelite.process.builder.ProcessBuilder) ProcessEntity(pipelite.entity.ProcessEntity) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with ProcessEntity

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();
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with ProcessEntity

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);
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ProcessEntity (pipelite.entity.ProcessEntity)39 Test (org.junit.jupiter.api.Test)24 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 Process (pipelite.process.Process)14 ProcessBuilder (pipelite.process.builder.ProcessBuilder)10 ScheduleEntity (pipelite.entity.ScheduleEntity)8 Stage (pipelite.stage.Stage)8 PipeliteProcessRetryException (pipelite.exception.PipeliteProcessRetryException)4 ZonedDateTime (java.time.ZonedDateTime)3 Pipeline (pipelite.Pipeline)3 StageEntity (pipelite.entity.StageEntity)3 StageLogEntity (pipelite.entity.StageLogEntity)3 PipeliteException (pipelite.exception.PipeliteException)2 Timed (io.micrometer.core.annotation.Timed)1 ArrayList (java.util.ArrayList)1 ProcessInfo (pipelite.controller.api.info.ProcessInfo)1 ProcessState (pipelite.process.ProcessState)1 ProcessRunner (pipelite.runner.process.ProcessRunner)1 ScheduleRunner (pipelite.runner.schedule.ScheduleRunner)1 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)1