Search in sources :

Example 1 with PipelineMetrics

use of pipelite.metrics.PipelineMetrics in project pipelite by enasequence.

the class MetricsTestAsserter method assertCompletedMetrics.

public static void assertCompletedMetrics(TestType testType, PipeliteMetrics metrics, String pipelineName, int processCnt) {
    PipelineMetrics pipelineMetrics = metrics.pipeline(pipelineName);
    // Assuming single stage in process.
    assertThat(pipelineMetrics.process().getCompletedCount()).isEqualTo(processCnt * testType.expectedProcessCompletedCnt());
    assertThat(pipelineMetrics.process().getFailedCount()).isEqualTo(processCnt * testType.expectedProcessFailedCnt());
    assertThat(pipelineMetrics.stage().getFailedCount()).isEqualTo(processCnt * testType.expectedStageFailedCnt());
    assertThat(pipelineMetrics.stage().getSuccessCount()).isEqualTo(processCnt * testType.expectedStageSuccessCnt());
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries())).isEqualTo(processCnt * testType.expectedProcessCompletedCnt());
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getFailedTimeSeries())).isEqualTo(processCnt * testType.expectedProcessFailedCnt());
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.stage().getFailedTimeSeries())).isEqualTo(processCnt * testType.expectedStageFailedCnt());
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.stage().getSuccessTimeSeries())).isEqualTo(processCnt * testType.expectedStageSuccessCnt());
}
Also used : PipelineMetrics(pipelite.metrics.PipelineMetrics)

Example 2 with PipelineMetrics

use of pipelite.metrics.PipelineMetrics in project pipelite by enasequence.

the class PipelineController method getRunningProcessesHistoryPlot.

private String getRunningProcessesHistoryPlot(Duration duration, String type, String id) {
    Collection<Table> tables = new ArrayList<>();
    ZonedDateTime since = ZonedDateTime.now().minus(duration);
    runnerService.getPipelineRunners().forEach(p -> {
        PipelineMetrics metrics = pipeliteMetrics.pipeline(p.getPipelineName());
        addRunningProcessesHistoryTable(metrics, tables, since, type);
    });
    Figure figure = TimeSeriesMetrics.getPlot("", tables);
    return TimeSeriesMetrics.getPlotJavaScript(figure, id);
}
Also used : Table(tech.tablesaw.api.Table) ZonedDateTime(java.time.ZonedDateTime) ArrayList(java.util.ArrayList) PipelineMetrics(pipelite.metrics.PipelineMetrics) Figure(tech.tablesaw.plotly.components.Figure)

Example 3 with PipelineMetrics

use of pipelite.metrics.PipelineMetrics in project pipelite by enasequence.

the class ProcessRunnerPoolTest method testSuccess.

@Test
public void testSuccess() {
    AtomicLong lockProcessCnt = new AtomicLong();
    AtomicLong unlockProcessCnt = new AtomicLong();
    ProcessRunnerPool pool = createProcessRunnerPool(lockProcessCnt, unlockProcessCnt);
    AtomicInteger runProcessCnt = new AtomicInteger();
    for (int i = 0; i < PROCESS_CNT; i++) {
        Process process = createProcess((request) -> StageExecutorResult.success());
        pool.runProcess(PIPELINE_NAME, process, (p) -> runProcessCnt.incrementAndGet());
    }
    while (!pool.isIdle()) {
        Time.wait(Duration.ofSeconds(1));
        pool.runOneIteration();
    }
    PipelineMetrics pipelineMetrics = metrics.pipeline(PIPELINE_NAME);
    assertThat(runProcessCnt.get()).isEqualTo(PROCESS_CNT);
    assertThat(pipelineMetrics.process().getCompletedCount()).isEqualTo(PROCESS_CNT);
    assertThat(pipelineMetrics.process().getFailedCount()).isZero();
    assertThat(pipelineMetrics.process().getInternalErrorCount()).isZero();
    assertThat(metrics.getProcessRunnerPoolOneIterationTimer().mean(TimeUnit.SECONDS)).isLessThan(5);
    assertThat(metrics.getProcessRunnerOneIterationTimer().mean(TimeUnit.SECONDS)).isLessThan(5);
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries())).isEqualTo(PROCESS_CNT);
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries(), ZonedDateTime.now().minusHours(1))).isEqualTo(PROCESS_CNT);
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getCompletedTimeSeries(), ZonedDateTime.now().plusHours(1))).isZero();
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getFailedTimeSeries())).isZero();
    assertThat(TimeSeriesMetrics.getCount(pipelineMetrics.process().getInternalErrorTimeSeries())).isZero();
    assertThat(lockProcessCnt.get()).isEqualTo(PROCESS_CNT);
    assertThat(unlockProcessCnt.get()).isEqualTo(PROCESS_CNT);
    assertThat(pool.getActiveProcessCount()).isZero();
    assertThat(pool.getActiveProcessRunners().size()).isZero();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Process(pipelite.process.Process) PipelineMetrics(pipelite.metrics.PipelineMetrics) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with PipelineMetrics

use of pipelite.metrics.PipelineMetrics in project pipelite by enasequence.

the class PipelineRunnerAsyncTest method assertSubmitException.

private void assertSubmitException() {
    TestPipeline f = submitException;
    PipelineRunner pipelineRunner = pipeliteServices.runner().getPipelineRunner(f.pipelineName()).get();
    assertThat(pipelineRunner.getActiveProcessRunners().size()).isEqualTo(0);
    PipelineMetrics pipelineMetrics = metrics.pipeline(f.pipelineName());
    assertThat(pipelineMetrics.process().getInternalErrorCount()).isEqualTo(PROCESS_CNT);
    assertThat(pipelineMetrics.process().getCompletedCount()).isZero();
    assertThat(pipelineMetrics.process().getFailedCount()).isEqualTo(PROCESS_CNT);
    assertThat(pipelineMetrics.stage().getFailedCount()).isEqualTo(PROCESS_CNT);
    assertThat(pipelineMetrics.stage().getSuccessCount()).isEqualTo(0);
    assertThat(f.stageExecutor.firstExecuteCalledCount.get()).isEqualTo(PROCESS_CNT);
    assertThat(f.stageExecutor.subsequentExecuteCalledCount.get()).isEqualTo(0);
}
Also used : ConfigurableTestPipeline(pipelite.tester.pipeline.ConfigurableTestPipeline) PipelineMetrics(pipelite.metrics.PipelineMetrics)

Example 5 with PipelineMetrics

use of pipelite.metrics.PipelineMetrics in project pipelite by enasequence.

the class PipelineRunnerAsyncTest method assertSubmitSuccessPollSuccess.

private void assertSubmitSuccessPollSuccess() {
    TestPipeline f = submitSuccessPollSuccess;
    PipelineRunner pipelineRunner = pipeliteServices.runner().getPipelineRunner(f.pipelineName()).get();
    assertThat(pipelineRunner.getActiveProcessRunners().size()).isEqualTo(0);
    PipelineMetrics pipelineMetrics = metrics.pipeline(f.pipelineName());
    assertThat(pipelineMetrics.process().getInternalErrorCount()).isEqualTo(0);
    assertThat(pipelineMetrics.process().getCompletedCount()).isEqualTo(PROCESS_CNT);
    assertThat(pipelineMetrics.process().getFailedCount()).isZero();
    assertThat(pipelineMetrics.stage().getFailedCount()).isEqualTo(0);
    assertThat(pipelineMetrics.stage().getSuccessCount()).isEqualTo(PROCESS_CNT);
    assertThat(f.stageExecutor.firstExecuteCalledCount.get()).isEqualTo(PROCESS_CNT);
    assertThat(f.stageExecutor.subsequentExecuteCalledCount.get()).isEqualTo(PROCESS_CNT);
}
Also used : ConfigurableTestPipeline(pipelite.tester.pipeline.ConfigurableTestPipeline) PipelineMetrics(pipelite.metrics.PipelineMetrics)

Aggregations

PipelineMetrics (pipelite.metrics.PipelineMetrics)13 ConfigurableTestPipeline (pipelite.tester.pipeline.ConfigurableTestPipeline)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Process (pipelite.process.Process)2 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 Table (tech.tablesaw.api.Table)1 Figure (tech.tablesaw.plotly.components.Figure)1