use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SqlIsNullOperatorTest method testIsNotNullMetricLabel.
@Issue("3516")
@Test
public void testIsNotNullMetricLabel() throws Exception {
Metric metric = new Metric("m-test-operator-is-not-null-metric-label");
metric.setLabel("foo");
String entityName = "e-test-operator-is-not-null-metric-label";
Series series = new Series(entityName, metric.getName());
series.addSamples(Sample.ofDateInteger("2016-06-19T00:00:00.000Z", 2));
MetricMethod.createOrReplaceMetricCheck(metric);
SeriesMethod.insertSeriesCheck(series);
String sqlQuery = String.format("SELECT entity %n" + "FROM \"m-test-operator-is-not-null-metric-label\" %n" + "WHERE datetime >= '2016-06-19T00:00:00.000Z' and datetime < '2016-06-19T00:01:00.000Z' %n" + "AND metric.label IS NOT NULL %n");
String[][] expectedRows = { { entityName } };
assertSqlQueryRows(expectedRows, sqlQuery);
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SqlLookupFunctionTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
String testEntityNameTagsCase = entity();
List<Series> seriesList = new ArrayList<>();
{
Series series = new Series(entity(), TEST_METRIC_NAME_BASE_LOOKUP_CASE);
series.addSamples(Sample.ofDateText("2016-06-03T09:20:00.000Z", "word"), Sample.ofDateText("2016-06-03T09:21:00.000Z", "-1"), Sample.ofDateText("2016-06-03T09:22:00.000Z", "1"), Sample.ofDateText("2016-06-03T09:23:00.000Z", "2"), Sample.ofDateText("2016-06-03T09:24:00.000Z", "word"), Sample.ofDateText("2016-06-03T09:25:00.000Z", "words"), Sample.ofDateText("2016-06-03T09:26:00.000Z", "3"), Sample.ofDateText("2016-06-03T09:27:00.000Z", "4"), Sample.ofDateText("2016-06-03T09:28:00.000Z", "PI"), Sample.ofDateText("2016-06-03T09:29:00.000Z", "3.14"), Sample.ofDateText("2016-06-03T09:30:00.000Z", "nothing"));
seriesList.add(series);
}
Map<String, String> tags = new HashMap<>();
tags.put("1", "-1");
tags.put("2", "1");
tags.put("3", "2");
tags.put("4", "word");
tags.put("5", "words");
tags.put("6", "3");
tags.put("7", "4");
tags.put("8", "PI");
tags.put("9", "3.14");
tags.put("10", "nothing");
Metric metric = new Metric(TEST_METRIC_NAME_TAGS_CASE, tags);
Entity entity = new Entity(testEntityNameTagsCase, tags);
Series series = new Series(testEntityNameTagsCase, TEST_METRIC_NAME_TAGS_CASE, tags);
series.addSamples(Sample.ofDateInteger("2016-06-03T09:20:00.000Z", 1));
seriesList.add(series);
MetricMethod.createOrReplaceMetricCheck(metric);
EntityMethod.createOrReplaceEntityCheck(entity);
SeriesMethod.insertSeriesCheck(seriesList);
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SqlTagNameWithDoubleQuotationTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
final Map<String, String> tags = Collections.unmodifiableMap(new HashMap<String, String>() {
{
put("tag", "0");
put("tag\"quotation", "1");
put("tag+plus", "2");
put("tag-minus", "3");
put("tag*multiple", "4");
put("tag/division", "5");
put("tag\"quotation'", "6");
}
});
Series series = new Series(TEST_ENTITY_NAME, TEST_METRIC_NAME, tags) {
{
addSamples(Sample.ofDateInteger("2016-06-19T11:00:00.500Z", 0));
}
};
MetricMethod.createOrReplaceMetricCheck(new Metric(TEST_METRIC_NAME, tags));
EntityMethod.createOrReplaceEntityCheck(new Entity(TEST_ENTITY_NAME, tags));
SeriesMethod.insertSeriesCheck(Collections.singletonList(series));
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SqlSyntaxQuotesEscapingTest method prepareData.
@BeforeClass
public void prepareData() throws Exception {
Map<String, String> tags = new HashMap<>();
tags.put("double\"quote", "tv1");
tags.put("single'quote", "tv2");
tags.put("both'quo\"tes", "tv3");
Series series = new Series(TEST_ENTITY_NAME, TEST_METRIC_NAME, tags);
series.addSamples(Sample.ofDateDecimal("2016-07-27T22:41:50.407Z", new BigDecimal("12.4")));
SeriesMethod.insertSeriesCheck(Collections.singletonList(series));
Metric updatedMetricQuery = new Metric();
updatedMetricQuery.setTags(tags);
MetricMethod.updateMetric(TEST_METRIC_NAME, updatedMetricQuery);
Entity updatedEntityQuery = new Entity();
updatedEntityQuery.setTags(tags);
MetricMethod.updateMetric(TEST_METRIC_NAME, updatedEntityQuery);
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class CSVUploadTest method testTimeRangeInMS.
@Issue("2957")
@Test
public void testTimeRangeInMS(Method method) throws Exception {
Entity entity = new Entity("e-csv-simple-parser-ms-1");
Metric metric = new Metric("m-csv-simple-parser-ms-1");
File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-time-range-ms.csv").toString());
Response response = binaryCsvUpload(csvPath, SIMPLE_PARSER_MS);
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("Managed to insert dataset with date out of range", 2, series.getData().size());
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());
}
Aggregations