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);
}
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");
}
Aggregations