Search in sources :

Example 61 with Stage

use of pipelite.stage.Stage 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 62 with Stage

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

the class TestTypeTest method next.

@Test
public void next() {
    TestType testType = TestType.nonPermanentErrorAndThenSuccess;
    String pipelineName = PipeliteIdCreator.pipelineName();
    String processId = PipeliteIdCreator.processId();
    String stageName = PipeliteIdCreator.stageName();
    testType.register(pipelineName, processId, stageName);
    assertThatThrownBy(() -> testType.lastExitCode(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
    assertThatThrownBy(() -> testType.lastCmd(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
    assertThatThrownBy(() -> testType.lastImageArgs(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
    assertThat(testType.nextExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR));
    assertThat(testType.nextCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_NON_PERMANENT_ERROR + "'");
    assertThat(testType.nextImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_NON_PERMANENT_ERROR);
    assertThat(testType.permanentErrors()).containsExactly(EXIT_CODE_PERMANENT_ERROR);
    SimpleLsfExecutor executor = new SimpleLsfExecutor();
    Stage stage = new Stage(stageName, executor);
    TestType.setLastExitCode(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR), pipelineName, processId, stageName);
    TestType.setNextExitCode(testType, stage, pipelineName, processId, stageName);
    assertThat(testType.lastExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR));
    assertThat(testType.lastCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_NON_PERMANENT_ERROR + "'");
    assertThat(testType.lastImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_NON_PERMANENT_ERROR);
    assertThat(testType.nextExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_SUCCESS));
    assertThat(testType.nextCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
    assertThat(testType.nextImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_SUCCESS);
    assertThat(executor.getCmd()).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
    TestType.setLastExitCode(String.valueOf(EXIT_CODE_SUCCESS), pipelineName, processId, stageName);
    TestType.setNextExitCode(testType, stage, pipelineName, processId, stageName);
    assertThat(testType.lastExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_SUCCESS));
    assertThat(testType.lastCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
    assertThat(testType.lastImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_SUCCESS);
    assertThatThrownBy(() -> testType.nextExitCode(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
    assertThatThrownBy(() -> testType.nextCmd(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
    assertThatThrownBy(() -> testType.nextImageArgs(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
}
Also used : Stage(pipelite.stage.Stage) TestType(pipelite.tester.TestType) SimpleLsfExecutor(pipelite.executor.SimpleLsfExecutor) 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