Search in sources :

Example 16 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 testAggregateNoPeriodRaiseError.

@Issue("3324")
@Test
public void testAggregateNoPeriodRaiseError() throws Exception {
    SeriesQuery query = new SeriesQuery("mock-entity", "mock-metric", MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    query.setAggregate(new Aggregate(AggregationType.SUM));
    Response response = querySeries(query);
    assertEquals("Aggregate query without period should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", String.format(AGGREGATE_NON_DETAIL_REQUIRE_PERIOD, query.getAggregate().getType()), extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 17 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 testDoubleSeriesQueryDifferentAggregation.

@Issue("4714")
@Test(description = "test double series query with different transformation")
public void testDoubleSeriesQueryDifferentAggregation() {
    SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query1.setStartDate("2017-01-01T00:01:00Z");
    query1.setEndDate("2017-01-01T00:04:00Z");
    query1.setAggregate(new Aggregate(AggregationType.MAX, new Period(120, TimeUnit.SECOND, PeriodAlignment.START_TIME)));
    SeriesQuery query2 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query2.setStartDate("2017-01-01T00:01:00Z");
    query2.setEndDate("2017-01-01T00:04:00Z");
    query2.setAggregate(new Aggregate(AggregationType.AVG, new Period(3, TimeUnit.MINUTE, PeriodAlignment.START_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("2.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("2.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 18 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 testAggregateInterpolateNoTypeRaiseError.

@Issue("3324")
@Test
public void testAggregateInterpolateNoTypeRaiseError() throws Exception {
    SeriesQuery query = new SeriesQuery("mock-entity", "mock-metric", MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    Aggregate aggregate = new Aggregate(AggregationType.SUM, new Period(99999, TimeUnit.QUARTER));
    aggregate.setInterpolate(new AggregationInterpolate());
    query.setAggregate(aggregate);
    Response response = querySeries(query);
    assertEquals("Query with interpolation but without type should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", INTERPOLATE_TYPE_REQUIRED, extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) 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) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 19 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 testDoubleSeriesQueryDifferentAggregationPeriod.

@Issue("4714")
@Test(description = "test double series query with different transformation period")
public void testDoubleSeriesQueryDifferentAggregationPeriod() {
    SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query1.setStartDate("2017-01-01T00:01:00Z");
    query1.setEndDate("2017-01-01T00:04:00Z");
    query1.setAggregate(new Aggregate(AggregationType.MAX, new Period(2, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
    SeriesQuery query2 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query2.setStartDate("2017-01-01T00:01:00Z");
    query2.setEndDate("2017-01-01T00:04:00Z");
    query2.setAggregate(new Aggregate(AggregationType.MAX, new Period(60, TimeUnit.SECOND, PeriodAlignment.START_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.0")), Sample.ofDateDecimal("2017-01-01T00:02:00Z", new BigDecimal("2.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("2.0")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
    assertEquals("Incorrect query result with two series requests with different transformation period", 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 20 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 testDefaultOrderRateAggregate.

@Issue("4729")
@Test(description = "test query result with default Group/Aggregate order")
public void testDefaultOrderRateAggregate() {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    query.setRate(new Rate(new Period(5, TimeUnit.SECOND)));
    query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND)));
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries1 = createSeries(TEST_ENTITY1, Sample.ofDateInteger("2017-01-01T00:00:00.000Z", 4), Sample.ofDateInteger("2017-01-01T00:00:10.000Z", 5));
    Series expectedSeries2 = createSeries(TEST_ENTITY2, Sample.ofDateInteger("2017-01-01T00:00:00.000Z", 4), Sample.ofDateInteger("2017-01-01T00:00:10.000Z", 5));
    assertEquals(result, Arrays.asList(expectedSeries1, expectedSeries2), "Incorrect query result with default Rate/Aggregate order");
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Rate(com.axibase.tsd.api.model.series.query.transformation.rate.Rate) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) 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