use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class DependencyResolverTest method allActivePendingOthersDependOnFirstTransitively.
@Test
public void allActivePendingOthersDependOnFirstTransitively() {
for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
ProcessBuilder builder = createProcessBuilder();
Process process = builder.execute("STAGE1").withSyncTestExecutor().executeAfter("STAGE2", "STAGE1").withSyncTestExecutor().executeAfter("STAGE3", Arrays.asList("STAGE2")).withSyncTestExecutor().executeAfter("STAGE4", Arrays.asList("STAGE3", "STAGE3")).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"));
}
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class DependencyResolverTest method simulateStageExecution.
private static void simulateStageExecution(Stage stage, ErrorType errorType) {
StageEntity stageEntity = new StageEntity();
stage.setStageEntity(stageEntity);
stageEntity.setStageState(ERROR);
stageEntity.startExecution();
stage.incrementImmediateExecutionCount();
stageEntity.endExecution(StageExecutorResult.error().setErrorType(errorType));
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class DependencyResolverTest method simulatedStageExecution.
private SingleStageProcess simulatedStageExecution(StageState stageState, int executionCount, int immediateExecutionCount, int maximumRetries, int immediateRetries) {
StageEntity stageEntity = new StageEntity();
stageEntity.setExecutionCount(executionCount);
stageEntity.setStageState(stageState);
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 < immediateExecutionCount; ++i) {
stage.incrementImmediateExecutionCount();
}
return new SingleStageProcess(new Process("TEST", ProcessBuilderHelper.stageGraph(Arrays.asList(new ProcessBuilderHelper.AddedStage(stage)))), stage);
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class RetryServiceTest method retryFailedProcessNoPermanentlyFailedStages.
@Test
public void retryFailedProcessNoPermanentlyFailedStages() {
String processId = PipeliteIdCreator.processId();
RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(PIPELINE_NAME);
Process process = ProcessFactory.create(processId, registeredPipeline);
// Save failed process
process.setProcessEntity(processService.createExecution(PIPELINE_NAME, processId, 1));
processService.startExecution(process.getProcessEntity());
processService.endExecution(process, ProcessState.FAILED);
// Check failed process
ProcessEntity processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
// Save completed stage
Stage stage = process.getStage(STAGE_NAME).get();
stageService.createExecution(PIPELINE_NAME, processId, stage);
stageService.startExecution(stage);
stageService.endExecution(stage, StageExecutorResult.success());
// Check completed stage
StageEntity stageEntity = stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get();
assertThat(stageEntity.getStageState()).isEqualTo(StageState.SUCCESS);
// Retry
retryService.retry(PIPELINE_NAME, processId);
processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getPriority()).isEqualTo(1);
assertThat(processEntity.getExecutionCount()).isEqualTo(1);
assertThat(processEntity.getStartTime()).isNotNull();
// Made null
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
// Check that stage state is unchanged
stageEntity.equals(stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get());
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class RetryServiceTest method retryFailedProcess.
@Test
public void retryFailedProcess() {
String processId = PipeliteIdCreator.processId();
RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(PIPELINE_NAME);
Process process = ProcessFactory.create(processId, registeredPipeline);
// Failed process
process.setProcessEntity(processService.createExecution(PIPELINE_NAME, processId, 1));
processService.startExecution(process.getProcessEntity());
ProcessEntity processEntity = processService.endExecution(process, ProcessState.FAILED);
// Failed stage
Stage stage = process.getStage(STAGE_NAME).get();
stageService.createExecution(PIPELINE_NAME, processId, stage);
stageService.startExecution(stage);
stageService.endExecution(stage, StageExecutorResult.error());
StageEntity stageEntity = stage.getStageEntity();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ERROR);
// Retry
retryService.retry(PIPELINE_NAME, processId);
// Check process state
processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getStartTime()).isNotNull();
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
// Check stage state
stageEntity = stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get();
assertThat(stageEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(STAGE_NAME);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.PENDING);
assertThat(stageEntity.getStartTime()).isNull();
assertThat(stageEntity.getEndTime()).isNull();
}
Aggregations