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)));
}
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());
}
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());
}
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);
}
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());
}
Aggregations