Search in sources :

Example 1 with ProcessEntity

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

the class ProcessEntityAsserter method assertCompletedProcessEntity.

public static void assertCompletedProcessEntity(ProcessService processService, TestType testType, String pipelineName, String processId) {
    ProcessEntity processEntity = processService.getSavedProcess(pipelineName, processId).get();
    assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
    assertThat(processEntity.getProcessId()).isEqualTo(processId);
    assertThat(processEntity.getExecutionCount()).isEqualTo(1);
    if (testType.expectedProcessCompletedCnt() > 0) {
        assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
    } else {
        assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
    }
    assertThat(processEntity.getStartTime()).isNotNull();
    assertThat(processEntity.getEndTime()).isAfterOrEqualTo(processEntity.getStartTime());
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity)

Example 2 with ProcessEntity

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

the class ScheduleRunnerTest method assertProcessEntity.

private void assertProcessEntity(TestSchedule f, String processId) {
    String pipelineName = f.pipelineName();
    ProcessEntity processEntity = processService.getSavedProcess(f.pipelineName(), processId).get();
    assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
    assertThat(processEntity.getProcessId()).isEqualTo(processId);
    assertThat(processEntity.getExecutionCount()).isEqualTo(1);
    TestProcessConfiguration t = f.getTestProcessConfiguration();
    if (t.stageTestResult != StageTestResult.SUCCESS) {
        assertThat(processEntity.getProcessState()).isEqualTo(// no re-executions allowed
        ProcessState.FAILED);
    } else {
        assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
    }
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity)

Example 3 with ProcessEntity

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

the class ProcessRunnerPoolTest method createProcess.

private Process createProcess(Function<StageExecutorRequest, StageExecutorResult> callback) {
    String processId = PipeliteIdCreator.processId();
    ExecutorParameters executorParams = new ExecutorParameters();
    executorParams.setMaximumRetries(0);
    Process process = new ProcessBuilder(processId).execute("STAGE1").withAsyncTestExecutor(callback, executorParams).build();
    ProcessEntity processEntity = ProcessEntity.createExecution(PIPELINE_NAME, processId, ProcessEntity.DEFAULT_PRIORITY);
    process.setProcessEntity(processEntity);
    return process;
}
Also used : ExecutorParameters(pipelite.stage.parameters.ExecutorParameters) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ProcessEntity(pipelite.entity.ProcessEntity) Process(pipelite.process.Process)

Example 4 with ProcessEntity

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

the class ScheduleRunnerResumeTest method testResumeSchedules.

@Test
public // @Timeout(value = 10, unit = TimeUnit.SECONDS)
void testResumeSchedules() {
    int maxExecution1 = 1;
    int maxExecution2 = 1;
    // Create two schedules with start time and process id to allow processes to resume.
    ZonedDateTime startTime1 = ZonedDateTime.now().minusHours(2).truncatedTo(ChronoUnit.SECONDS);
    ZonedDateTime startTime2 = ZonedDateTime.now().minusHours(2).truncatedTo(ChronoUnit.SECONDS);
    ZonedDateTime nextTime1 = ZonedDateTime.now().minusMinutes(1).truncatedTo(ChronoUnit.SECONDS);
    ZonedDateTime nextTime2 = ZonedDateTime.now().minusHours(1).truncatedTo(ChronoUnit.SECONDS);
    ScheduleEntity scheduleEntity1 = pipeliteServices.schedule().getSavedSchedule(resume1.pipelineName()).get();
    ScheduleEntity scheduleEntity2 = pipeliteServices.schedule().getSavedSchedule(resume2.pipelineName()).get();
    scheduleEntity1.setStartTime(startTime1);
    scheduleEntity2.setStartTime(startTime2);
    scheduleEntity1.setNextTime(nextTime1);
    scheduleEntity2.setNextTime(nextTime2);
    String processId1 = "1";
    String processId2 = "2";
    scheduleEntity1.setProcessId(processId1);
    scheduleEntity2.setProcessId(processId2);
    pipeliteServices.schedule().saveSchedule(scheduleEntity1);
    pipeliteServices.schedule().saveSchedule(scheduleEntity2);
    ProcessEntity processEntity1 = ProcessEntity.createExecution(resume1.pipelineName(), processId1, 5);
    ProcessEntity processEntity2 = ProcessEntity.createExecution(resume2.pipelineName(), processId2, 5);
    pipeliteServices.process().saveProcess(processEntity1);
    pipeliteServices.process().saveProcess(processEntity2);
    ScheduleRunner scheduleRunner = spy(ScheduleRunnerFactory.create(pipeliteConfiguration, pipeliteServices, pipeliteMetrics, pipeliteServices.registeredPipeline().getRegisteredPipelines(Schedule.class)));
    scheduleRunner.setMaximumExecutions(resume1.pipelineName(), maxExecution1);
    scheduleRunner.setMaximumExecutions(resume2.pipelineName(), maxExecution2);
    // Resume the two processes, check that they are immediately executed
    // and that they are scheduled for a later execution.
    scheduleRunner.startUp();
    while (!scheduleRunner.isIdle()) {
        scheduleRunner.runOneIteration();
        Time.wait(Duration.ofMillis(100));
    }
    scheduleEntity1 = pipeliteServices.schedule().getSavedSchedule(resume1.pipelineName()).get();
    scheduleEntity2 = pipeliteServices.schedule().getSavedSchedule(resume2.pipelineName()).get();
    assertThat(scheduleEntity1.getStartTime()).isEqualTo(startTime1);
    assertThat(scheduleEntity2.getStartTime()).isEqualTo(startTime2);
    assertThat(scheduleEntity1.getEndTime()).isAfter(startTime1);
    assertThat(scheduleEntity2.getEndTime()).isAfter(startTime2);
    assertThat(scheduleEntity1.getExecutionCount()).isOne();
    assertThat(scheduleEntity2.getExecutionCount()).isOne();
    assertThat(scheduleEntity1.getProcessId()).isEqualTo(processId1);
    assertThat(scheduleEntity2.getProcessId()).isEqualTo(processId2);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ProcessEntity(pipelite.entity.ProcessEntity) ScheduleEntity(pipelite.entity.ScheduleEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with ProcessEntity

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

the class ProcessFactoryTest method createFailed.

@Test
public void createFailed() {
    ProcessEntity processEntity = new ProcessEntity();
    processEntity.setProcessId(PROCESS_ID);
    Pipeline pipeline = new Pipeline() {

        @Override
        public String pipelineName() {
            return PIPELINE_NAME;
        }

        @Override
        public Options configurePipeline() {
            return new Options().pipelineParallelism(5);
        }

        @Override
        public void configureProcess(ProcessBuilder builder) {
        }
    };
    assertThrows(PipeliteException.class, () -> ProcessFactory.create(processEntity, pipeline));
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Pipeline(pipelite.Pipeline) Test(org.junit.jupiter.api.Test)

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