Search in sources :

Example 26 with ProcessBuilder

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"));
    }
}
Also used : StageState(pipelite.stage.StageState) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) StageEntity(pipelite.entity.StageEntity) Test(org.junit.jupiter.api.Test)

Example 27 with ProcessBuilder

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;
}
Also used : StageState(pipelite.stage.StageState) Test(org.junit.jupiter.api.Test) List(java.util.List) ExecutorParameters(pipelite.stage.parameters.ExecutorParameters) ProcessBuilder(pipelite.process.builder.ProcessBuilder) StageEntity(pipelite.entity.StageEntity) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.assertj.core.api.Assertions) Process(pipelite.process.Process) ProcessState(pipelite.process.ProcessState) ArrayList(java.util.ArrayList) Stage(pipelite.stage.Stage) ExecutorParameters(pipelite.stage.parameters.ExecutorParameters) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ArrayList(java.util.ArrayList) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) StageEntity(pipelite.entity.StageEntity)

Example 28 with ProcessBuilder

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);
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Pipeline(pipelite.Pipeline) Test(org.junit.jupiter.api.Test)

Example 29 with ProcessBuilder

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;
}
Also used : StageInfo(pipelite.controller.api.info.StageInfo) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ArrayList(java.util.ArrayList) Process(pipelite.process.Process) AtomicReference(java.util.concurrent.atomic.AtomicReference) RegisteredPipeline(pipelite.RegisteredPipeline) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

ProcessBuilder (pipelite.process.builder.ProcessBuilder)29 Test (org.junit.jupiter.api.Test)25 Process (pipelite.process.Process)24 Stage (pipelite.stage.Stage)21 StageState (pipelite.stage.StageState)13 ProcessEntity (pipelite.entity.ProcessEntity)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ArrayList (java.util.ArrayList)3 StageEntity (pipelite.entity.StageEntity)3 StageLogEntity (pipelite.entity.StageLogEntity)3 Pipeline (pipelite.Pipeline)2 PipeliteException (pipelite.exception.PipeliteException)2 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)2 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 RegisteredPipeline (pipelite.RegisteredPipeline)1