Search in sources :

Example 1 with Period

use of com.axibase.tsd.api.model.Period 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 Period

use of com.axibase.tsd.api.model.Period 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 Period

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

Example 4 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class SeriesQueryForecastAutoAggregateTest method testOfMatchTimeSpanBetweenSamplesAndPeriodCount.

@Issue("6171")
@Test(dependsOnMethods = "testResponseHaveForecastSeries", description = "Checks that forecast series is regular" + " and time span between samples is correct")
public void testOfMatchTimeSpanBetweenSamplesAndPeriodCount() {
    List<Series> seriesList = querySeriesAsList(query);
    Series series = seriesList.get(0);
    List<Sample> samples = series.getData();
    long timeStampPeriodMs = timeStampDifference(samples.get(0), samples.get(1));
    for (int i = 2; i < samples.size(); i++) {
        long timeSpan = timeStampDifference(samples.get(i - 1), samples.get(i));
        if (timeSpan != timeStampPeriodMs) {
            throw new AssertionError("Output series is irregular");
        }
    }
    Period period = series.getAggregate().getPeriod();
    long countPeriodMs = period.getUnit().toMilliseconds(period.getCount());
    assertEquals(timeStampPeriodMs, countPeriodMs, "Count in period of aggregation not match time span between samples");
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) Period(com.axibase.tsd.api.model.Period) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class SeriesQueryAggregateGroupOrderRateTest method testAggregateLimit.

@Issue("4729")
@Test(description = "test query result with aggregate limit")
public void testAggregateLimit() {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    query.setAggregate(new Aggregate(AggregationType.MAX, new Period(5, TimeUnit.SECOND)));
    query.setLimit(1);
    query.setDirection("ASC");
    Set<CheckedFields> actualFields = createCheckFields(querySeriesAsList(query));
    CheckedFields series1 = new CheckedFields(TEST_ENTITY1, Arrays.asList(Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("103.0"))));
    CheckedFields series2 = new CheckedFields(TEST_ENTITY2, Arrays.asList(Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("204.0"))));
    Set<CheckedFields> expectedFields = collectCheckFields(series1, series2);
    assertEquals(actualFields, expectedFields, "Incorrect query result with aggregate limit");
}
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

Period (com.axibase.tsd.api.model.Period)63 Test (org.testng.annotations.Test)48 Issue (io.qameta.allure.Issue)44 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)39 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)30 BigDecimal (java.math.BigDecimal)24 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)16 Series (com.axibase.tsd.api.model.series.Series)14 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)11 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)10 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)7 Property (com.axibase.tsd.api.model.property.Property)6 MessageQuery (com.axibase.tsd.api.model.message.MessageQuery)5 MessageQuerySizeCheck (com.axibase.tsd.api.method.checks.MessageQuerySizeCheck)4 Message (com.axibase.tsd.api.model.message.Message)4 AggregationType (com.axibase.tsd.api.model.series.query.transformation.aggregate.AggregationType)3 ArrayList (java.util.ArrayList)3 Response (javax.ws.rs.core.Response)3 DataProvider (org.testng.annotations.DataProvider)3 Metric (com.axibase.tsd.api.model.metric.Metric)2