Search in sources :

Example 6 with StageLogEntity

use of pipelite.entity.StageLogEntity in project pipelite by enasequence.

the class MailServiceTest method sendFailedStageExecutionMessageWithNullLog.

@Test
public void sendFailedStageExecutionMessageWithNullLog() {
    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);
    StageLogEntity stageLogEntity = new StageLogEntity();
    stageLogEntity.setPipelineName(pipelineName);
    stageLogEntity.setProcessId(processId);
    stageLogEntity.setStageName("STAGE1");
    stageLogEntity.setStageLog(null);
    stageService.saveStageLog(stageLogEntity);
    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");
}
Also used : StageLogEntity(pipelite.entity.StageLogEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ProcessEntity(pipelite.entity.ProcessEntity) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with StageLogEntity

use of pipelite.entity.StageLogEntity in project pipelite by enasequence.

the class MailServiceTest method sendFailedStageExecutionMessageWithLog.

@Test
public void sendFailedStageExecutionMessageWithLog() {
    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);
    StageLogEntity stageLogEntity = new StageLogEntity();
    stageLogEntity.setPipelineName(pipelineName);
    stageLogEntity.setProcessId(processId);
    stageLogEntity.setStageName("STAGE1");
    stageLogEntity.setStageLog("TEST");
    stageService.saveStageLog(stageLogEntity);
    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" + "\n" + "Stage: STAGE1\n" + "===============\n" + "TEST\n");
}
Also used : StageLogEntity(pipelite.entity.StageLogEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) ProcessEntity(pipelite.entity.ProcessEntity) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

StageLogEntity (pipelite.entity.StageLogEntity)7 Stage (pipelite.stage.Stage)5 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 ProcessEntity (pipelite.entity.ProcessEntity)4 Process (pipelite.process.Process)4 ProcessBuilder (pipelite.process.builder.ProcessBuilder)3 StageEntity (pipelite.entity.StageEntity)2 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 Optional (java.util.Optional)1 Flogger (lombok.extern.flogger.Flogger)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)1 JavaMailSender (org.springframework.mail.javamail.JavaMailSender)1 Component (org.springframework.stereotype.Component)1 AdvancedConfiguration (pipelite.configuration.AdvancedConfiguration)1 MailConfiguration (pipelite.configuration.MailConfiguration)1 ServiceConfiguration (pipelite.configuration.ServiceConfiguration)1 LogInfo (pipelite.controller.api.info.LogInfo)1