Search in sources :

Example 11 with StageState

use of pipelite.stage.StageState 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 12 with StageState

use of pipelite.stage.StageState 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 13 with StageState

use of pipelite.stage.StageState 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)

Example 14 with StageState

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

the class DependencyResolverTest method allActivePendingOthersDependOnPrevious.

@Test
public void allActivePendingOthersDependOnPrevious() {
    for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
        ProcessBuilder builder = createProcessBuilder();
        Process process = builder.execute("STAGE1").withSyncTestExecutor().executeAfterPrevious("STAGE2").withSyncTestExecutor().executeAfterPrevious("STAGE3").withSyncTestExecutor().executeAfterPrevious("STAGE4").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 15 with StageState

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

the class ProcessRunnerTest method twoIndependentStagesProcess.

public static Process twoIndependentStagesProcess(StageState firstStageState, StageState secondStageState, int firstStageExecutions, int secondStageExecutions, int maximumRetries, int immediateRetries) {
    ExecutorParameters executorParams = ExecutorParameters.builder().maximumRetries(maximumRetries).immediateRetries(immediateRetries).build();
    Process process = new ProcessBuilder("pipelite-test").execute("STAGE0").withSyncTestExecutor((request) -> null, executorParams).execute("STAGE1").withSyncTestExecutor((request) -> null, executorParams).build();
    List<Stage> stages = new ArrayList<>();
    Stage firstStage = process.getStage("STAGE0").get();
    StageEntity firstStageEntity = new StageEntity();
    firstStage.setStageEntity(firstStageEntity);
    firstStageEntity.setStageState(firstStageState);
    firstStageEntity.setExecutionCount(firstStageExecutions);
    for (int i = 0; i < firstStageExecutions; ++i) {
        firstStage.incrementImmediateExecutionCount();
    }
    stages.add(firstStage);
    Stage secondStage = process.getStage("STAGE1").get();
    StageEntity secondStageEntity = new StageEntity();
    secondStage.setStageEntity(secondStageEntity);
    secondStageEntity.setStageState(secondStageState);
    secondStageEntity.setExecutionCount(secondStageExecutions);
    for (int i = 0; i < secondStageExecutions; ++i) {
        secondStage.incrementImmediateExecutionCount();
    }
    stages.add(secondStage);
    return process;
}
Also used : StageState(pipelite.stage.StageState) Test(org.junit.jupiter.api.Test) List(java.util.List) ExecutorParameters(pipelite.stage.parameters.ExecutorParameters) ProcessBuilder(pipelite.process.builder.ProcessBuilder) StageEntity(pipelite.entity.StageEntity) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.assertj.core.api.Assertions) Process(pipelite.process.Process) ProcessState(pipelite.process.ProcessState) ArrayList(java.util.ArrayList) Stage(pipelite.stage.Stage) ExecutorParameters(pipelite.stage.parameters.ExecutorParameters) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ArrayList(java.util.ArrayList) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) StageEntity(pipelite.entity.StageEntity)

Aggregations

StageState (pipelite.stage.StageState)15 Stage (pipelite.stage.Stage)14 Test (org.junit.jupiter.api.Test)13 Process (pipelite.process.Process)13 ProcessBuilder (pipelite.process.builder.ProcessBuilder)13 StageEntity (pipelite.entity.StageEntity)5 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ProcessState (pipelite.process.ProcessState)1 ErrorType (pipelite.stage.executor.ErrorType)1 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)1