Search in sources :

Example 1 with SeriesQuery

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

the class AnotherTradeSideTest method addTestCase.

private void addTestCase(boolean isAggregate, String function, String periodStr, String[] requestedSides, List<TestCase> testCases) {
    Period period = Period.from(periodStr);
    SeriesQuery query = query(isAggregate, function, period, requestedSides);
    int seriesCount = expectedSeriesCount(isAggregate, requestedSides);
    Set<String> expectedSides = expectedSides(isAggregate, requestedSides);
    int expectedSamplesCount = expectedSamplesCount(period);
    testCases.add(new TestCase(query, seriesCount, expectedSides, expectedSamplesCount));
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period)

Example 2 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery 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> seriesList = SeriesMethod.querySeriesAsList(query, query);
    List<Series> result = new ArrayList<>();
    for (Series series : seriesList) {
        result.add(pullCheckedFields(series));
    }
    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 : Series(com.axibase.tsd.api.model.series.Series) 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 3 with SeriesQuery

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

the class SeriesQueryTest method testSameDoubleSeriesQuery.

@Issue("4714")
@Test(description = "test same double series query")
public void testSameDoubleSeriesQuery() throws JSONException {
    SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query.setStartDate("2017-01-01T00:01:00Z");
    query.setEndDate("2017-01-01T00:04:00Z");
    CommonAssertions.jsonAssert(Arrays.asList(TEST_SERIES3, TEST_SERIES3), SeriesMethod.querySeries(Arrays.asList(query, query)));
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 4 with SeriesQuery

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

the class SeriesQueryTest method testDateFilterRangeIsAfterStorableRange.

@Issue("3013")
@Test
public void testDateFilterRangeIsAfterStorableRange() throws Exception {
    String entityName = "e-query-range-15";
    String metricName = "m-query-range-15";
    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(), addOneMS(MAX_STORABLE_DATE), MAX_QUERYABLE_DATE);
    List<Sample> data = querySeriesAsList(seriesQuery).get(0).getData();
    assertEquals("Not empty data for disjoint query and stored interval", 0, data.size());
}
Also used : Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Sample(com.axibase.tsd.api.model.series.Sample) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery 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, pullCheckedFields(result.get(0)));
}
Also used : Series(com.axibase.tsd.api.model.series.Series) 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)

Aggregations

SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)219 Test (org.testng.annotations.Test)195 Issue (io.qameta.allure.Issue)172 Series (com.axibase.tsd.api.model.series.Series)101 BigDecimal (java.math.BigDecimal)45 Period (com.axibase.tsd.api.model.Period)39 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)35 Response (javax.ws.rs.core.Response)33 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)31 Sample (com.axibase.tsd.api.model.series.Sample)26 Metric (com.axibase.tsd.api.model.metric.Metric)13 Interval (com.axibase.tsd.api.model.series.query.Interval)10 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)10 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)8 Entity (com.axibase.tsd.api.model.entity.Entity)6 File (java.io.File)4 Interpolate (com.axibase.tsd.api.model.series.query.transformation.interpolate.Interpolate)3 ArrayList (java.util.ArrayList)3 BeforeClass (org.testng.annotations.BeforeClass)3 SeriesCheck (com.axibase.tsd.api.method.checks.SeriesCheck)2