Search in sources :

Example 1 with Aggregate

use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testAggregateUnknownRaiseError.

@Issue("2945")
@Test
public void testAggregateUnknownRaiseError() throws Exception {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
    statsQuery.setAggregate(new Aggregate(AggregationType.SUM));
    Response response = queryMessageStats(statsQuery);
    assertEquals("Query with unknown aggregate type should fail", 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 2 with Aggregate

use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testAggregateDetail.

@Issue("2945")
@Test(enabled = false)
public void testAggregateDetail() throws Exception {
    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 3 with Aggregate

use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.

the class SeriesQueryAggregateGroupOrderRateTest method testAggregateLimit.

@Issue("4729")
@Test(description = "test query result with aggregate limit")
public void testAggregateLimit() {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    query.setAggregate(new Aggregate(AggregationType.MAX, new Period(5, TimeUnit.SECOND)));
    query.setLimit(1);
    query.setDirection("ASC");
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries1 = createSeries(TEST_ENTITY1, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("103.0")));
    Series expectedSeries2 = createSeries(TEST_ENTITY2, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("204.0")));
    assertEquals(result, Arrays.asList(expectedSeries1, expectedSeries2), "Incorrect query result with aggregate limit");
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) 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 Aggregate

use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.

the class SeriesQueryAggregateGroupOrderRateTest method testAggregateOrder.

@Issue("4729")
@Test(dataProvider = "provideOrders", description = "test query result with aggregate")
public void testAggregateOrder(Integer order) {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    Aggregate aggregate = new Aggregate(AggregationType.MIN, new Period(10, TimeUnit.SECOND));
    if (order != null) {
        aggregate.setOrder(order);
    }
    query.setAggregate(aggregate);
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries1 = createSeries(TEST_ENTITY1, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("101.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("111.0")));
    Series expectedSeries2 = createSeries(TEST_ENTITY2, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("200.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("210.0")));
    assertEquals(result, Arrays.asList(expectedSeries1, expectedSeries2), "Incorrect query result with aggregate");
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) 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 5 with Aggregate

use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.

the class SeriesQueryTest method testDateIntervalFieldEnoughToAggregate.

@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToAggregate() throws Exception {
    final BigDecimal VALUE = new BigDecimal("1.0");
    Series series = new Series("entity-query-26", "metric-query-26");
    series.addSamples(Sample.ofDateDecimal("2014-01-01T00:00:00.000Z", VALUE));
    insertSeriesCheck(Collections.singletonList(series));
    SeriesQuery query = new SeriesQuery();
    query.setEntity(series.getEntity());
    query.setMetric(series.getMetric());
    Period interval = new Period(99999, TimeUnit.QUARTER);
    query.setInterval(interval);
    query.setAggregate(new Aggregate(AggregationType.SUM, interval));
    List<Series> storedSeries = querySeriesAsList(query);
    assertEquals("Response should contain only one series", 1, storedSeries.size());
    List<Sample> data = storedSeries.get(0).getData();
    assertEquals("Response should contain only one sample", 1, data.size());
    assertEquals("Returned value does not match to expected SUM", VALUE, data.get(0).getValue());
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) 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)

Aggregations

Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)30 Issue (io.qameta.allure.Issue)29 Test (org.testng.annotations.Test)29 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)26 Period (com.axibase.tsd.api.model.Period)25 BigDecimal (java.math.BigDecimal)19 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)7 MessageStatsQuery (com.axibase.tsd.api.model.message.MessageStatsQuery)4 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)4 Response (javax.ws.rs.core.Response)4 Metric (com.axibase.tsd.api.model.metric.Metric)2 Sample (com.axibase.tsd.api.model.series.Sample)2 Series (com.axibase.tsd.api.model.series.Series)2 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)2 Threshold (com.axibase.tsd.api.model.series.query.transformation.aggregate.Threshold)1 ZonedDateTime (java.time.ZonedDateTime)1