Search in sources :

Example 11 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 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());
}
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 12 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 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());
}
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 13 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 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));
}
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 14 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 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));
}
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 15 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 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));
}
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