Search in sources :

Example 1 with MessageStatsQuery

use of com.axibase.tsd.api.model.message.MessageStatsQuery in project atsd-api-test by axibase.

the class TokenMessageTest method testStatsMethod.

@Test(description = "Tests messages query stats endpoint with tokens.")
@Issue("6052")
public void testStatsMethod() throws Exception {
    String url = "/messages/stats/query";
    String token = TokenRepository.getToken(username, HttpMethod.POST, url);
    MessageStatsQuery msq = new MessageStatsQuery().setEntity(entity).setType(message.getType()).setStartDate(ISO_TIME).setEndDate(Util.MAX_QUERYABLE_DATE).setAggregate(new Aggregate(AggregationType.COUNT, new Period(1, TimeUnit.DAY, PeriodAlignment.START_TIME)));
    Response response = queryMessageStats(Collections.singletonList(msq), token);
    String expected = String.format("[ {\n" + "  \"entity\" : \"%s\",\n" + "  \"metric\" : \"message-count\",\n" + "  \"tags\" : {\n" + "    \"type\" : \"logger\"\n" + "  },\n" + "  \"type\" : \"HISTORY\",\n" + "  \"aggregate\" : {\n" + "    \"type\" : \"COUNT\",\n" + "   \"period\":{\"count\":1,\"unit\":\"DAY\"}" + "  },\n" + "  \"data\" : [{\"d\":\"%s\", \"v\":1} ]\n" + "} ]", entity, ISO_TIME);
    assertTrue(compareJsonString(expected, response.readEntity(String.class)));
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) Issue(io.qameta.allure.Issue) MessageTest(com.axibase.tsd.api.method.message.MessageTest) Test(org.testng.annotations.Test)

Example 2 with MessageStatsQuery

use of com.axibase.tsd.api.model.message.MessageStatsQuery in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testAggregateUnknownRaiseError.

@Issue("2945")
@Test
public void testAggregateUnknownRaiseError() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
    statsQuery.setAggregate(new Aggregate(AggregationType.SUM));
    Response response = queryMessageStats(statsQuery);
    assertEquals("Query with unknown aggregate type should fail", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 3 with MessageStatsQuery

use of com.axibase.tsd.api.model.message.MessageStatsQuery in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testAggregateDetail.

@Issue("2945")
@Test(enabled = false)
public void testAggregateDetail() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
    statsQuery.setAggregate(new Aggregate(AggregationType.DETAIL));
    List<Series> messageStatsList = queryMessageStatsReturnSeries(statsQuery);
    assertEquals("Response should contain only 1 series", 1, messageStatsList.size());
    List<Sample> samples = messageStatsList.get(0).getData();
    assertEquals("Response should contain only 1 sample", 1, samples.size());
    assertEquals("Message count mismatch", new BigDecimal(DATES.size()), samples.get(0).getValue());
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 4 with MessageStatsQuery

use of com.axibase.tsd.api.model.message.MessageStatsQuery in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testTagsExpressionNoData.

@Issue("6460")
@Test(description = "Tests that messages are not found for expression that does not match any field.")
public void testTagsExpressionNoData() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY).setTagExpression("false");
    Response response = queryMessageStats(statsQuery);
    List<MessageStats> messageStatsList = response.readEntity(ResponseAsList.ofMessageStats());
    assertEquals(1, messageStatsList.size());
    MessageStats stats = messageStatsList.get(0);
    assertEquals(stats.getData().size(), 0);
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) MessageStats(com.axibase.tsd.api.model.message.MessageStats) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with MessageStatsQuery

use of com.axibase.tsd.api.model.message.MessageStatsQuery in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testTagsExpressionNotValidField.

@Issue("6460")
@Test(description = "Tests that request is not stuck if executing query with call to non-existent field")
public void testTagsExpressionNotValidField() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY).setTagExpression("non_existent_key='value'");
    Response response = queryMessageStats(statsQuery);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

MessageStatsQuery (com.axibase.tsd.api.model.message.MessageStatsQuery)13 Issue (io.qameta.allure.Issue)12 Test (org.testng.annotations.Test)12 Response (javax.ws.rs.core.Response)9 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)5 BigDecimal (java.math.BigDecimal)4 MessageStats (com.axibase.tsd.api.model.message.MessageStats)3 Sample (com.axibase.tsd.api.model.series.Sample)3 Series (com.axibase.tsd.api.model.series.Series)3 MessageTest (com.axibase.tsd.api.method.message.MessageTest)1 Period (com.axibase.tsd.api.model.Period)1