Search in sources :

Example 86 with SeriesQuery

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

the class SeriesQueryTransformationsLimitTest method testGroupAggregateRateLimit.

@Issue("4835")
@Test(description = "test that limit is applied correctly after all permutations of grouping, aggregation, and rate")
public void testGroupAggregateRateLimit() throws Exception {
    SeriesQuery query = new SeriesQuery("*", METRIC, "2017-01-01T00:00:00Z", "2017-01-01T02:00:00Z");
    query.setEntities(ENTITIES);
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            for (int k = 1; k < 3; k++) {
                if (i != j && j != k && k != i) {
                    GROUP.setOrder(i);
                    query.setGroup(GROUP);
                    AGGREGATE.setOrder(j);
                    query.setAggregate(AGGREGATE);
                    RATE.setOrder(k);
                    query.setRate(RATE);
                    checkResponse(query);
                }
            }
        }
    }
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 87 with SeriesQuery

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

the class SeriesQueryWildcardTest method testEntityWithWildcardExactMatchTrue.

@Issue("3371")
@Test
public void testEntityWithWildcardExactMatchTrue() throws Exception {
    TestNameGenerator nameGenerator = new TestNameGenerator();
    String metricName = Mocks.metric();
    Series series1 = new Series(nameGenerator.newEntityName(), metricName);
    series1.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 7));
    Series series2 = new Series(nameGenerator.newEntityName(), metricName, "tag_key", "tag_value");
    series2.addSamples(Sample.ofTimeInteger(MIN_STORABLE_TIMESTAMP, 7), Sample.ofTimeInteger(MIN_STORABLE_TIMESTAMP + 1, 8));
    insertSeriesCheck(series1, series2);
    SeriesQuery seriesQuery = new SeriesQuery(nameGenerator.getPrefix(TestNameGenerator.Key.ENTITY).concat("*"), series1.getMetric(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    seriesQuery.setExactMatch(true);
    seriesQuery.setLimit(2);
    seriesQuery.setSeriesLimit(1);
    List<Sample> data = querySeriesAsList(seriesQuery).get(0).getData();
    assertEquals("ExactMatch true with wildcard doesn't return series without tags", 1, data.size());
    seriesQuery.addTag("tag_key", "tag_value");
    data = querySeriesAsList(seriesQuery).get(0).getData();
    assertEquals("ExactMatch true with wildcard doesn't return series with tags", 2, 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) TestNameGenerator(com.axibase.tsd.api.util.TestNameGenerator) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 88 with SeriesQuery

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

the class SeriesQueryAddMetaTest method checkMeta.

private void checkMeta(String entity, String metric, SeriesType type) {
    SeriesQuery seriesQuery = new SeriesQuery(entity, metric, MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE).setAddMeta(true).setType(type);
    List<Series> seriesList = querySeriesAsList(seriesQuery);
    assertEquals(String.format("Response for series query of type %s has inappropriate length", type), 1, seriesList.size());
    SeriesMeta meta = seriesList.get(0).getMeta();
    assertTrue(String.format("Response for series query of type %s doesn't contain meta", type), meta != null);
    assertTrue(String.format("Response for series query of type %s doesn't contain entity meta", type), meta.getEntity() != null);
    assertTrue(String.format("Response for series query of type %s doesn't contain metric meta", type), meta.getMetric() != null);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery)

Example 89 with SeriesQuery

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

the class SeriesQueryDateFilterTest method testStartEqualEndRaiseError.

@Issue("3030")
@Test
public void testStartEqualEndRaiseError() throws Exception {
    SeriesQuery query = new SeriesQuery("mockEntity", "mockMetric");
    query.setEndDate(MIN_QUERYABLE_DATE);
    query.setStartDate(MIN_QUERYABLE_DATE);
    Response response = querySeries(query);
    assertEquals("Response code mismatch", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", DATE_FILTER_END_GREATER_START_REQUIRED, extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 90 with SeriesQuery

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

the class SeriesQueryDateFilterTest method testIntervalZeroAndEndRaiseError.

@Issue("3030")
@Test
public void testIntervalZeroAndEndRaiseError() throws Exception {
    SeriesQuery query = new SeriesQuery("mockEntity", "mockMetric");
    query.setInterval(new Period(0, TimeUnit.HOUR));
    query.setEndDate(MIN_QUERYABLE_DATE);
    Response response = querySeries(query);
    assertEquals("Response code mismatch", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", DATE_FILTER_END_GREATER_START_REQUIRED, extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) 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)

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