Search in sources :

Example 11 with Process

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);
}
Also used : Process(pipelite.process.Process)

Example 12 with Process

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");
}
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 13 with Process

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");
}
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 14 with Process

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");
}
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 15 with Process

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

Aggregations

Process (pipelite.process.Process)40 Test (org.junit.jupiter.api.Test)29 Stage (pipelite.stage.Stage)27 ProcessBuilder (pipelite.process.builder.ProcessBuilder)24 ProcessEntity (pipelite.entity.ProcessEntity)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)14 StageState (pipelite.stage.StageState)14 StageEntity (pipelite.entity.StageEntity)8 StageLogEntity (pipelite.entity.StageLogEntity)4 ArrayList (java.util.ArrayList)3 PipeliteProcessRetryException (pipelite.exception.PipeliteProcessRetryException)3 ZonedDateTime (java.time.ZonedDateTime)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 RegisteredPipeline (pipelite.RegisteredPipeline)2 ScheduleEntity (pipelite.entity.ScheduleEntity)2 SyncTestExecutor (pipelite.executor.SyncTestExecutor)2 PipelineMetrics (pipelite.metrics.PipelineMetrics)2 ProcessState (pipelite.process.ProcessState)2 ScheduleRunner (pipelite.runner.schedule.ScheduleRunner)2