use of pipelite.entity.ScheduleEntity in project pipelite by enasequence.
the class TestTypeScheduleRunner method deleteSchedule.
private <T extends SingleStageTestProcessConfiguration> void deleteSchedule(ConfigurableTestSchedule<T> schedule) {
ScheduleEntity scheduleEntity = new ScheduleEntity();
scheduleEntity.setPipelineName(schedule.pipelineName());
scheduleService.delete(scheduleEntity);
System.out.println("deleted schedule for pipeline: " + schedule.pipelineName());
}
use of pipelite.entity.ScheduleEntity in project pipelite by enasequence.
the class ScheduleRunnerTest method assertScheduleEntity.
private void assertScheduleEntity(List<ScheduleEntity> scheduleEntities, TestSchedule f) {
String pipelineName = f.pipelineName();
assertThat(scheduleEntities.stream().filter(e -> e.getPipelineName().equals(f.pipelineName())).count()).isEqualTo(1);
ScheduleEntity scheduleEntity = scheduleEntities.stream().filter(e -> e.getPipelineName().equals(f.pipelineName())).findFirst().get();
assertThat(scheduleEntity.getServiceName()).isEqualTo(serviceConfiguration.getName());
assertThat(scheduleEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(scheduleEntity.getProcessId()).isNotNull();
assertThat(scheduleEntity.getExecutionCount()).isEqualTo(f.processCnt);
assertThat(scheduleEntity.getStartTime()).isNotNull();
assertThat(scheduleEntity.getEndTime()).isNotNull();
}
use of pipelite.entity.ScheduleEntity 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.ScheduleEntity in project pipelite by enasequence.
the class RetryServiceTest method clean.
@AfterEach
public void clean() {
ScheduleEntity scheduleEntity = new ScheduleEntity();
scheduleEntity.setPipelineName(SCHEDULE_NAME);
scheduleService.delete(scheduleEntity);
}
use of pipelite.entity.ScheduleEntity in project pipelite by enasequence.
the class ScheduleServiceTest method isRetryScheduleWithNewExecutionWithinRetryMargin.
@Test
public void isRetryScheduleWithNewExecutionWithinRetryMargin() {
String serviceName = PipeliteIdCreator.serviceName();
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
String cron = PipeliteTestConstants.CRON_EVERY_TWO_SECONDS;
ScheduleEntity scheduleEntity = scheduleService.createSchedule(serviceName, pipelineName, cron);
assertThat(scheduleEntity.isFailed()).isFalse();
scheduleEntity = scheduleService.startExecution(pipelineName, processId);
assertThat(scheduleEntity.isFailed()).isFalse();
ProcessEntity processEntity = ProcessEntity.createExecution(pipelineName, processId, 1);
processEntity.endExecution(ProcessState.FAILED);
scheduleEntity = scheduleService.endExecution(processEntity, ZonedDateTime.now());
assertThat(scheduleEntity.isFailed()).isTrue();
PipeliteProcessRetryException ex = assertThrows(PipeliteProcessRetryException.class, () -> scheduleService.isRetrySchedule(pipelineName, processId));
assertThat(ex.getMessage()).contains("the next process for the schedule will be executed in less than");
}
Aggregations