Search in sources :

Example 21 with ProcessEntity

use of pipelite.entity.ProcessEntity in project pipelite by enasequence.

the class ScheduleRunner method createProcessEntity.

private ProcessEntity createProcessEntity(ScheduleCron scheduleCron) {
    String pipelineName = scheduleCron.getPipelineName();
    ScheduleEntity scheduleEntity = scheduleService.getSavedSchedule(pipelineName).get();
    String lastProcessId = scheduleEntity.getProcessId();
    String nextProcessId = nextProcessId(lastProcessId);
    Optional<ProcessEntity> processEntity = processService.getSavedProcess(pipelineName, nextProcessId);
    if (processEntity.isPresent()) {
        throw new PipeliteException("Scheduled new process already exists: " + pipelineName + " " + nextProcessId);
    }
    return processService.createExecution(pipelineName, nextProcessId, ProcessEntity.DEFAULT_PRIORITY);
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) PipeliteException(pipelite.exception.PipeliteException) ScheduleEntity(pipelite.entity.ScheduleEntity)

Example 22 with ProcessEntity

use of pipelite.entity.ProcessEntity in project pipelite by enasequence.

the class PipelineRunner method runProcesses.

private void runProcesses() {
    if (processQueue.get() == null) {
        return;
    }
    while (true) {
        ProcessEntity processEntity = processQueue.get().nextProcess(this.getActiveProcessCount());
        if (processEntity == null) {
            return;
        }
        runProcess(processEntity);
    }
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity)

Example 23 with ProcessEntity

use of pipelite.entity.ProcessEntity in project pipelite by enasequence.

the class MailServiceTest method sendFailedStageExecutionMessageWithNullLog.

@Test
public void sendFailedStageExecutionMessageWithNullLog() {
    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(null);
    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 24 with ProcessEntity

use of pipelite.entity.ProcessEntity in project pipelite by enasequence.

the class MailServiceTest method sendProcessExecutionMessage.

@Test
public void sendProcessExecutionMessage() {
    Process process = new ProcessBuilder("PROCESS_ID").execute("STAGE1").withSyncTestExecutor().build();
    StageEntity.createExecution("PIPELINE_NAME", "PROCESS_ID", process.getStage("STAGE1").get());
    ProcessEntity processEntity = new ProcessEntity();
    processEntity.setPipelineName("PIPELINE_NAME");
    processEntity.setProcessId("PROCESS_ID");
    processEntity.setProcessState(ProcessState.PENDING);
    processEntity.setPriority(5);
    process.setProcessEntity(processEntity);
    assertThat(mailService.getProcessExecutionSubject(process)).isEqualTo("Pipelite process (PENDING): PIPELINE_NAME/PROCESS_ID");
    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) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with ProcessEntity

use of pipelite.entity.ProcessEntity in project pipelite by enasequence.

the class MailServiceTest method sendFailedStageExecutionMessageWithLog.

@Test
public void sendFailedStageExecutionMessageWithLog() {
    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("TEST");
    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" + "\n" + "Stage: STAGE1\n" + "===============\n" + "TEST\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)

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