Search in sources :

Example 6 with SeriesQuery

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

the class SeriesQueryTest method testDateIntervalFieldEnoughToDetail.

@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToDetail() throws Exception {
    Series series = new Series("entity-query-24", "metric-query-24");
    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));
    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 : 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 7 with SeriesQuery

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

the class SeriesQueryTest method testExactMatchIgnoresReservedVersioningTags.

@Issue("3770")
@Test
public void testExactMatchIgnoresReservedVersioningTags() throws Exception {
    String metricName = metric();
    Metric metric = new Metric(metricName);
    metric.setVersioned(true);
    final int insertedVersionsCount = 3;
    Series series = new Series(entity(), metricName);
    MetricMethod.createOrReplaceMetricCheck(metric);
    for (int i = 0; i < insertedVersionsCount; i++) {
        series.setSamples(Collections.singleton(Sample.ofDateInteger(Mocks.ISO_TIME, i)));
        SeriesMethod.insertSeriesCheck(Collections.singletonList(series));
    }
    SeriesQuery query = new SeriesQuery(series);
    query.setVersioned(true);
    query.setExactMatch(true);
    List<Series> receivedSeries = querySeriesAsList(query);
    int receivedVersionsCount = receivedSeries.get(0).getData().size();
    assertEquals("Number of received versions mismatched", insertedVersionsCount, receivedVersionsCount);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Metric(com.axibase.tsd.api.model.metric.Metric) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 8 with SeriesQuery

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

the class SeriesQueryTest method testLastSeriesWithText.

@Issue("3860")
@Test
public void testLastSeriesWithText() throws Exception {
    Series series = Mocks.series();
    series.setSamples(Collections.singleton(Mocks.TEXT_SAMPLE));
    SeriesMethod.insertSeriesCheck(series);
    SeriesQuery query = new SeriesQuery(series);
    query.setLimit(1);
    List<Series> resultSeriesList = SeriesMethod.querySeriesAsList(query);
    assertEquals("Response doesn't match the expected", Collections.singletonList(series), resultSeriesList);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 9 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> 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 10 with SeriesQuery

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

the class SeriesQueryTest method testXTextFieldLastVersion.

@Issue("3480")
@Test
public void testXTextFieldLastVersion() throws Exception {
    String entityName = "e-text-overwritten-versioning-1";
    String metricName = "m-text-overwritten-versioning-1";
    Series series = new Series(entityName, metricName);
    Metric metric = new Metric(metricName);
    metric.setVersioned(true);
    MetricMethod.createOrReplaceMetricCheck(metric);
    String[] data = new String[] { "1", "2" };
    for (String x : data) {
        Sample sample = Sample.ofDateIntegerText("2016-10-11T13:00:00.000Z", 1, x);
        series.setSamples(Collections.singleton(sample));
        insertSeriesCheck(Collections.singletonList(series));
    }
    SeriesQuery seriesQuery = new SeriesQuery(series);
    List<Series> seriesList = querySeriesAsList(seriesQuery);
    assertFalse("No series", seriesList.isEmpty());
    assertFalse("No series data", seriesList.get(0).getData().isEmpty());
    String received = seriesList.get(0).getData().get(0).getText();
    assertEquals("Last version of text field incorrect", data[data.length - 1], received);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Metric(com.axibase.tsd.api.model.metric.Metric) 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