use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class RetryServiceTest method retryFailedProcessNoPermanentlyFailedStages.
@Test
public void retryFailedProcessNoPermanentlyFailedStages() {
String processId = PipeliteIdCreator.processId();
RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(PIPELINE_NAME);
Process process = ProcessFactory.create(processId, registeredPipeline);
// Save failed process
process.setProcessEntity(processService.createExecution(PIPELINE_NAME, processId, 1));
processService.startExecution(process.getProcessEntity());
processService.endExecution(process, ProcessState.FAILED);
// Check failed process
ProcessEntity processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
// Save completed stage
Stage stage = process.getStage(STAGE_NAME).get();
stageService.createExecution(PIPELINE_NAME, processId, stage);
stageService.startExecution(stage);
stageService.endExecution(stage, StageExecutorResult.success());
// Check completed stage
StageEntity stageEntity = stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get();
assertThat(stageEntity.getStageState()).isEqualTo(StageState.SUCCESS);
// Retry
retryService.retry(PIPELINE_NAME, processId);
processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getPriority()).isEqualTo(1);
assertThat(processEntity.getExecutionCount()).isEqualTo(1);
assertThat(processEntity.getStartTime()).isNotNull();
// Made null
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
// Check that stage state is unchanged
stageEntity.equals(stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get());
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class RetryServiceTest method retryFailedProcess.
@Test
public void retryFailedProcess() {
String processId = PipeliteIdCreator.processId();
RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(PIPELINE_NAME);
Process process = ProcessFactory.create(processId, registeredPipeline);
// Failed process
process.setProcessEntity(processService.createExecution(PIPELINE_NAME, processId, 1));
processService.startExecution(process.getProcessEntity());
ProcessEntity processEntity = processService.endExecution(process, ProcessState.FAILED);
// Failed stage
Stage stage = process.getStage(STAGE_NAME).get();
stageService.createExecution(PIPELINE_NAME, processId, stage);
stageService.startExecution(stage);
stageService.endExecution(stage, StageExecutorResult.error());
StageEntity stageEntity = stage.getStageEntity();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.ERROR);
// Retry
retryService.retry(PIPELINE_NAME, processId);
// Check process state
processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
assertThat(processEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getStartTime()).isNotNull();
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
// Check stage state
stageEntity = stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get();
assertThat(stageEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
assertThat(stageEntity.getProcessId()).isEqualTo(processId);
assertThat(stageEntity.getStageName()).isEqualTo(STAGE_NAME);
assertThat(stageEntity.getStageState()).isEqualTo(StageState.PENDING);
assertThat(stageEntity.getStartTime()).isNull();
assertThat(stageEntity.getEndTime()).isNull();
}
use of pipelite.entity.ProcessEntity 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");
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ScheduleServiceTest method isRetryScheduleWithFailedSchedule.
@Test
public void isRetryScheduleWithFailedSchedule() {
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().plusDays(1));
assertThat(scheduleEntity.isFailed()).isTrue();
assertThat(scheduleService.isRetrySchedule(pipelineName, processId)).isTrue();
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ScheduleServiceTest method isRetryScheduleWithDifferentProcessId.
@Test
public void isRetryScheduleWithDifferentProcessId() {
String serviceName = PipeliteIdCreator.serviceName();
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
String differentProcessId = 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, differentProcessId));
assertThat(ex.getMessage()).contains("a newer process execution exists for the schedule");
}
Aggregations