use of pipelite.stage.Stage in project pipelite by enasequence.
the class MailServiceTest method sendFailedStageExecutionMessageWithNoLog.
@Test
public void sendFailedStageExecutionMessageWithNoLog() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
Process process = new ProcessBuilder(processId).execute("STAGE1").withSyncTestExecutor().build();
Stage stage = process.getStage("STAGE1").get();
StageEntity.createExecution(pipelineName, processId, stage).setStageState(StageState.ERROR);
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName(pipelineName);
processEntity.setProcessId(processId);
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
process.setProcessEntity(processEntity);
assertThat(mailService.getStageExecutionSubject(process, stage)).isEqualTo("Pipelite stage (ERROR): " + pipelineName + "/" + processId + "/STAGE1");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"ERROR\",\n" + " \"executionCount\" : 0\n" + "}\n" + "\n" + "Error logs:\n" + "---------------\n");
}
use of pipelite.stage.Stage in project pipelite by enasequence.
the class AbstractAsyncExecutorTest method executeSubmitException.
@Test
public void executeSubmitException() {
AbstractAsyncExecutor executor = executor();
doThrow(new RuntimeException("test exception")).when(executor).submit(any());
Stage stage = new Stage(STAGE_NAME, executor);
StageExecutorRequest request = new StageExecutorRequest(PIPELINE_NAME, PROCESS_ID, stage);
AtomicReference<StageExecutorResult> result = new AtomicReference<>();
executor.execute(request, (r) -> result.set(r));
while (result.get() == null) {
Time.wait(Duration.ofSeconds(1));
}
assertThat(result.get().isError()).isTrue();
assertThat(result.get().isErrorType(ErrorType.INTERNAL_ERROR)).isTrue();
assertThat(result.get().getStageLog()).contains("java.lang.RuntimeException: test exception");
}
use of pipelite.stage.Stage in project pipelite by enasequence.
the class AbstractLsfExecutorFilesTest method resolveDefaultLogFile.
@Test
public void resolveDefaultLogFile() {
TestLsfExecutor executor = new TestLsfExecutor();
Stage stage = Stage.builder().stageName("STAGE_NAME").executor(executor).build();
StageExecutorRequest request = StageExecutorRequest.builder().pipelineName("PIPELINE_NAME").processId("PROCESS_ID").stage(stage).build();
AbstractLsfExecutorParameters params = AbstractLsfExecutorParameters.builder().build();
assertThat(params.resolveLogFile(request, LsfFilePathResolver.Format.WITH_LSF_PATTERN)).isEqualTo("%U/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.out");
params = AbstractLsfExecutorParameters.builder().user("user").build();
assertThat(params.resolveLogFile(request, LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN)).isEqualTo("user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.out");
}
use of pipelite.stage.Stage in project pipelite by enasequence.
the class AbstractLsfExecutorFilesTest method resolveDefaultLogDir.
@Test
public void resolveDefaultLogDir() {
TestLsfExecutor executor = new TestLsfExecutor();
Stage stage = Stage.builder().stageName("STAGE_NAME").executor(executor).build();
StageExecutorRequest request = StageExecutorRequest.builder().pipelineName("PIPELINE_NAME").processId("PROCESS_ID").stage(stage).build();
AbstractLsfExecutorParameters params = AbstractLsfExecutorParameters.builder().build();
assertThat(params.resolveLogDir(request, LsfFilePathResolver.Format.WITH_LSF_PATTERN)).isEqualTo("%U/PIPELINE_NAME/PROCESS_ID");
params = AbstractLsfExecutorParameters.builder().user("user").build();
assertThat(params.resolveLogDir(request, LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN)).isEqualTo("user/PIPELINE_NAME/PROCESS_ID");
}
use of pipelite.stage.Stage 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());
}
Aggregations