Search in sources :

Example 26 with StageEntity

use of pipelite.entity.StageEntity 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 27 with StageEntity

use of pipelite.entity.StageEntity 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)

Example 28 with StageEntity

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

the class StageExecutorSerializerTest method deserializeExecutorJson.

@Test
public void deserializeExecutorJson() {
    StageExecutorResult result = StageExecutorResult.success();
    StageEntity stageEntity = new StageEntity();
    stageEntity.setExecutorName(TestExecutor.class.getName());
    stageEntity.setExecutorData("{\n" + "  \"stageState\" : \"" + StageState.from(result).name() + "\"\n}");
    Stage stage = Stage.builder().stageName("STAGE1").executor(new TestExecutor(StageState.from(result))).build();
    stage.setStageEntity(stageEntity);
    StageExecutor deserializedExecutor = StageExecutorSerializer.deserializeExecutor(stage, StageExecutorSerializer.Deserialize.JSON_EXECUTOR);
    assertThat(deserializedExecutor).isNotNull();
    assertThat(stage.getExecutor()).isInstanceOf(TestExecutor.class);
    assertThat(((TestExecutor) stage.getExecutor()).getStageState()).isEqualTo(StageState.from(result));
}
Also used : Stage(pipelite.stage.Stage) StageEntity(pipelite.entity.StageEntity) Test(org.junit.jupiter.api.Test)

Example 29 with StageEntity

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

the class StageExecutorSerializerTest method deserializeExecutorParams.

@Test
public void deserializeExecutorParams() {
    StageEntity stageEntity = new StageEntity();
    stageEntity.setExecutorParams("{\n" + "  \"maximumRetries\" : 3,\n" + "  \"immediateRetries\" : 3\n" + "}");
    TestExecutor executor = new TestExecutor(StageState.SUCCESS);
    Stage stage = Stage.builder().stageName("STAGE1").executor(executor).build();
    stage.setStageEntity(stageEntity);
    ExecutorParameters deserializedExecutorParams = StageExecutorSerializer.deserializeExecutorParameters(stage, executor.getExecutorParamsType());
    assertThat(deserializedExecutorParams).isNotNull();
    assertThat(deserializedExecutorParams.getImmediateRetries()).isEqualTo(3);
    assertThat(deserializedExecutorParams.getMaximumRetries()).isEqualTo(3);
}
Also used : SimpleLsfExecutorParameters(pipelite.stage.parameters.SimpleLsfExecutorParameters) ExecutorParameters(pipelite.stage.parameters.ExecutorParameters) Stage(pipelite.stage.Stage) StageEntity(pipelite.entity.StageEntity) Test(org.junit.jupiter.api.Test)

Example 30 with StageEntity

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

the class StageEntityAsserter method assertSubmittedSimpleLsfStageEntity.

public static void assertSubmittedSimpleLsfStageEntity(StageService stageService, TestType testType, LsfTestConfiguration lsfTestConfiguration, String pipelineName, String processId, String stageName) {
    StageEntity stageEntity = assertSubmittedStageEntity(stageService, testType, pipelineName, processId, stageName);
    assertSimpleLsfStageEntity(testType, lsfTestConfiguration, stageEntity);
}
Also used : StageEntity(pipelite.entity.StageEntity)

Aggregations

StageEntity (pipelite.entity.StageEntity)32 Stage (pipelite.stage.Stage)15 Test (org.junit.jupiter.api.Test)11 Process (pipelite.process.Process)8 StageState (pipelite.stage.StageState)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Timed (io.micrometer.core.annotation.Timed)3 ProcessEntity (pipelite.entity.ProcessEntity)3 ProcessBuilder (pipelite.process.builder.ProcessBuilder)3 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)3 StageLogEntity (pipelite.entity.StageLogEntity)2 JsonSerializableExecutor (pipelite.executor.JsonSerializableExecutor)2 SyncTestExecutor (pipelite.executor.SyncTestExecutor)2 StageExecutorResult (pipelite.stage.executor.StageExecutorResult)2 SimpleLsfExecutorParameters (pipelite.stage.parameters.SimpleLsfExecutorParameters)2 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assertions (org.assertj.core.api.Assertions)1