Search in sources :

Example 6 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 testSameDoubleSeriesQueryWithAggregation.

@Issue("4714")
@Test(description = "test same double series query")
public void testSameDoubleSeriesQueryWithAggregation() {
    SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query.setStartDate("2017-01-01T00:01:00Z");
    query.setEndDate("2017-01-01T00:04:00Z");
    query.setAggregate(new Aggregate(AggregationType.SUM, new Period(3, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
    List<Series> result = SeriesMethod.querySeriesAsList(query, 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:00Z", new BigDecimal("6.0")));
    assertEquals("Incorrect query result with two same series requests", Arrays.asList(expectedSeries, expectedSeries), 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 7 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 testEndTimeAggregationWithInterpolation.

@Issue("4867")
@Test(description = "test END_TIME period align aggregation with interpolation")
public void testEndTimeAggregationWithInterpolation() {
    SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query.setStartDate("2017-01-01T00:00:50Z");
    query.setEndDate("2017-01-01T00:03:30Z");
    Aggregate aggregate = new Aggregate(AggregationType.MAX, new Period(1, TimeUnit.MINUTE, PeriodAlignment.END_TIME));
    aggregate.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
    query.setAggregate(aggregate);
    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 with interpolation", 1, result.size());
    assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", 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) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 8 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 testDefaultOrderGroupAggregate.

@Issue("4729")
@Test(description = "test query result with default Group/Aggregate order")
public void testDefaultOrderGroupAggregate() {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND)));
    query.setGroup(new Group(GroupType.MAX, new Period(5, TimeUnit.SECOND)));
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("2.0")));
    assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with default Group/Aggregate order");
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) 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 9 with Aggregate

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

the class SeriesQueryMultipleYearsGroupTest method testSeriesQueryMultipleYearGroupSingleEntity.

@Issue("4101")
@Issue("4591")
@Test
public void testSeriesQueryMultipleYearGroupSingleEntity() throws Exception {
    SeriesQuery query = new SeriesQuery();
    query.setEntities(Collections.singletonList(ENTITY_NAME2));
    query.setMetric(METRIC_NAME);
    query.setStartDate("1900-01-01T00:00:00.000Z");
    query.setEndDate("2100-01-01T00:00:00.000Z");
    query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(12, TimeUnit.YEAR)));
    List<Series> resultSeries = querySeriesAsList(query);
    List<Sample> samples = new ArrayList<>();
    samples.add(Sample.ofDateInteger("2006-01-01T00:00:00.000Z", 2));
    assertSamples(samples, resultSeries.get(0).getData());
}
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) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 10 with Aggregate

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

the class SeriesQueryMultipleYearsGroupTest method testSeriesQueryMultipleYearGroupBothEntities.

@Issue("4101")
@Issue("4591")
@Test
public void testSeriesQueryMultipleYearGroupBothEntities() throws Exception {
    SeriesQuery query = new SeriesQuery();
    query.setEntities(Arrays.asList(ENTITY_NAME1, ENTITY_NAME2));
    query.setMetric(METRIC_NAME);
    query.setStartDate("1900-01-01T00:00:00.000Z");
    query.setEndDate("2100-01-01T00:00:00.000Z");
    query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(12, TimeUnit.YEAR)));
    List<Series> resultSeries = querySeriesAsList(query);
    List<Sample> samples1 = new ArrayList<>();
    /* See #4101#note-18 */
    if (zeroTimeOffset <= 0) {
        samples1.add(Sample.ofDateInteger("1970-01-01T00:00:00.000Z", 1));
    }
    samples1.add(Sample.ofDateInteger("2006-01-01T00:00:00.000Z", 2));
    samples1.add(Sample.ofDateInteger("2018-01-01T00:00:00.000Z", 1));
    List<Sample> samples2 = new ArrayList<>();
    samples2.add(Sample.ofDateInteger("2006-01-01T00:00:00.000Z", 2));
    assertSamples(samples1, resultSeries.get(0).getData());
    assertSamples(samples2, resultSeries.get(1).getData());
}
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) 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