Search in sources :

Example 21 with ProcessBuilder

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

the class DependencyResolverTest method othersActivePendingIndependentOneErrorMaxRetriesLeft.

@Test
public void othersActivePendingIndependentOneErrorMaxRetriesLeft() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR, ExecutorParameters.builder().maximumRetries(1).immediateRetries(0).build()).execute("STAGE2").withSyncTestExecutor().execute("STAGE3").withSyncTestExecutor().execute("STAGE4").withSyncTestExecutor().build();
        Set<Stage> stages = process.getStages();
        int stageNumber = 0;
        for (Stage stage : process.getStages()) {
            if (stageNumber == 0) {
                simulateStageExecution(stage, StageState.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, Collections.emptyList());
        assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE2", "STAGE3", "STAGE4"));
        assertGetEventuallyExecutableStages(process, Arrays.asList("STAGE1", "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 22 with ProcessBuilder

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

the class DependencyResolverTest method allActivePendingDependOnPrevious.

@Test
public void allActivePendingDependOnPrevious() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor().executeAfterPrevious("STAGE2").withSyncTestExecutor().executeAfterPrevious("STAGE3").withSyncTestExecutor().build();
        Set<Stage> stages = process.getStages();
        for (Stage stage : process.getStages()) {
            simulateStageExecution(stage, stageState);
        }
        assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStages(process, "STAGE2", Arrays.asList("STAGE1"));
        assertGetDependsOnStages(process, "STAGE3", Arrays.asList("STAGE1", "STAGE2"));
        assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE2", Arrays.asList("STAGE1"));
        assertGetDependsOnStagesDirectly(process, "STAGE3", Arrays.asList("STAGE2"));
        assertGetDependentStages(process, "STAGE1", Arrays.asList("STAGE2", "STAGE3"));
        assertGetDependentStages(process, "STAGE2", Arrays.asList("STAGE3"));
        assertGetDependentStages(process, "STAGE3", Collections.emptyList());
        assertGetPermanentFailedStages(stages, Collections.emptyList());
        assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE1"));
        assertGetEventuallyExecutableStages(process, Arrays.asList("STAGE1", "STAGE2", "STAGE3"));
    }
}
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 23 with ProcessBuilder

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

the class DependencyResolverTest method othersActivePendingDependOnFirstInErrorNoRetriesLeft.

@Test
public void othersActivePendingDependOnFirstInErrorNoRetriesLeft() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).executeAfter("STAGE2", "STAGE1").withSyncTestExecutor().executeAfter("STAGE3", "STAGE1").withSyncTestExecutor().build();
        Set<Stage> stages = process.getStages();
        int stageNumber = 0;
        for (Stage stage : process.getStages()) {
            if (stageNumber == 0) {
                simulateStageExecution(stage, StageState.ERROR);
            } else {
                simulateStageExecution(stage, stageState);
            }
            stageNumber++;
        }
        assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStages(process, "STAGE2", Arrays.asList("STAGE1"));
        assertGetDependsOnStages(process, "STAGE3", Arrays.asList("STAGE1"));
        assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE2", Arrays.asList("STAGE1"));
        assertGetDependsOnStagesDirectly(process, "STAGE3", Arrays.asList("STAGE1"));
        assertGetDependentStages(process, "STAGE1", Arrays.asList("STAGE2", "STAGE3"));
        assertGetDependentStages(process, "STAGE2", Collections.emptyList());
        assertGetDependentStages(process, "STAGE3", Collections.emptyList());
        assertGetPermanentFailedStages(stages, Arrays.asList("STAGE1"));
        assertGetImmediatelyExecutableStages(process, Collections.emptyList());
        assertGetEventuallyExecutableStages(process, Collections.emptyList());
    }
}
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 24 with ProcessBuilder

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

the class DependencyResolverTest method independentAllPermanentError.

@Test
public void independentAllPermanentError() {
    ProcessBuilder builder = createProcessBuilder();
    Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR).execute("STAGE2").withSyncTestExecutor(StageExecutorState.ERROR).execute("STAGE3").withSyncTestExecutor(StageExecutorState.ERROR).execute("STAGE4").withSyncTestExecutor(StageExecutorState.ERROR).build();
    Set<Stage> stages = process.getStages();
    for (Stage stage : stages) {
        simulateStageExecution(stage, ErrorType.PERMANENT_ERROR);
    }
    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", "STAGE2", "STAGE3", "STAGE4"));
    assertGetImmediatelyExecutableStages(process, Collections.emptyList());
    assertGetEventuallyExecutableStages(process, Collections.emptyList());
}
Also used : ProcessBuilder(pipelite.process.builder.ProcessBuilder) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test)

Example 25 with ProcessBuilder

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

the class DependencyResolverTest method othersActivePendingIndependentOneErrorNoRetriesLeft.

@Test
public void othersActivePendingIndependentOneErrorNoRetriesLeft() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR, ExecutorParameters.builder().maximumRetries(0).immediateRetries(0).build()).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, StageState.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)

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