use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class DependencyResolverTest method allActivePendingOthersDependOnPrevious.
@Test
public void allActivePendingOthersDependOnPrevious() {
for (StageState stageState : EnumSet.of(ACTIVE, PENDING)) {
ProcessBuilder builder = createProcessBuilder();
Process process = builder.execute("STAGE1").withSyncTestExecutor().executeAfterPrevious("STAGE2").withSyncTestExecutor().executeAfterPrevious("STAGE3").withSyncTestExecutor().executeAfterPrevious("STAGE4").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.process.builder.ProcessBuilder in project pipelite by enasequence.
the class ProcessRunnerTest method twoIndependentStagesProcess.
public static Process twoIndependentStagesProcess(StageState firstStageState, StageState secondStageState, int firstStageExecutions, int secondStageExecutions, int maximumRetries, int immediateRetries) {
ExecutorParameters executorParams = ExecutorParameters.builder().maximumRetries(maximumRetries).immediateRetries(immediateRetries).build();
Process process = new ProcessBuilder("pipelite-test").execute("STAGE0").withSyncTestExecutor((request) -> null, executorParams).execute("STAGE1").withSyncTestExecutor((request) -> null, executorParams).build();
List<Stage> stages = new ArrayList<>();
Stage firstStage = process.getStage("STAGE0").get();
StageEntity firstStageEntity = new StageEntity();
firstStage.setStageEntity(firstStageEntity);
firstStageEntity.setStageState(firstStageState);
firstStageEntity.setExecutionCount(firstStageExecutions);
for (int i = 0; i < firstStageExecutions; ++i) {
firstStage.incrementImmediateExecutionCount();
}
stages.add(firstStage);
Stage secondStage = process.getStage("STAGE1").get();
StageEntity secondStageEntity = new StageEntity();
secondStage.setStageEntity(secondStageEntity);
secondStageEntity.setStageState(secondStageState);
secondStageEntity.setExecutionCount(secondStageExecutions);
for (int i = 0; i < secondStageExecutions; ++i) {
secondStage.incrementImmediateExecutionCount();
}
stages.add(secondStage);
return process;
}
use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class ProcessFactoryTest method createSuccess.
@Test
public void createSuccess() {
ProcessEntity processEntity = new ProcessEntity();
processEntity.setProcessId(PROCESS_ID);
processEntity.setPipelineName(PIPELINE_NAME);
Pipeline pipeline = new Pipeline() {
@Override
public String pipelineName() {
return PIPELINE_NAME;
}
@Override
public Options configurePipeline() {
return new Options().pipelineParallelism(5);
}
@Override
public void configureProcess(ProcessBuilder builder) {
builder.execute("STAGE1").withSyncTestExecutor();
}
};
Process process = ProcessFactory.create(processEntity, pipeline);
assertThat(process).isNotNull();
assertThat(process.getProcessId()).isEqualTo(PROCESS_ID);
assertThat(process.getProcessEntity()).isNotNull();
assertThat(process.getProcessEntity()).isSameAs(processEntity);
}
use of pipelite.process.builder.ProcessBuilder in project pipelite by enasequence.
the class StageController method stages.
@GetMapping("/{pipelineName}/{processId}")
@ResponseStatus(HttpStatus.OK)
@Operation(description = "Process stages")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "500", description = "Internal Server error") })
public List<StageInfo> stages(@PathVariable(value = "pipelineName") String pipelineName, @PathVariable(value = "processId") String processId) {
List<StageInfo> list = new ArrayList<>();
AtomicReference<Process> process = new AtomicReference<>();
try {
RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(pipelineName);
ProcessBuilder processBuilder = new ProcessBuilder(processId);
registeredPipeline.configureProcess(processBuilder);
process.set(processBuilder.build());
} catch (Exception ex) {
log.atSevere().withCause(ex).log(ex.getMessage());
}
stageService.getSavedStages(pipelineName, processId).forEach(stageEntity -> list.add(getStage(stageEntity, process.get())));
return list;
}
Aggregations