use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageEntityAsserter method assertCompletedCmdStageEntity.
public static void assertCompletedCmdStageEntity(StageService stageService, TestType testType, String pipelineName, String processId, String stageName) {
String exitCode = testType.lastExitCode(pipelineName, processId, stageName);
StageEntity stageEntity = assertCompletedStageEntity(stageService, testType, pipelineName, processId, stageName);
assertCmdStageEntity(testType, stageEntity);
assertThat(stageEntity.getResultParams()).contains("\"exit code\" : \"" + exitCode + "\"");
assertThat(stageEntity.getExitCode().toString()).isEqualTo(exitCode);
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageEntityAsserter method assertSubmittedStageEntity.
private static StageEntity assertSubmittedStageEntity(StageService stageService, TestType testType, String pipelineName, String processId, String stageName) {
StageEntity stageEntity = stageService.getSavedStage(pipelineName, processId, stageName).get();
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ACTIVE);
assertThat(stageEntity.getErrorType()).isNull();
assertThat(stageEntity.getExecutionCount()).isZero();
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isNull();
return stageEntity;
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageEntityAsserter method assertCompletedSimpleLsfStageEntity.
public static void assertCompletedSimpleLsfStageEntity(StageService stageService, TestType testType, LsfTestConfiguration lsfTestConfiguration, String pipelineName, String processId, String stageName) {
String exitCode = testType.lastExitCode(pipelineName, processId, stageName);
StageEntity stageEntity = assertCompletedStageEntity(stageService, testType, pipelineName, processId, stageName);
assertSimpleLsfStageEntity(testType, lsfTestConfiguration, stageEntity);
assertThat(stageEntity.getResultParams()).contains("\"exit code\" : \"" + exitCode + "\"");
assertThat(stageEntity.getResultParams()).contains("\"job id\" :");
assertThat(String.valueOf(stageEntity.getExitCode())).isEqualTo(exitCode);
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageEntityAsserter method assertCompletedStageEntity.
private static StageEntity assertCompletedStageEntity(StageService stageService, TestType testType, String pipelineName, String processId, String stageName) {
StageState expectedStageState;
ErrorType expectedErrorType = null;
if (testType.expectedStagePermanentErrorCnt() > 0) {
expectedStageState = StageState.ERROR;
expectedErrorType = ErrorType.PERMANENT_ERROR;
} else if (testType.expectedStageSuccessCnt() > 0) {
expectedStageState = StageState.SUCCESS;
} else {
expectedStageState = StageState.ERROR;
expectedErrorType = ErrorType.EXECUTION_ERROR;
}
StageEntity stageEntity = stageService.getSavedStage(pipelineName, processId, stageName).get();
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getStageState()).isEqualTo(expectedStageState);
assertThat(stageEntity.getErrorType()).isEqualTo(expectedErrorType);
assertThat(stageEntity.getExecutionCount()).isEqualTo(testType.expectedStageExecutionCnt());
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isAfterOrEqualTo(stageEntity.getStartTime());
return stageEntity;
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageServiceTest method lifecycle.
@Test
public void lifecycle() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
String stageName = PipeliteIdCreator.stageName();
TestExecutor executor = new TestExecutor(StageState.SUCCESS);
executor.setExecutorParams(ExecutorParameters.builder().immediateRetries(0).maximumRetries(1).timeout(Duration.ofSeconds(0)).build());
Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
// Create execution.
service.createExecution(pipelineName, processId, stage);
StageEntity stageEntity = stage.getStageEntity();
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getExecutionCount()).isEqualTo(0);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.PENDING);
assertThat(stageEntity.getResultParams()).isNull();
assertThat(stageEntity.getStartTime()).isNull();
assertThat(stageEntity.getEndTime()).isNull();
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.service.StageServiceTest$TestExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"stageState\" : \"SUCCESS\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 0,\n" + " \"maximumRetries\" : 1,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
// Start first execution.
service.startExecution(stage);
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getExecutionCount()).isEqualTo(0);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ACTIVE);
assertThat(stageEntity.getResultParams()).isNull();
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isNull();
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.service.StageServiceTest$TestExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"stageState\" : \"SUCCESS\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 0,\n" + " \"maximumRetries\" : 1,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
assertThat(service.getSavedStage(pipelineName, processId, stageName).get()).isEqualTo(stageEntity);
assertThat(service.getSavedStageLog(pipelineName, processId, stageName)).isNotPresent();
// End first execution.
StageExecutorResult firstExecutionResult = StageExecutorResult.error();
service.endExecution(stage, firstExecutionResult);
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getExecutionCount()).isEqualTo(1);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ERROR);
assertThat(stageEntity.getResultParams()).isNull();
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isNotNull();
assertThat(stageEntity.getStartTime()).isBeforeOrEqualTo(stageEntity.getEndTime());
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.service.StageServiceTest$TestExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"stageState\" : \"SUCCESS\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 0,\n" + " \"maximumRetries\" : 1,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
assertThat(service.getSavedStage(pipelineName, processId, stageName).get()).isEqualTo(stageEntity);
Optional<StageLogEntity> stageLogEntity = service.getSavedStageLog(pipelineName, processId, stageName);
assertThat(stageLogEntity).isPresent();
// Start second execution.
service.startExecution(stage);
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getExecutionCount()).isEqualTo(1);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ACTIVE);
assertThat(stageEntity.getResultParams()).isNull();
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isNull();
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.service.StageServiceTest$TestExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"stageState\" : \"SUCCESS\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 0,\n" + " \"maximumRetries\" : 1,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
assertThat(service.getSavedStage(pipelineName, processId, stageName).get()).isEqualTo(stageEntity);
assertThat(service.getSavedStageLog(pipelineName, processId, stageName)).isNotPresent();
// End second execution.
StageExecutorResult secondExecutionResult = StageExecutorResult.success();
service.endExecution(stage, secondExecutionResult);
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getExecutionCount()).isEqualTo(2);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.SUCCESS);
assertThat(stageEntity.getResultParams()).isNull();
assertThat(stageEntity.getStartTime()).isNotNull();
assertThat(stageEntity.getEndTime()).isNotNull();
assertThat(stageEntity.getStartTime()).isBeforeOrEqualTo(stageEntity.getEndTime());
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.service.StageServiceTest$TestExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"stageState\" : \"SUCCESS\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 0,\n" + " \"maximumRetries\" : 1,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
assertThat(service.getSavedStage(pipelineName, processId, stageName).get()).isEqualTo(stageEntity);
stageLogEntity = service.getSavedStageLog(pipelineName, processId, stageName);
assertThat(stageLogEntity).isPresent();
// Reset execution.
service.resetExecution(stage);
assertThat(stageEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(stageName);
assertThat(stageEntity.getExecutionCount()).isEqualTo(0);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.PENDING);
assertThat(stageEntity.getResultParams()).isNull();
assertThat(stageEntity.getStartTime()).isNull();
assertThat(stageEntity.getEndTime()).isNull();
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.service.StageServiceTest$TestExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"stageState\" : \"SUCCESS\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 0,\n" + " \"maximumRetries\" : 1,\n" + " \"immediateRetries\" : 0,\n" + " \"logLines\" : 1000\n" + "}");
assertThat(service.getSavedStage(pipelineName, processId, stageName).get()).isEqualTo(stageEntity);
assertThat(service.getSavedStageLog(pipelineName, processId, stageName)).isNotPresent();
}
Aggregations