Search in sources :

Example 6 with ProcessBuilder

use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.

the class DependencyResolverTest method othersActivePendingIndependentOnePermanentError.

@Test
public void othersActivePendingIndependentOnePermanentError() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR).execute("STAGE2").withSyncTestExecutor().execute("STAGE3").withSyncTestExecutor().execute("STAGE4").withSyncTestExecutor().build();
        Set<Stage> stages = process.getStages();
        int stageNumber = 0;
        for (Stage stage : stages) {
            if (stageNumber == 0) {
                simulateStageExecution(stage, ErrorType.PERMANENT_ERROR);
            } else {
                simulateStageExecution(stage, stageState);
            }
            stageNumber++;
        }
        assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStages(process, "STAGE2", Collections.emptyList());
        assertGetDependsOnStages(process, "STAGE3", Collections.emptyList());
        assertGetDependsOnStages(process, "STAGE4", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE2", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE3", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE4", Collections.emptyList());
        assertGetDependentStages(process, "STAGE1", Collections.emptyList());
        assertGetDependentStages(process, "STAGE2", Collections.emptyList());
        assertGetDependentStages(process, "STAGE3", Collections.emptyList());
        assertGetDependentStages(process, "STAGE4", Collections.emptyList());
        assertGetPermanentFailedStages(stages, Arrays.asList("STAGE1"));
        assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE2", "STAGE3", "STAGE4"));
        assertGetEventuallyExecutableStages(process, Arrays.asList("STAGE2", "STAGE3", "STAGE4"));
    }
}
Also used : StageState(pipelite.stage.StageState) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test)

Example 7 with ProcessBuilder

use of pipelite.process.builder.ProcessBuilder 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 8 with ProcessBuilder

use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.

the class ProcessBuilderTest method test.

@Test
public void test() {
    String stageName1 = "STAGE1";
    String stageName2 = "STAGE2";
    String stageName3 = "STAGE3";
    String stageName4 = "STAGE4";
    String stageName5 = "STAGE5";
    Process process = new ProcessBuilder(PROCESS_ID).execute(stageName1).withSyncTestExecutor().executeAfterPrevious(stageName2).withSyncTestExecutor().executeAfterPrevious(stageName3).withSyncTestExecutor().executeAfterFirst(stageName4).withSyncTestExecutor().executeAfter(stageName5, Arrays.asList(stageName1, stageName2)).withSyncTestExecutor().build();
    Stage stage1 = process.getStage(stageName1).get();
    Stage stage2 = process.getStage(stageName2).get();
    Stage stage3 = process.getStage(stageName3).get();
    Stage stage4 = process.getStage(stageName4).get();
    Stage stage5 = process.getStage(stageName5).get();
    assertThat(process).isNotNull();
    assertThat(process.getProcessId()).isEqualTo(PROCESS_ID);
    assertThat(process.getStages()).hasSize(5);
    assertThat(DependencyResolver.getDependsOnStages(process, stage1)).isEmpty();
    assertThat(DependencyResolver.getDependsOnStages(process, stage2).size()).isOne();
    assertThat(DependencyResolver.getDependsOnStages(process, stage3).size()).isEqualTo(2);
    assertThat(DependencyResolver.getDependsOnStages(process, stage4).size()).isOne();
    assertThat(DependencyResolver.getDependsOnStages(process, stage5).size()).isEqualTo(2);
    assertThat(DependencyResolver.getDependsOnStages(process, stage2).contains(stage1)).isTrue();
    assertThat(DependencyResolver.getDependsOnStages(process, stage3).contains(stage1)).isTrue();
    assertThat(DependencyResolver.getDependsOnStages(process, stage3).contains(stage2)).isTrue();
    assertThat(DependencyResolver.getDependsOnStages(process, stage4).contains(stage1)).isTrue();
    assertThat(DependencyResolver.getDependsOnStages(process, stage5).contains(stage1)).isTrue();
    assertThat(DependencyResolver.getDependsOnStages(process, stage5).contains(stage2)).isTrue();
    assertThat(DependencyResolver.getDependentStages(process, stage1).size()).isEqualTo(4);
    assertThat(DependencyResolver.getDependentStages(process, stage2).size()).isEqualTo(2);
    assertThat(DependencyResolver.getDependentStages(process, stage3)).isEmpty();
    assertThat(DependencyResolver.getDependentStages(process, stage4)).isEmpty();
    assertThat(DependencyResolver.getDependentStages(process, stage5)).isEmpty();
    assertThat(DependencyResolver.getDependentStages(process, stage1).contains(stage2)).isTrue();
    assertThat(DependencyResolver.getDependentStages(process, stage1).contains(stage3)).isTrue();
    assertThat(DependencyResolver.getDependentStages(process, stage1).contains(stage4)).isTrue();
    assertThat(DependencyResolver.getDependentStages(process, stage1).contains(stage5)).isTrue();
    assertThat(DependencyResolver.getDependentStages(process, stage2).contains(stage3)).isTrue();
    assertThat(DependencyResolver.getDependentStages(process, stage2).contains(stage5)).isTrue();
}
Also used : ProcessBuilder(pipelite.process.builder.ProcessBuilder) Stage(pipelite.stage.Stage) Test(org.junit.jupiter.api.Test)

Example 9 with ProcessBuilder

use of pipelite.process.builder.ProcessBuilder 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)

Example 10 with ProcessBuilder

use of pipelite.process.builder.ProcessBuilder 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)

Aggregations

ProcessBuilder (pipelite.process.builder.ProcessBuilder)29 Test (org.junit.jupiter.api.Test)25 Process (pipelite.process.Process)24 Stage (pipelite.stage.Stage)21 StageState (pipelite.stage.StageState)13 ProcessEntity (pipelite.entity.ProcessEntity)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ArrayList (java.util.ArrayList)3 StageEntity (pipelite.entity.StageEntity)3 StageLogEntity (pipelite.entity.StageLogEntity)3 Pipeline (pipelite.Pipeline)2 PipeliteException (pipelite.exception.PipeliteException)2 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)2 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 RegisteredPipeline (pipelite.RegisteredPipeline)1