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()));
}
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());
}
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));
}
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));
}
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));
}
Aggregations