Search in sources :

Example 6 with SystemMetricsRequest

use of ee.ria.xroad.monitor.common.SystemMetricsRequest in project X-Road by nordic-institute.

the class MetricsProviderActorTest method testParametrizedSystemMetricsRequest.

@Test
public void testParametrizedSystemMetricsRequest() throws Exception {
    final Props props = Props.create(MetricsProviderActor.class);
    final TestActorRef<MetricsProviderActor> ref = TestActorRef.create(actorSystem, props, "testActorRef");
    Future<Object> future = Patterns.ask(ref, new SystemMetricsRequest(Arrays.asList(HISTOGRAM_NAME), true), Timeout.apply(1, TimeUnit.MINUTES));
    Object result = Await.result(future, Duration.apply(1, TimeUnit.MINUTES));
    assertTrue(future.isCompleted());
    assertTrue(result instanceof SystemMetricsResponse);
    SystemMetricsResponse response = (SystemMetricsResponse) result;
    MetricSetDto metricSetDto = response.getMetrics();
    Set<MetricDto> dtoSet = metricSetDto.getMetrics();
    log.info("metricSetDto: " + metricSetDto);
    assertEquals(1, dtoSet.stream().count());
    // Note: findFirst() works only because of single result
    MetricDto metricDto = dtoSet.stream().findFirst().get();
    assertEquals(HISTOGRAM_NAME, metricDto.getName());
    assertTrue(metricDto instanceof HistogramDto);
    HistogramDto h = (HistogramDto) metricDto;
    assertEquals(100L, (long) h.getMax());
    assertEquals(10L, (long) h.getMin());
    assertEquals(55L, (long) h.getMean());
}
Also used : HistogramDto(ee.ria.xroad.monitor.common.dto.HistogramDto) SystemMetricsResponse(ee.ria.xroad.monitor.common.SystemMetricsResponse) MetricDto(ee.ria.xroad.monitor.common.dto.MetricDto) SystemMetricsRequest(ee.ria.xroad.monitor.common.SystemMetricsRequest) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) Props(akka.actor.Props) Test(org.junit.Test)

Aggregations

SystemMetricsRequest (ee.ria.xroad.monitor.common.SystemMetricsRequest)6 SystemMetricsResponse (ee.ria.xroad.monitor.common.SystemMetricsResponse)6 MetricSetDto (ee.ria.xroad.monitor.common.dto.MetricSetDto)4 Props (akka.actor.Props)3 MetricDto (ee.ria.xroad.monitor.common.dto.MetricDto)3 Test (org.junit.Test)3 HistogramDto (ee.ria.xroad.monitor.common.dto.HistogramDto)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 CodedException (ee.ria.xroad.common.CodedException)1