Search in sources :

Example 96 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery 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)

Example 97 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery 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 98 with SeriesQuery

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

the class SeriesQueryTest method testDateIntervalFieldEnoughToGroup.

@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToGroup() throws Exception {
    Series series = new Series("entity-query-25", "metric-query-25");
    series.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 1));
    insertSeriesCheck(Collections.singletonList(series));
    SeriesQuery query = new SeriesQuery();
    query.setEntity(series.getEntity());
    query.setMetric(series.getMetric());
    query.setInterval(new Period(99999, TimeUnit.QUARTER));
    query.setGroup(new Group(GroupType.SUM));
    List<Series> storedSeries = querySeriesAsList(query);
    final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
    final String given = jacksonMapper.writeValueAsString(storedSeries);
    assertTrue("Stored series does not match to inserted", compareJsonString(expected, given));
}
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) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 99 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery 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 100 with SeriesQuery

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

the class SeriesQueryTest method testDateFilterRangeIncludesStorableRange.

@Issue("3013")
@Test
public void testDateFilterRangeIncludesStorableRange() throws Exception {
    String entityName = "e-query-range-16";
    String metricName = "m-query-range-16";
    BigDecimal v = new BigDecimal("7");
    Series series = new Series(entityName, metricName);
    series.addSamples(Sample.ofDateDecimal(MIN_STORABLE_DATE, v));
    insertSeriesCheck(Collections.singletonList(series));
    SeriesQuery seriesQuery = new SeriesQuery(series.getEntity(), series.getMetric(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    List<Sample> data = querySeriesAsList(seriesQuery).get(0).getData();
    assertEquals("Empty data for query interval that contains stored interval", 1, data.size());
    assertEquals("Incorrect stored date", MIN_STORABLE_DATE, data.get(0).getRawDate());
    assertEquals("Incorrect stored value", v, data.get(0).getValue());
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)157 Issue (io.qameta.allure.Issue)145 Test (org.testng.annotations.Test)145 Period (com.axibase.tsd.api.model.Period)43 BigDecimal (java.math.BigDecimal)43 Response (javax.ws.rs.core.Response)31 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)26 Series (com.axibase.tsd.api.model.series.Series)23 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)20 Metric (com.axibase.tsd.api.model.metric.Metric)13 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)8 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)8 Sample (com.axibase.tsd.api.model.series.Sample)7 Entity (com.axibase.tsd.api.model.entity.Entity)6 ArrayList (java.util.ArrayList)5 File (java.io.File)4 List (java.util.List)3 HashMap (java.util.HashMap)2 BaseMethod.compareJsonString (com.axibase.tsd.api.method.BaseMethod.compareJsonString)1 SeriesCheck (com.axibase.tsd.api.method.checks.SeriesCheck)1