Search in sources :

Example 91 with SeriesQuery

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

the class CSVUploadTest method testFileWithCRLineBreakAndDST.

@Issue("3591")
@Test
public void testFileWithCRLineBreakAndDST(Method method) throws Exception {
    Entity entity = new Entity("e-cr-dst-parser-ms-2");
    Metric metric = new Metric("m-cr-dst-parser-ms-2");
    File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-cr-dst-parser.csv").toString());
    Response response = binaryCsvUpload(csvPath, CRLF_PARSER, entity.getName());
    assertEquals("Failed to upload file", OK.getStatusCode(), response.getStatus());
    SeriesQuery seriesQuery = new SeriesQuery(entity.getName(), metric.getName(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    assertSeriesQueryDataSize(seriesQuery, 3);
    Sample sample = SeriesMethod.querySeriesAsList(seriesQuery).get(0).getData().get(0);
    Calendar serverCalendar = new GregorianCalendar(TimeZone.getTimeZone(timezone));
    serverCalendar.clear();
    serverCalendar.set(2015, Calendar.NOVEMBER, 24, 6, 17);
    assertEquals("Date failed to save", serverCalendar.getTime(), parseDate(sample.getRawDate()));
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Sample(com.axibase.tsd.api.model.series.Sample) Metric(com.axibase.tsd.api.model.metric.Metric) File(java.io.File) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 92 with SeriesQuery

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

the class CSVUploadTest method testTimeRangeInISO.

@Issue("2957")
@Test
public void testTimeRangeInISO(Method method) throws Exception {
    Entity entity = new Entity("e-csv-simple-parser-iso-0");
    Metric metric = new Metric("m-csv-simple-parser-iso-0");
    File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-time-range-iso.csv").toString());
    Response response = binaryCsvUpload(csvPath, SIMPLE_PARSER_ISO);
    assertEquals("Failed to upload file", OK.getStatusCode(), response.getStatus());
    SeriesQuery seriesQuery = new SeriesQuery(entity.getName(), metric.getName(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    assertSeriesQueryDataSize(seriesQuery, 2);
    List<Series> seriesList = SeriesMethod.querySeriesAsList(seriesQuery);
    Series series = seriesList.get(0);
    assertEquals("Min storable date failed to save", MIN_STORABLE_DATE, series.getData().get(0).getRawDate());
    assertEquals("Incorrect stored value", "12.45", series.getData().get(0).getValue().toString());
    assertEquals("Max storable date failed to save", MAX_STORABLE_DATE, series.getData().get(1).getRawDate());
    assertEquals("Incorrect stored value", "10.8", series.getData().get(1).getValue().toString());
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Metric(com.axibase.tsd.api.model.metric.Metric) File(java.io.File) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 93 with SeriesQuery

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

the class SeriesQueryTest method testDoubleSeriesQueryDifferentAggregationInSingleQuery.

@Issue("4714")
@Test(description = "test double series query with different transformation")
public void testDoubleSeriesQueryDifferentAggregationInSingleQuery() {
    SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query1.setStartDate("2017-01-01T00:01:00Z");
    query1.setEndDate("2017-01-01T00:04:00Z");
    Aggregate aggregate = new Aggregate();
    aggregate.addType(AggregationType.MIN);
    aggregate.addType(AggregationType.COUNTER);
    aggregate.setPeriod(new Period(2, TimeUnit.MINUTE, PeriodAlignment.START_TIME));
    query1.setAggregate(aggregate);
    List<Series> result = SeriesMethod.querySeriesAsList(query1);
    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("1.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("1.0")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("1.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 94 with SeriesQuery

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

the class SeriesQueryTest method testEndTimeInterpolation.

@Issue("4867")
@Test(description = "test END_TIME period align interpolation")
public void testEndTimeInterpolation() {
    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.setInterpolate(new Interpolate(InterpolateFunction.LINEAR, 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("1.5")), Sample.ofDateDecimal("2017-01-01T00:02:30Z", new BigDecimal("2.5")));
    assertEquals("Incorrect query result with END_TIME period align interpolation", 1, result.size());
    assertEquals("Incorrect query result with END_TIME period align interpolation", expectedSeries, result.get(0));
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Interpolate(com.axibase.tsd.api.model.series.query.transformation.interpolate.Interpolate) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Period(com.axibase.tsd.api.model.Period) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 95 with SeriesQuery

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

the class SeriesQueryTest method testDoubleSeriesQueryDifferentAggregationPeriodAlign.

@Issue("4714")
@Test(description = "test double series query with different transformation period align")
public void testDoubleSeriesQueryDifferentAggregationPeriodAlign() {
    SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query1.setStartDate("2016-12-31T00:01:00Z");
    query1.setEndDate("2017-01-01T00:04:00Z");
    query1.setAggregate(new Aggregate(AggregationType.AVG, new Period(2, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
    SeriesQuery query2 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query2.setStartDate("2016-12-31T00:00:00Z");
    query2.setEndDate("2017-01-01T00:04:00Z");
    query2.setAggregate(new Aggregate(AggregationType.AVG, new Period(2, TimeUnit.MINUTE, PeriodAlignment.FIRST_VALUE_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("1.5")), 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("1.5")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
    assertEquals("Incorrect query result with two series requests with different transformation period align", 2, result.size());
    assertEquals("Incorrect query result with two series requests with different transformation period align", 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)

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