use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class MetricGetTest method testMetricNameContainsCyrillic.
@Issue("1278")
@Test
public void testMetricNameContainsCyrillic() throws Exception {
final Metric metric = new Metric("getйёmetric-3");
createOrReplaceMetricCheck(metric);
Response response = queryMetric(metric.getName());
assertEquals("Fail to execute queryMetric query", OK.getStatusCode(), response.getStatus());
assertTrue("Metrics should be equal", compareJsonString(jacksonMapper.writeValueAsString(metric), response.readEntity(String.class)));
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SeriesInsertTest method testPrecisionAfterCompaction.
@Issue("2871")
@Test(dataProvider = "afterCompactionDataProvider")
public void testPrecisionAfterCompaction(DataType type, BigDecimal valueBefore) throws Exception {
Metric metric = new Metric(metric());
metric.setDataType(type);
Long time = MILLS_TIME;
Series series = new Series(entity(), metric.getName());
series.addSamples(Sample.ofDateDecimal(Util.ISOFormat(time), valueBefore));
MetricMethod.createOrReplaceMetricCheck(metric);
SeriesMethod.insertSeriesCheck(series);
CompactionMethod.performCompaction();
SeriesQuery seriesQuery = new SeriesQuery(series.getEntity(), series.getMetric(), time, time + 1);
List<Series> seriesList = querySeriesAsList(seriesQuery);
BigDecimal actualValue = seriesList.get(0).getData().get(0).getValue();
String assertMessage = String.format("Stored value precision incorrect.%n Expected: %s%nActual: %s%n", valueBefore, actualValue);
assertTrue(assertMessage, valueBefore.compareTo(actualValue) == 0);
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SeriesInsertTest method testXTextFieldVersioned.
@Issue("3740")
@Test
public void testXTextFieldVersioned() throws Exception {
String entityName = "e-text-versioning-2";
String metricName = "m-text-versioning-2";
Series series = new Series(entityName, metricName);
Metric metric = new Metric(metricName);
metric.setVersioned(true);
MetricMethod.createOrReplaceMetricCheck(metric);
String[] data = new String[] { "1", "2", "3", "4" };
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 seriesQueryVersioned = new SeriesQuery(series);
seriesQueryVersioned.setVersioned(true);
seriesQueryVersioned.setExactMatch(false);
List<Series> seriesListVersioned = querySeriesAsList(seriesQueryVersioned);
List<String> textValuesVersioned = new ArrayList<>();
for (Sample s : seriesListVersioned.get(0).getData()) {
textValuesVersioned.add(s.getText());
}
assertEquals("Text field versioning is corrupted", Arrays.asList(data), textValuesVersioned);
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class CSVUploadTest method testFileWithLineBreak.
@Issue("3011")
@Test(dataProvider = "parserProvider")
public void testFileWithLineBreak(Method method, int numTest, String lineBreakType, String parser, Integer dataSize) throws Exception {
String nameSuffix = String.format("-%s-parser-ms-%d", lineBreakType, numTest);
Entity entity = new Entity("e" + nameSuffix);
Metric metric = new Metric("m" + nameSuffix);
String confFileName = String.format("test-%s-parser.csv", lineBreakType);
File csvPath = resolvePath(Paths.get(RESOURCE_DIR, confFileName).toString());
Response response = binaryCsvUpload(csvPath, 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, dataSize);
Sample sample = SeriesMethod.querySeriesAsList(seriesQuery).get(0).getData().get(0);
Calendar serverCalendar = new GregorianCalendar(TimeZone.getTimeZone(timezone));
serverCalendar.clear();
serverCalendar.set(2015, Calendar.MARCH, 24, 6, 17);
assertEquals("Incorrect stored value", LINE_BREAKS_TEST_VALUE, sample.getValue().toString());
assertEquals("Date failed to save", serverCalendar.getTime(), parseDate(sample.getRawDate()));
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SeriesSearchResultRecordDeserializer method deserialize.
@Override
public SeriesSearchResultRecord deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
SeriesSearchResultRecord result = new SeriesSearchResultRecord();
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
JsonNode metricNameNode = node.get(0);
String metricName = null;
if (metricNameNode != null) {
metricName = metricNameNode.textValue();
}
JsonNode metricLabelNode = node.get(1);
String metricLabel = null;
if (metricLabelNode != null) {
metricLabel = metricLabelNode.textValue();
}
Metric metric = null;
JsonNode metricNode = node.get(2);
if (metricNode != null) {
metric = mapper.convertValue(metricNode, Metric.class);
}
if (metric == null) {
metric = new Metric();
}
metric.setName(metricName);
metric.setLabel(metricLabel);
Map<String, String> metricTags = null;
JsonNode metricTagsNode = node.get(3);
if (metricTagsNode != null) {
metricTags = mapper.convertValue(metricTagsNode, Map.class);
}
if (metricTags != null && metricTags.size() != 0) {
metric.setTags(metricTags);
}
result.setMetric(metric);
JsonNode entityNameNode = node.get(4);
String entityName = null;
if (entityNameNode != null) {
entityName = entityNameNode.textValue();
}
JsonNode entityLabelNode = node.get(5);
String entityLabel = null;
if (entityLabelNode != null) {
entityLabel = entityLabelNode.textValue();
}
Entity entity = null;
JsonNode entityNode = node.get(6);
if (entityNode != null) {
entity = mapper.convertValue(entityNode, Entity.class);
}
if (entity == null) {
entity = new Entity();
}
entity.setName(entityName);
entity.setLabel(entityLabel);
Map<String, String> entityTags = null;
JsonNode entityTagsNode = node.get(7);
if (entityTagsNode != null) {
entityTags = mapper.convertValue(entityTagsNode, Map.class);
}
if (entityTags != null && entityTags.size() != 0) {
entity.setTags(entityTags);
}
result.setEntity(entity);
Map<String, String> seriesTags = null;
JsonNode seriesTagsNode = node.get(8);
if (seriesTagsNode != null) {
seriesTags = mapper.convertValue(seriesTagsNode, Map.class);
}
if (seriesTags != null && seriesTags.size() != 0) {
result.setSeriesTags(seriesTags);
}
Double relevanceScore = null;
JsonNode relevanceScoreNode = node.get(9);
if (relevanceScoreNode != null) {
relevanceScore = relevanceScoreNode.doubleValue();
}
result.setRelevanceScore(relevanceScore);
return result;
}
Aggregations