use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class MessageQueryStatsTest method testAggregateNoTypeRaiseError.
@Issue("2945")
@Test
public void testAggregateNoTypeRaiseError() throws Exception {
MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
statsQuery.setAggregate(new Aggregate());
Response response = queryMessageStats(statsQuery);
assertEquals("Query with unknown aggregate type should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class MessageQueryStatsTest method testAggregateCount.
@Issue("2945")
@Test(enabled = false)
public void testAggregateCount() throws Exception {
MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
statsQuery.setAggregate(new Aggregate(AggregationType.COUNT));
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.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testDoubleSeriesQueryDifferentAggregationInSingleQuery.
@Issue("4714")
@Test(description = "test double series query with different transformation")
public void testDoubleSeriesQueryDifferentAggregationInSingleQuery() {
SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query1.setStartDate("2017-01-01T00:01:00Z");
query1.setEndDate("2017-01-01T00:04:00Z");
Aggregate aggregate = new Aggregate();
aggregate.addType(AggregationType.MIN);
aggregate.addType(AggregationType.COUNTER);
aggregate.setPeriod(new Period(2, TimeUnit.MINUTE, PeriodAlignment.START_TIME));
query1.setAggregate(aggregate);
List<Series> result = SeriesMethod.querySeriesAsList(query1);
Series expectedSeries1 = new Series();
expectedSeries1.setEntity(TEST_SERIES3.getEntity());
expectedSeries1.setMetric(TEST_SERIES3.getMetric());
expectedSeries1.setTags(Mocks.TAGS);
expectedSeries1.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("1.0")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
Series expectedSeries2 = new Series();
expectedSeries2.setEntity(TEST_SERIES3.getEntity());
expectedSeries2.setMetric(TEST_SERIES3.getMetric());
expectedSeries2.setTags(Mocks.TAGS);
expectedSeries2.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("1.0")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("1.0")));
assertEquals("Incorrect query result with two series requests with different transformation", Sets.newHashSet(expectedSeries1, expectedSeries2), Sets.newHashSet(result));
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testDoubleSeriesQueryDifferentAggregationPeriodAlign.
@Issue("4714")
@Test(description = "test double series query with different transformation period align")
public void testDoubleSeriesQueryDifferentAggregationPeriodAlign() {
SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query1.setStartDate("2016-12-31T00:01:00Z");
query1.setEndDate("2017-01-01T00:04:00Z");
query1.setAggregate(new Aggregate(AggregationType.AVG, new Period(2, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
SeriesQuery query2 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query2.setStartDate("2016-12-31T00:00:00Z");
query2.setEndDate("2017-01-01T00:04:00Z");
query2.setAggregate(new Aggregate(AggregationType.AVG, new Period(2, TimeUnit.MINUTE, PeriodAlignment.FIRST_VALUE_TIME)));
List<Series> result = SeriesMethod.querySeriesAsList(query1, query2);
Series expectedSeries1 = new Series();
expectedSeries1.setEntity(TEST_SERIES3.getEntity());
expectedSeries1.setMetric(TEST_SERIES3.getMetric());
expectedSeries1.setTags(Mocks.TAGS);
expectedSeries1.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("1.5")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
Series expectedSeries2 = new Series();
expectedSeries2.setEntity(TEST_SERIES3.getEntity());
expectedSeries2.setMetric(TEST_SERIES3.getMetric());
expectedSeries2.setTags(Mocks.TAGS);
expectedSeries2.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("1.5")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
assertEquals("Incorrect query result with two series requests with different transformation period align", 2, result.size());
assertEquals("Incorrect query result with two series requests with different transformation period align", Sets.newHashSet(expectedSeries1, expectedSeries2), Sets.newHashSet(result));
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testEndTimeAggregation.
@Issue("4867")
@Test(description = "test END_TIME period align aggregation")
public void testEndTimeAggregation() {
SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query.setStartDate("2017-01-01T00:00:50Z");
query.setEndDate("2017-01-01T00:03:30Z");
query.setAggregate(new Aggregate(AggregationType.MAX, new Period(1, TimeUnit.MINUTE, PeriodAlignment.END_TIME)));
List<Series> result = SeriesMethod.querySeriesAsList(query);
Series expectedSeries = new Series();
expectedSeries.setEntity(TEST_SERIES3.getEntity());
expectedSeries.setMetric(TEST_SERIES3.getMetric());
expectedSeries.setTags(Mocks.TAGS);
expectedSeries.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:30Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:02:30Z", new BigDecimal("3.0")));
assertEquals("Incorrect query result with END_TIME period align aggregation", 1, result.size());
assertEquals("Incorrect query result with END_TIME period align aggregation", expectedSeries, result.get(0));
}
Aggregations