use of com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord in project atsd-api-test by axibase.
the class SeriesSearchTest method testLimitOffset.
@Issue("4404")
@Test(description = "Test limit and offset options are working")
public void testLimitOffset() {
SeriesSearchQuery query = new SeriesSearchQuery("sst_*");
query.addEntityFields(entityFields);
query.addEntityTags("*");
query.addMetricFields(metricFields);
query.addMetricTags("*");
query.setLimit(2);
query.setOffset(1);
Set<SeriesSearchResultRecord> result = Sets.newHashSet(Arrays.asList(resultRecord2, resultRecord3));
checkQueryWithoutRelevance(query, result);
}
use of com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord in project atsd-api-test by axibase.
the class SeriesSearchTest method testAllFields.
@Issue("4404")
@Test(description = "Test all fields returned")
public void testAllFields() {
Entity expectedEntity = EntityMethod.getEntity(resultRecord4.getEntity().getName());
Metric expectedMetric = MetricMethod.getMetric(resultRecord4.getMetric().getName());
SeriesSearchQuery query = new SeriesSearchQuery("sst_22*");
query.addEntityFields("*");
query.addEntityTags("*");
query.addMetricFields("*");
query.addMetricTags("*");
SeriesSearchResult result = SeriesMethod.searchSeries(query);
SeriesSearchResultRecord[] resultRecords = result.getData();
assertTrue(resultRecords != null && resultRecords.length == 1, "Incorrect series count");
SeriesSearchResultRecord resultRecord = resultRecords[0];
Entity resultEntity = resultRecord.getEntity();
Metric resultMetric = resultRecord.getMetric();
assertEquals(resultEntity, expectedEntity);
assertEquals(resultMetric, expectedMetric);
}
use of com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord in project atsd-api-test by axibase.
the class SeriesSearchTest method createSeries.
private static SeriesSearchResultRecord createSeries(String prefix) throws Exception {
Entity entity = new Entity(prefix + Mocks.entity(), Collections.singletonMap(prefix + "entity_tag", prefix + "entity_value")).setLabel(prefix + Mocks.LABEL).setInterpolationMode(InterpolationMode.PREVIOUS).setTimeZoneID("Europe/Moscow").setEnabled(true);
Metric metric = new Metric(prefix + Mocks.metric(), Collections.singletonMap(prefix + "metric_tag", prefix + "metric_value")).setLabel(prefix + Mocks.LABEL).setTimeZoneID("Europe/London").setEnabled(true).setInterpolate(InterpolationMode.PREVIOUS).setDescription(prefix + Mocks.DESCRIPTION).setDataType(DataType.DECIMAL).setTimePrecision("SECONDS").setEnabled(true).setPersistent(true).setFilter("name = '*'").setRetentionDays(0).setSeriesRetentionDays(0).setVersioned(false).setMinValue(new BigDecimal("1")).setMaxValue(new BigDecimal("200.1")).setInvalidAction("TRANSFORM").setUnits("kg");
Map<String, String> tags = Collections.singletonMap(prefix + "tag", prefix + "value");
Series series = new Series(entity.getName(), metric.getName(), tags);
series.addSamples(Mocks.SAMPLE);
EntityMethod.createOrReplaceEntityCheck(entity);
MetricMethod.createOrReplaceMetricCheck(metric);
SeriesMethod.insertSeriesCheck(series);
return new SeriesSearchResultRecord(entity, metric, tags, 1.0);
}
use of com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord in project atsd-api-test by axibase.
the class SeriesSearchTest method checkQueryWithoutRelevance.
private static void checkQueryWithoutRelevance(SeriesSearchQuery query, Set<SeriesSearchResultRecord> expectedResult) {
SeriesSearchResult result = searchSeries(query);
HashMap<String, SeriesSearchResultRecord> actualRecords = new HashMap<>();
for (SeriesSearchResultRecord resultRecord : result.getData()) {
actualRecords.put(resultRecord.getEntity().getName(), resultRecord);
}
assertEquals(expectedResult.size(), actualRecords.size(), "Expected and actual result sets has different sizes");
for (SeriesSearchResultRecord expectedRecord : expectedResult) {
SeriesSearchResultRecord actualRecord = actualRecords.get(expectedRecord.getEntity().getName());
assertNotNull(actualRecord, "Requested series not found");
assertEquals(actualRecord.getEntity(), expectedRecord.getEntity(), "Entities are different");
assertEquals(actualRecord.getMetric(), expectedRecord.getMetric(), "Metrics are different");
assertEquals(actualRecord.getSeriesTags(), expectedRecord.getSeriesTags(), "Tags are different");
}
}
use of com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord in project atsd-api-test by axibase.
the class SeriesSearchTest method testFieldsTags.
@Issue("4404")
@Test(description = "Test explicitly requested fields and tags are returned")
public void testFieldsTags() {
SeriesSearchQuery query = new SeriesSearchQuery("sst_1*");
query.addEntityFields("interpolate", "timezone");
query.addEntityTags("sst_11_entity_tag");
query.addMetricFields("datatype", "timeprecision");
query.addMetricTags("sst_11_metric_tag");
Entity entity1 = new Entity().setName(resultRecord1.getEntity().getName()).setLabel(resultRecord1.getEntity().getLabel()).setInterpolationMode(resultRecord1.getEntity().getInterpolationMode()).setTimeZoneID(resultRecord1.getEntity().getTimeZoneID());
Metric metirc1 = new Metric().setName(resultRecord1.getMetric().getName()).setLabel(resultRecord1.getMetric().getLabel()).setDataType(resultRecord1.getMetric().getDataType()).setTimePrecision(resultRecord1.getMetric().getTimePrecision());
SeriesSearchResultRecord expectedResult1 = new SeriesSearchResultRecord(entity1, metirc1, resultRecord1.getSeriesTags(), 1.0);
Entity entity2 = new Entity().setName(resultRecord3.getEntity().getName()).setLabel(resultRecord3.getEntity().getLabel()).setInterpolationMode(resultRecord3.getEntity().getInterpolationMode()).setTimeZoneID(resultRecord3.getEntity().getTimeZoneID()).setTags(resultRecord3.getEntity().getTags());
Metric metirc2 = new Metric().setName(resultRecord3.getMetric().getName()).setLabel(resultRecord3.getMetric().getLabel()).setDataType(resultRecord3.getMetric().getDataType()).setTimePrecision(resultRecord3.getMetric().getTimePrecision()).setTags(resultRecord3.getMetric().getTags());
SeriesSearchResultRecord expectedResult3 = new SeriesSearchResultRecord(entity2, metirc2, resultRecord3.getSeriesTags(), 1.0);
SeriesSearchResultRecord[] expectedResult = { expectedResult1, expectedResult3 };
checkQueryWithoutRelevance(query, Sets.newHashSet(Arrays.asList(expectedResult)));
}
Aggregations