Search in sources :

Example 36 with ProcessEntity

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

the class ProcessQueueTest method lifecycle.

@Test
public void lifecycle() {
    final TestPipeline pipeline = new TestPipeline();
    final int pipelineParallelism = pipeline.configurePipeline().pipelineParallelism();
    final int processQueueMaxSize = pipelineParallelism * MAX_QUEUE_SIZE_PARALLELISM_MULTIPLIER;
    List<ProcessEntity> activeEntities = Collections.nCopies(ACTIVE_PROCESS_CNT, mock(ProcessEntity.class));
    List<ProcessEntity> pendingEntities = Collections.nCopies(PENDING_PROCESS_CNT, mock(ProcessEntity.class));
    doReturn(activeEntities).when(processService).getUnlockedActiveProcesses(any(), eq(processQueueMaxSize));
    doReturn(pendingEntities).when(processService).getPendingProcesses(any(), eq(processQueueMaxSize - ACTIVE_PROCESS_CNT));
    ProcessQueue processQueue = spy(new ProcessQueue(pipeliteConfiguration, pipeliteServices, pipeline));
    assertThat(processQueue.isRefreshQueue()).isTrue();
    assertThat(processQueue.getProcessQueueSize()).isZero();
    assertThat(processQueue.getProcessQueueMaxSize()).isEqualTo(processQueueMaxSize);
    assertThat(processQueue.getProcessQueueRefreshSize()).isZero();
    // Queue processes.
    processQueue.refreshQueue();
    verify(processQueue, times(1)).refreshQueue();
    assertThat(processQueue.isRefreshQueue()).isFalse();
    assertThat(processQueue.getProcessQueueSize()).isEqualTo(ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT);
    assertThat(processQueue.getProcessQueueMaxSize()).isEqualTo(processQueueMaxSize);
    assertThat(processQueue.getProcessQueueRefreshSize()).isEqualTo(ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT);
    for (int i = 0; i < ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT; ++i) {
        assertThat(processQueue.nextProcess(0)).isNotNull();
    }
    assertThat(processQueue.isRefreshQueue()).isTrue();
    assertThat(processQueue.getProcessQueueSize()).isZero();
    assertThat(processQueue.getProcessQueueMaxSize()).isEqualTo(processQueueMaxSize);
    assertThat(processQueue.getProcessQueueRefreshSize()).isEqualTo(ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT);
}
Also used : ConfigurableTestPipeline(pipelite.tester.pipeline.ConfigurableTestPipeline) ProcessEntity(pipelite.entity.ProcessEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with ProcessEntity

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

the class ProcessEntityCreatorTest method processEntity.

private static ProcessEntity processEntity(String pipelineName, String processId) {
    ProcessEntity processEntity = new ProcessEntity();
    processEntity.setPipelineName(pipelineName);
    processEntity.setProcessId(processId);
    return processEntity;
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity)

Example 38 with ProcessEntity

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

the class ProcessFactoryTest method createSuccess.

@Test
public void createSuccess() {
    ProcessEntity processEntity = new ProcessEntity();
    processEntity.setProcessId(PROCESS_ID);
    processEntity.setPipelineName(PIPELINE_NAME);
    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) {
            builder.execute("STAGE1").withSyncTestExecutor();
        }
    };
    Process process = ProcessFactory.create(processEntity, pipeline);
    assertThat(process).isNotNull();
    assertThat(process.getProcessId()).isEqualTo(PROCESS_ID);
    assertThat(process.getProcessEntity()).isNotNull();
    assertThat(process.getProcessEntity()).isSameAs(processEntity);
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Pipeline(pipelite.Pipeline) Test(org.junit.jupiter.api.Test)

Example 39 with ProcessEntity

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

the class ProcessController method getProcesses.

private static List<ProcessInfo> getProcesses(ProcessRunnerPool processRunnerPool, String pipelineName) {
    List<ProcessInfo> processes = new ArrayList<>();
    for (ProcessRunner processRunner : processRunnerPool.getActiveProcessRunners()) {
        Process process = processRunner.getProcess();
        ProcessEntity processEntity = process.getProcessEntity();
        if (pipelineName == null || pipelineName.equals(processRunner.getPipelineName())) {
            ProcessInfo processInfo = getProcess(processEntity);
            processes.add(processInfo);
        }
    }
    return processes;
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) ArrayList(java.util.ArrayList) Process(pipelite.process.Process) ProcessInfo(pipelite.controller.api.info.ProcessInfo) ProcessRunner(pipelite.runner.process.ProcessRunner)

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