use of pipelite.process.Process in project pipelite by enasequence.
the class DependencyResolverTest method independentAllErrorNoRetriesLeft.
@Test
public void independentAllErrorNoRetriesLeft() {
ProcessBuilder builder = createProcessBuilder();
Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).execute("STAGE2").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).execute("STAGE3").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).execute("STAGE4").withSyncTestExecutor(StageExecutorState.ERROR, NO_RETRIES_EXECUTOR_PARAMS).build();
Set<Stage> stages = process.getStages();
for (Stage stage : stages) {
simulateStageExecution(stage, StageState.ERROR);
}
assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE2", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE3", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE4", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE2", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE3", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE4", Collections.emptyList());
assertGetDependentStages(process, "STAGE1", Collections.emptyList());
assertGetDependentStages(process, "STAGE2", Collections.emptyList());
assertGetDependentStages(process, "STAGE3", Collections.emptyList());
assertGetDependentStages(process, "STAGE4", Collections.emptyList());
assertGetPermanentFailedStages(stages, Arrays.asList("STAGE1", "STAGE2", "STAGE3", "STAGE4"));
assertGetImmediatelyExecutableStages(process, Collections.emptyList());
assertGetEventuallyExecutableStages(process, Collections.emptyList());
}
use of pipelite.process.Process in project pipelite by enasequence.
the class DependencyResolverTest method othersActivePendingIndependentOnePermanentError.
@Test
public void othersActivePendingIndependentOnePermanentError() {
for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
ProcessBuilder builder = createProcessBuilder();
Process process = builder.execute("STAGE1").withSyncTestExecutor(StageExecutorState.ERROR).execute("STAGE2").withSyncTestExecutor().execute("STAGE3").withSyncTestExecutor().execute("STAGE4").withSyncTestExecutor().build();
Set<Stage> stages = process.getStages();
int stageNumber = 0;
for (Stage stage : stages) {
if (stageNumber == 0) {
simulateStageExecution(stage, ErrorType.PERMANENT_ERROR);
} else {
simulateStageExecution(stage, stageState);
}
stageNumber++;
}
assertGetDependsOnStages(process, "STAGE1", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE2", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE3", Collections.emptyList());
assertGetDependsOnStages(process, "STAGE4", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE1", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE2", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE3", Collections.emptyList());
assertGetDependsOnStagesDirectly(process, "STAGE4", Collections.emptyList());
assertGetDependentStages(process, "STAGE1", Collections.emptyList());
assertGetDependentStages(process, "STAGE2", Collections.emptyList());
assertGetDependentStages(process, "STAGE3", Collections.emptyList());
assertGetDependentStages(process, "STAGE4", Collections.emptyList());
assertGetPermanentFailedStages(stages, Arrays.asList("STAGE1"));
assertGetImmediatelyExecutableStages(process, Arrays.asList("STAGE2", "STAGE3", "STAGE4"));
assertGetEventuallyExecutableStages(process, Arrays.asList("STAGE2", "STAGE3", "STAGE4"));
}
}
use of pipelite.process.Process 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.process.Process in project pipelite by enasequence.
the class ProcessRunnerPoolTest method createProcess.
private Process createProcess(Function<StageExecutorRequest, StageExecutorResult> callback) {
String processId = PipeliteIdCreator.processId();
ExecutorParameters executorParams = new ExecutorParameters();
executorParams.setMaximumRetries(0);
Process process = new ProcessBuilder(processId).execute("STAGE1").withAsyncTestExecutor(callback, executorParams).build();
ProcessEntity processEntity = ProcessEntity.createExecution(PIPELINE_NAME, processId, ProcessEntity.DEFAULT_PRIORITY);
process.setProcessEntity(processEntity);
return process;
}
use of pipelite.process.Process in project pipelite by enasequence.
the class ProcessRunnerPoolTest method testSuccess.
@Test
public void testSuccess() {
AtomicLong lockProcessCnt = new AtomicLong();
AtomicLong unlockProcessCnt = new AtomicLong();
ProcessRunnerPool pool = createProcessRunnerPool(lockProcessCnt, unlockProcessCnt);
AtomicInteger runProcessCnt = new AtomicInteger();
for (int i = 0; i < PROCESS_CNT; i++) {
Process process = createProcess((request) -> StageExecutorResult.success());
pool.runProcess(PIPELINE_NAME, process, (p) -> runProcessCnt.incrementAndGet());
}
while (!pool.isIdle()) {
Time.wait(Duration.ofSeconds(1));
pool.runOneIteration();
}
PipelineMetrics pipelineMetrics = metrics.pipeline(PIPELINE_NAME);
assertThat(runProcessCnt.get()).isEqualTo(PROCESS_CNT);
assertThat(pipelineMetrics.process().getCompletedCount()).isEqualTo(PROCESS_CNT);
assertThat(pipelineMetrics.process().getFailedCount()).isZero();
assertThat(pipelineMetrics.process().getInternalErrorCount()).isZero();
assertThat(metrics.getProcessRunnerPoolOneIterationTimer().mean(TimeUnit.SECONDS)).isLessThan(5);
assertThat(metrics.getProcessRunnerOneIterationTimer().mean(TimeUnit.SECONDS)).isLessThan(5);
assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries())).isEqualTo(PROCESS_CNT);
assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries(), ZonedDateTime.now().minusHours(1))).isEqualTo(PROCESS_CNT);
assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries(), ZonedDateTime.now().plusHours(1))).isZero();
assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getFailedTimeSeries())).isZero();
assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getInternalErrorTimeSeries())).isZero();
assertThat(lockProcessCnt.get()).isEqualTo(PROCESS_CNT);
assertThat(unlockProcessCnt.get()).isEqualTo(PROCESS_CNT);
assertThat(pool.getActiveProcessCount()).isZero();
assertThat(pool.getActiveProcessRunners().size()).isZero();
}
Aggregations