Search in sources :

Example 16 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class AbstractLsfExecutorExtractTest method extractResultFromBhistError.

@Test
public void extractResultFromBhistError() {
    StageExecutorResult result = AbstractLsfExecutor.extractResultFromBhistOutputOrOutFile("Summary of time in seconds spent in various states:\n" + "JOBID   USER    JOB_NAME  PEND    PSUSP   RUN     USUSP   SSUSP   UNKWN   TOTAL\n" + "873209  rasko   fdfs      1       0       0       0       0       0       1\n" + "\n" + "[rasko@noah-login-01 ~]$ bhist -l 873209\n" + "\n" + "Job <873209>, User <rasko>, Project <default>, Command <fdfs>, Esub <esub>\n" + "Sun Jan 10 17:50:11: Submitted from host <noah-login-01>, to Queue <research-rh\n" + "                     74>, CWD <$HOME>, Requested Resources <rusage[numcpus=1:du\n" + "                     ration=480]>;\n" + "Sun Jan 10 17:50:12: Dispatched to <hx-noah-10-04>, Effective RES_REQ <select[t\n" + "                     ype == local] order[r15s:pg] rusage[numcpus=1.00:duration=\n" + "                     8h:decay=0] span[hosts=1] >;\n" + "Sun Jan 10 17:50:12: Starting (Pid 87178);\n" + "Sun Jan 10 17:50:12: Running with execution home </homes/rasko>, Execution CWD\n" + "                     </homes/rasko>, Execution Pid <87178>;\n" + "Sun Jan 10 17:50:12: Exited with exit code 127. The CPU time used is 0.0 second\n" + "                     s;\n" + "Sun Jan 10 17:50:12: Completed <exit>;\n" + "\n" + "\n" + " CORELIMIT\n" + "      0 M\n" + "\n" + "Summary of time in seconds spent in various states by  Sun Jan 10 17:50:12\n" + "  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL\n" + "  1        0        0        0        0        0        1");
    assertThat(result.isError()).isTrue();
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) Test(org.junit.jupiter.api.Test)

Example 17 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class AbstractLsfExecutorExtractTest method extractResultFromBhistSuccess.

@Test
public void extractResultFromBhistSuccess() {
    StageExecutorResult result = AbstractLsfExecutor.extractResultFromBhistOutputOrOutFile("Job <872795>, User <rasko>, Project <default>, Command <echo hello>, Esub <esub\n" + "                     >\n" + "Sun Jan 10 17:47:38: Submitted from host <noah-login-01>, to Queue <research-rh\n" + "                     74>, CWD <$HOME>, Requested Resources <rusage[numcpus=1:du\n" + "                     ration=480]>;\n" + "Sun Jan 10 17:47:39: Dispatched to <hx-noah-05-14>, Effective RES_REQ <select[t\n" + "                     ype == local] order[r15s:pg] rusage[numcpus=1.00:duration=\n" + "                     8h:decay=0] span[hosts=1] >;\n" + "Sun Jan 10 17:47:39: Starting (Pid 110245);\n" + "Sun Jan 10 17:47:39: Running with execution home </homes/rasko>, Execution CWD\n" + "                     </homes/rasko>, Execution Pid <110245>;\n" + "Sun Jan 10 17:47:39: Done successfully. The CPU time used is 0.0 seconds;\n" + "Sun Jan 10 17:47:40: Post job process done successfully;\n" + "\n" + "\n" + " CORELIMIT\n" + "      0 M\n" + "\n" + "Summary of time in seconds spent in various states by  Sun Jan 10 17:47:40\n" + "  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL\n" + "  1        0        0        0        0        0        1");
    assertThat(result.isSuccess()).isTrue();
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) Test(org.junit.jupiter.api.Test)

Example 18 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class AbstractLsfExecutorExtractTest method extractResultFromOutFileSuccess.

@Test
public void extractResultFromOutFileSuccess() {
    StageExecutorResult result = AbstractLsfExecutor.extractResultFromBhistOutputOrOutFile("\n" + "\n" + "Job <echo test> was submitted from host <noah-login-02> by user <rasko> in cluster <EBI> at Sun Jan 24 18:03:50 2021\n" + "Job was executed on host(s) <hx-noah-51-01>, in queue <research-rh74>, as user <rasko> in cluster <EBI> at Sun Jan 24 18:03:51 2021\n" + "</homes/rasko> was used as the home directory.\n" + "</homes/rasko> was used as the working directory.\n" + "Started at Sun Jan 24 18:03:51 2021\n" + "Terminated at Sun Jan 24 18:03:51 2021\n" + "Results reported at Sun Jan 24 18:03:51 2021\n" + "\n" + "Your job looked like:\n" + "\n" + "------------------------------------------------------------\n" + "# LSBATCH: User input\n" + "echo test\n" + "------------------------------------------------------------\n" + "\n" + "Successfully completed.\n" + "\n" + "Resource usage summary:\n" + "\n" + "    CPU time :                                   0.01 sec.\n" + "    Max Memory :                                 -\n" + "    Average Memory :                             -\n" + "    Total Requested Memory :                     -\n" + "    Delta Memory :                               -\n" + "    Max Swap :                                   -\n" + "    Max Processes :                              -\n" + "    Max Threads :                                -\n" + "    Run time :                                   0 sec.\n" + "    Turnaround time :                            1 sec.\n" + "\n" + "The output (if any) follows:\n" + "\n" + "test\n" + "\n");
    assertThat(result.isSuccess()).isTrue();
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) Test(org.junit.jupiter.api.Test)

Example 19 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class AsyncExecutorTestHelper method testExecute.

public static void testExecute(AbstractAsyncExecutor<?, ?> executor, PipeliteExecutorService pipeliteExecutorService, DescribeJobsCacheService describeJobsCacheService, PipeliteMetrics pipeliteMetrics, StageExecutorResultCallback assertAfterSubmit, StageExecutorResultCallback assertAfterPoll) {
    String pipelineName = PipeliteIdCreator.pipelineName();
    String processId = PipeliteIdCreator.processId();
    String stageName = PipeliteIdCreator.stageName();
    Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
    StageExecutorRequest request = StageExecutorRequest.builder().pipelineName(pipelineName).processId(processId).stage(stage).build();
    executor.setSubmitExecutorService(pipeliteExecutorService.submitStage());
    executor.setDescribeJobsService(describeJobsCacheService);
    executor.setStageMetrics(pipeliteMetrics.pipeline(pipelineName).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().isSubmitted()).isTrue();
    assertAfterSubmit.accept(result.get());
    while (!result.get().isSuccess() && !result.get().isError()) {
        executor.execute(request, (r) -> result.set(r));
        Time.wait(Duration.ofSeconds(1));
    }
    // Ignore timeout errors.
    if (result.get().isErrorType(ErrorType.TIMEOUT_ERROR)) {
        return;
    }
    assertAfterPoll.accept(result.get());
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) StageExecutorRequest(pipelite.stage.executor.StageExecutorRequest) Stage(pipelite.stage.Stage) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 20 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class TestType method spyStageService.

public static void spyStageService(StageService stageServiceSpy) {
    if (!Mockito.mockingDetails(stageServiceSpy).isSpy()) {
        throw new RuntimeException("StageService must be a spy");
    }
    // Last and next exit code
    doAnswer(invocation -> {
        StageEntity stageEntity = (StageEntity) invocation.callRealMethod();
        AtomicReference<TestType> testTypeRef = new AtomicReference<>();
        handleErrors(testTypeRef, () -> {
            Stage stage = invocation.getArgument(0);
            StageExecutorResult result = invocation.getArgument(1);
            StageMapKey key = registeredKey(stage);
            TestType testType = testType(key);
            testTypeRef.set(testType);
            String lastExitCode = result.getAttribute(StageExecutorResultAttribute.EXIT_CODE);
            if (lastExitCode == null) {
                testType.failedAsserts.add("Stage has no exit code");
            } else if (!lastExitCode.equals(stageNextExitCode.get(key))) {
                testType.failedAsserts.add("Unexpected stage exit code " + lastExitCode + " and not " + stageNextExitCode.get(key));
            }
            setLastExitCode(lastExitCode, key);
            setNextExitCode(testType, stage, key);
        });
        return stageEntity;
    }).when(stageServiceSpy).endExecution(any(), any());
    // Stage deserialization
    doAnswer(invocation -> {
        Stage stage = invocation.getArgument(0);
        StageEntity savedStageEntity = (StageEntity) invocation.callRealMethod();
        AtomicReference<TestType> testTypeRef = new AtomicReference<>();
        handleErrors(testTypeRef, () -> {
            StageMapKey key = registeredKey(stage);
            TestType testType = testType(key);
            testTypeRef.set(testType);
            if (!stage.getStageEntity().equals(savedStageEntity)) {
                testType.failedAsserts.add("Stage entity " + stage.getStageEntity().toString() + " is different from saved stage entity: " + savedStageEntity.toString());
            }
        });
        return null;
    }).when(stageServiceSpy).saveStage(any());
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) Stage(pipelite.stage.Stage) AtomicReference(java.util.concurrent.atomic.AtomicReference) StageEntity(pipelite.entity.StageEntity)

Aggregations

StageExecutorResult (pipelite.stage.executor.StageExecutorResult)33 Test (org.junit.jupiter.api.Test)14 PipeliteException (pipelite.exception.PipeliteException)5 Stage (pipelite.stage.Stage)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)3 Collectors (java.util.stream.Collectors)3 IntStream (java.util.stream.IntStream)3 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)3 Mockito.mock (org.mockito.Mockito.mock)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ServiceConfiguration (pipelite.configuration.ServiceConfiguration)3 InternalErrorService (pipelite.service.InternalErrorService)3 Pod (io.fabric8.kubernetes.api.model.Pod)2 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 ZonedDateTime (java.time.ZonedDateTime)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 StageEntity (pipelite.entity.StageEntity)2 ContainerStatus (io.fabric8.kubernetes.api.model.ContainerStatus)1