use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageExecutorSerializerTest method deserializeExecutionJson.
@Test
public void deserializeExecutionJson() {
StageExecutorResult result = StageExecutorResult.success();
StageEntity stageEntity = new StageEntity();
Stage stage = Stage.builder().stageName("STAGE1").executor(new TestExecutor(StageState.from(result))).build();
stage.setStageEntity(stageEntity);
stageEntity.startExecution();
stageEntity.setExecutorName(TestExecutor.class.getName());
stageEntity.setExecutorData("{\n" + " \"stageState\" : \"" + StageState.from(result).name() + "\"\n}");
stageEntity.setExecutorParams("{\n" + " \"maximumRetries\" : 3,\n" + " \"immediateRetries\" : 3\n" + "}");
assertThat(StageExecutorSerializer.deserializeExecution(stage, StageExecutorSerializer.Deserialize.JSON_EXECUTOR)).isTrue();
assertThat(stage.getExecutor()).isNotNull();
assertThat(stage.getExecutor()).isInstanceOf(TestExecutor.class);
assertThat(((TestExecutor) stage.getExecutor()).getStageState()).isEqualTo(StageState.from(result));
assertThat(stage.getExecutor().getExecutorParams()).isNotNull();
assertThat(stage.getExecutor().getExecutorParams().getImmediateRetries()).isEqualTo(3);
assertThat(stage.getExecutor().getExecutorParams().getMaximumRetries()).isEqualTo(3);
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageExecutorSerializerTest method deserializeExecutionAsync.
@Test
public void deserializeExecutionAsync() {
SimpleLsfExecutor lsfExecutor = StageExecutor.createSimpleLsfExecutor("test");
lsfExecutor.setJobId("test");
SimpleLsfExecutorParameters params = new SimpleLsfExecutorParameters();
params.setHost("host");
params.setQueue("queue");
lsfExecutor.setExecutorParams(params);
StageEntity stageEntity = new StageEntity();
Stage stage = Stage.builder().stageName("STAGE1").executor(lsfExecutor).build();
stage.setStageEntity(stageEntity);
stageEntity.startExecution();
StageService.prepareSaveStage(stage);
assertThat(StageExecutorSerializer.deserializeExecution(stage, StageExecutorSerializer.Deserialize.ASYNC_EXECUTOR)).isTrue();
assertThat(stage.getExecutor()).isNotNull();
assertThat(stage.getExecutor()).isInstanceOf(SimpleLsfExecutor.class);
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.executor.SimpleLsfExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"jobId\" : \"test\",\n" + " \"cmd\" : \"test\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 604800000,\n" + " \"maximumRetries\" : 3,\n" + " \"immediateRetries\" : 3,\n" + " \"logLines\" : 1000,\n" + " \"host\" : \"host\",\n" + " \"logTimeout\" : 10000,\n" + " \"queue\" : \"queue\"\n" + "}");
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class ScheduleRunnerTest method assertStageEntities.
private void assertStageEntities(TestSchedule f, String processId) {
String pipelineName = f.pipelineName();
TestProcessConfiguration t = f.getTestProcessConfiguration();
for (int i = 0; i < t.stageCnt; ++i) {
StageEntity stageEntity = stageService.getSavedStage(f.pipelineName(), processId, "STAGE" + i).get();
StageLogEntity stageLogEntity = stageService.getSavedStageLog(f.pipelineName(), processId, "STAGE" + i).get();
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getExecutionCount()).isEqualTo(1);
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isNotNull();
assertThat(stageEntity.getStartTime()).isBeforeOrEqualTo(stageEntity.getEndTime());
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.executor.SyncTestExecutor");
assertThat(stageEntity.getExecutorData()).isNull();
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 10000,\n" + " \"maximumRetries\" : 0,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
if (t.stageTestResult == StageTestResult.ERROR) {
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ERROR);
assertThat(stageEntity.getResultParams()).isNull();
} else if (t.stageTestResult == StageTestResult.EXCEPTION) {
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ERROR);
assertThat(stageLogEntity.getStageLog()).contains("java.lang.RuntimeException: Expected exception");
} else {
assertThat(stageEntity.getStageState()).isEqualTo(StageState.SUCCESS);
assertThat(stageEntity.getResultParams()).isNull();
}
}
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class DependencyResolverTest method simulateStageExecution.
private static void simulateStageExecution(Stage stage, StageState stageState) {
StageEntity stageEntity = new StageEntity();
stage.setStageEntity(stageEntity);
stageEntity.setStageState(PENDING);
if (stageState == PENDING) {
return;
}
stageEntity.startExecution();
if (stageState == ACTIVE) {
return;
}
stage.incrementImmediateExecutionCount();
if (stageState == SUCCESS) {
stageEntity.endExecution(StageExecutorResult.success());
} else if (stageState == ERROR) {
stageEntity.endExecution(StageExecutorResult.error());
}
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class DependencyResolverTest method simulatedStageExecution.
private SingleStageProcess simulatedStageExecution(ErrorType errorType, int executionCount, int immediateCount, int maximumRetries, int immediateRetries) {
StageEntity stageEntity = new StageEntity();
stageEntity.setExecutionCount(executionCount);
stageEntity.setStageState(ERROR);
stageEntity.setErrorType(errorType);
SyncTestExecutor executor = StageExecutor.createSyncTestExecutor(StageExecutorState.SUCCESS, null);
executor.setExecutorParams(ExecutorParameters.builder().immediateRetries(immediateRetries).maximumRetries(maximumRetries).build());
Stage stage = Stage.builder().stageName("STAGE").executor(executor).build();
stage.setStageEntity(stageEntity);
for (int i = 0; i < immediateCount; ++i) {
stage.incrementImmediateExecutionCount();
}
return new SingleStageProcess(new Process("TEST", ProcessBuilderHelper.stageGraph(Arrays.asList(new ProcessBuilderHelper.AddedStage(stage)))), stage);
}
Aggregations