Search in sources :

Example 6 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class DependencyResolverTest method othersActivePendingDependOnFirstInPermanentError.

@Test
public void othersActivePendingDependOnFirstInPermanentError() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR).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, ErrorType.PERMANENT_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 7 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class DependencyResolverTest method othersActivePendingDependOnFirstThatSucceeded.

@Test
public void othersActivePendingDependOnFirstThatSucceeded() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor().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.SUCCESS);
            } 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, Collections.emptyList());
        assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE2", "STAGE3"));
        assertGetEventuallyExecutableStages(process, Arrays.asList("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 8 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class DependencyResolverTest method allActivePendingOthersDependOnFirstTransitively.

@Test
public void allActivePendingOthersDependOnFirstTransitively() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor().executeAfter("STAGE2", "STAGE1").withSyncTestExecutor().executeAfter("STAGE3", Arrays.asList("STAGE2")).withSyncTestExecutor().executeAfter("STAGE4", Arrays.asList("STAGE3", "STAGE3")).withSyncTestExecutor().build();
        Set<Stage> stages = process.getStages();
        for (Stage stage : stages) {
            stage.setStageEntity(new StageEntity());
            stage.getStageEntity().setStageState(stageState);
        }
        assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStages(process, "STAGE2", Arrays.asList("STAGE1"));
        assertGetDependsOnStages(process, "STAGE3", Arrays.asList("STAGE1", "STAGE2"));
        assertGetDependsOnStages(process, "STAGE4", Arrays.asList("STAGE1", "STAGE2", "STAGE3"));
        assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
        assertGetDependsOnStagesDirectly(process, "STAGE2", Arrays.asList("STAGE1"));
        assertGetDependsOnStagesDirectly(process, "STAGE3", Arrays.asList("STAGE2"));
        assertGetDependsOnStagesDirectly(process, "STAGE4", Arrays.asList("STAGE3"));
        assertGetDependentStages(process, "STAGE1", Arrays.asList("STAGE2", "STAGE3", "STAGE4"));
        assertGetDependentStages(process, "STAGE2", Arrays.asList("STAGE3", "STAGE4"));
        assertGetDependentStages(process, "STAGE3", Arrays.asList("STAGE4"));
        assertGetDependentStages(process, "STAGE4", Collections.emptyList());
        assertGetPermanentFailedStages(stages, Collections.emptyList());
        assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE1"));
        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) StageEntity(pipelite.entity.StageEntity) Test(org.junit.jupiter.api.Test)

Example 9 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class DependencyResolverTest method othersActivePendingDependOnFirstInErrorMaxRetriesLeft.

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

use of pipelite.stage.Stage in project pipelite by enasequence.

the class DependencyResolverTest method independentAllErrorNoRetriesLeft.

@Test
public void independentAllErrorNoRetriesLeft() {
    ProcessBuilder builder = createProcessBuilder();
    Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).execute("STAGE2").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).execute("STAGE3").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).execute("STAGE4").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).build();
    Set<Stage> stages = process.getStages();
    for (Stage stage : stages) {
        simulateStageExecution(stage, StageState.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)

Aggregations

Stage (pipelite.stage.Stage)62 Test (org.junit.jupiter.api.Test)49 Process (pipelite.process.Process)28 ProcessBuilder (pipelite.process.builder.ProcessBuilder)21 StageEntity (pipelite.entity.StageEntity)15 StageState (pipelite.stage.StageState)15 StageExecutorRequest (pipelite.stage.executor.StageExecutorRequest)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 ProcessEntity (pipelite.entity.ProcessEntity)9 SimpleLsfExecutorParameters (pipelite.stage.parameters.SimpleLsfExecutorParameters)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 StageExecutorResult (pipelite.stage.executor.StageExecutorResult)6 StageLogEntity (pipelite.entity.StageLogEntity)5 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)3 ZonedDateTime (java.time.ZonedDateTime)2 Flogger (lombok.extern.flogger.Flogger)2 InternalErrorHandler (pipelite.error.InternalErrorHandler)2 SimpleLsfExecutor (pipelite.executor.SimpleLsfExecutor)2 SyncTestExecutor (pipelite.executor.SyncTestExecutor)2 ProcessState (pipelite.process.ProcessState)2