Search in sources :

Example 26 with ProcessEntity

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

the class ProcessServiceTest method createProcessEntity.

private ProcessEntity createProcessEntity(Integer priority, ZonedDateTime initTime) {
    ProcessEntity processEntity = new ProcessEntity();
    processEntity.setProcessId(PipeliteIdCreator.processId());
    processEntity.setPriority(priority);
    processEntity.setCreateTime(initTime);
    return processEntity;
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity)

Example 27 with ProcessEntity

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

the class ProcessServiceTest method lifecycle.

@Test
public void lifecycle() {
    String pipelineName = PipeliteIdCreator.pipelineName();
    String processId = PipeliteIdCreator.processId();
    int priority = 1;
    ProcessEntity processEntity = processService.createExecution(pipelineName, processId, priority);
    assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
    assertThat(processEntity.getProcessId()).isEqualTo(processId);
    assertThat(processEntity.getPriority()).isEqualTo(priority);
    assertThat(processEntity.getExecutionCount()).isEqualTo(0);
    assertThat(processEntity.getStartTime()).isNull();
    assertThat(processEntity.getEndTime()).isNull();
    assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.PENDING);
    processService.startExecution(processEntity);
    assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
    assertThat(processEntity.getProcessId()).isEqualTo(processId);
    assertThat(processEntity.getPriority()).isEqualTo(priority);
    assertThat(processEntity.getExecutionCount()).isEqualTo(0);
    assertThat(processEntity.getStartTime()).isNotNull();
    assertThat(processEntity.getEndTime()).isNull();
    assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
    assertThat(processService.getSavedProcess(pipelineName, processId).get()).isEqualTo(processEntity);
    Process process = new ProcessBuilder(processId).execute("STAGE").withSyncTestExecutor().build();
    process.setProcessEntity(processEntity);
    processService.endExecution(process, ProcessState.COMPLETED);
    assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
    assertThat(processEntity.getProcessId()).isEqualTo(processId);
    assertThat(processEntity.getPriority()).isEqualTo(priority);
    assertThat(processEntity.getExecutionCount()).isEqualTo(1);
    assertThat(processEntity.getStartTime()).isNotNull();
    assertThat(processEntity.getEndTime()).isNotNull();
    assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
    assertThat(processService.getSavedProcess(pipelineName, processId).get()).isEqualTo(processEntity);
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with ProcessEntity

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

the class ProcessServiceTest method getProcesses.

@Test
public void getProcesses() {
    String pipelineName = PipeliteIdCreator.pipelineName();
    List<ProcessEntity> processes = Arrays.asList(saveProcess(pipelineName, ProcessState.ACTIVE, 1), saveProcess(pipelineName, ProcessState.ACTIVE, 1), saveProcess(pipelineName, ProcessState.COMPLETED, 1), saveProcess(pipelineName, ProcessState.COMPLETED, 1), saveProcess(pipelineName, ProcessState.FAILED, 1), saveProcess(pipelineName, ProcessState.FAILED, 1), saveProcess(pipelineName, ProcessState.PENDING, 1), saveProcess(pipelineName, ProcessState.PENDING, 1));
    // Test without state.
    assertProcessStateCount(processService.getProcesses(pipelineName, null, /* state*/
    MAX_PROCESS_COUNT), 2, 2, 2, 2);
    for (ProcessState state : EnumSet.of(ProcessState.ACTIVE, ProcessState.COMPLETED, ProcessState.FAILED, ProcessState.CANCELLED)) {
        assertProcessStateCount(processService.getProcesses(pipelineName, state, MAX_PROCESS_COUNT), state == ProcessState.COMPLETED ? 2 : 0, state == ProcessState.ACTIVE ? 2 : 0, state == ProcessState.FAILED ? 2 : 0, state == ProcessState.PENDING ? 2 : 0);
    }
}
Also used : ProcessState(pipelite.process.ProcessState) ProcessEntity(pipelite.entity.ProcessEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with ProcessEntity

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

the class ProcessServiceTest method saveProcess.

private ProcessEntity saveProcess(String pipelineName, ProcessState state, int priority) {
    ProcessEntity processEntity = ProcessEntity.createExecution(pipelineName, PipeliteIdCreator.processId(), priority);
    processEntity.setProcessState(state);
    processEntity.setExecutionCount(0);
    return processService.saveProcess(processEntity);
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity)

Example 30 with ProcessEntity

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

the class ProcessServiceTest method isRetryProcessWithNotFailedProcess.

@Test
public void isRetryProcessWithNotFailedProcess() {
    String pipelineName = PipeliteIdCreator.pipelineName();
    String processId = PipeliteIdCreator.processId();
    int priority = 1;
    ProcessEntity processEntity = processService.createExecution(pipelineName, processId, priority);
    processEntity.endExecution(ProcessState.COMPLETED);
    processService.saveProcess(processEntity);
    assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
    assertThrows(PipeliteProcessRetryException.class, () -> processService.isRetryProcess(pipelineName, processId));
}
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