use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessEntityAsserter method assertCompletedProcessEntity.
public static void assertCompletedProcessEntity(ProcessService processService, TestType testType, String pipelineName, String processId) {
ProcessEntity processEntity = processService.getSavedProcess(pipelineName, processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getExecutionCount()).isEqualTo(1);
if (testType.expectedProcessCompletedCnt() > 0) {
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
} else {
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
}
assertThat(processEntity.getStartTime()).isNotNull();
assertThat(processEntity.getEndTime()).isAfterOrEqualTo(processEntity.getStartTime());
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ScheduleRunnerTest method assertProcessEntity.
private void assertProcessEntity(TestSchedule f, String processId) {
String pipelineName = f.pipelineName();
ProcessEntity processEntity = processService.getSavedProcess(f.pipelineName(), processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getExecutionCount()).isEqualTo(1);
TestProcessConfiguration t = f.getTestProcessConfiguration();
if (t.stageTestResult != StageTestResult.SUCCESS) {
assertThat(processEntity.getProcessState()).isEqualTo(// no re-executions allowed
ProcessState.FAILED);
} else {
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
}
}
use of pipelite.entity.ProcessEntity 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.entity.ProcessEntity in project pipelite by enasequence.
the class ScheduleRunnerResumeTest method testResumeSchedules.
@Test
public // @Timeout(value = 10, unit = TimeUnit.SECONDS)
void testResumeSchedules() {
int maxExecution1 = 1;
int maxExecution2 = 1;
// Create two schedules with start time and process id to allow processes to resume.
ZonedDateTime startTime1 = ZonedDateTime.now().minusHours(2).truncatedTo(ChronoUnit.SECONDS);
ZonedDateTime startTime2 = ZonedDateTime.now().minusHours(2).truncatedTo(ChronoUnit.SECONDS);
ZonedDateTime nextTime1 = ZonedDateTime.now().minusMinutes(1).truncatedTo(ChronoUnit.SECONDS);
ZonedDateTime nextTime2 = ZonedDateTime.now().minusHours(1).truncatedTo(ChronoUnit.SECONDS);
ScheduleEntity scheduleEntity1 = pipeliteServices.schedule().getSavedSchedule(resume1.pipelineName()).get();
ScheduleEntity scheduleEntity2 = pipeliteServices.schedule().getSavedSchedule(resume2.pipelineName()).get();
scheduleEntity1.setStartTime(startTime1);
scheduleEntity2.setStartTime(startTime2);
scheduleEntity1.setNextTime(nextTime1);
scheduleEntity2.setNextTime(nextTime2);
String processId1 = "1";
String processId2 = "2";
scheduleEntity1.setProcessId(processId1);
scheduleEntity2.setProcessId(processId2);
pipeliteServices.schedule().saveSchedule(scheduleEntity1);
pipeliteServices.schedule().saveSchedule(scheduleEntity2);
ProcessEntity processEntity1 = ProcessEntity.createExecution(resume1.pipelineName(), processId1, 5);
ProcessEntity processEntity2 = ProcessEntity.createExecution(resume2.pipelineName(), processId2, 5);
pipeliteServices.process().saveProcess(processEntity1);
pipeliteServices.process().saveProcess(processEntity2);
ScheduleRunner scheduleRunner = spy(ScheduleRunnerFactory.create(pipeliteConfiguration, pipeliteServices, pipeliteMetrics, pipeliteServices.registeredPipeline().getRegisteredPipelines(Schedule.class)));
scheduleRunner.setMaximumExecutions(resume1.pipelineName(), maxExecution1);
scheduleRunner.setMaximumExecutions(resume2.pipelineName(), maxExecution2);
// Resume the two processes, check that they are immediately executed
// and that they are scheduled for a later execution.
scheduleRunner.startUp();
while (!scheduleRunner.isIdle()) {
scheduleRunner.runOneIteration();
Time.wait(Duration.ofMillis(100));
}
scheduleEntity1 = pipeliteServices.schedule().getSavedSchedule(resume1.pipelineName()).get();
scheduleEntity2 = pipeliteServices.schedule().getSavedSchedule(resume2.pipelineName()).get();
assertThat(scheduleEntity1.getStartTime()).isEqualTo(startTime1);
assertThat(scheduleEntity2.getStartTime()).isEqualTo(startTime2);
assertThat(scheduleEntity1.getEndTime()).isAfter(startTime1);
assertThat(scheduleEntity2.getEndTime()).isAfter(startTime2);
assertThat(scheduleEntity1.getExecutionCount()).isOne();
assertThat(scheduleEntity2.getExecutionCount()).isOne();
assertThat(scheduleEntity1.getProcessId()).isEqualTo(processId1);
assertThat(scheduleEntity2.getProcessId()).isEqualTo(processId2);
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessFactoryTest method createFailed.
@Test
public void createFailed() {
ProcessEntity processEntity = new ProcessEntity();
processEntity.setProcessId(PROCESS_ID);
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) {
}
};
assertThrows(PipeliteException.class, () -> ProcessFactory.create(processEntity, pipeline));
}
Aggregations