use of net.opentsdb.storage.MockBase.MockScanner in project opentsdb by OpenTSDB.
the class TestTsdbQueryQueries method filterExplicitTagsGroupByOK.
@Test
public void filterExplicitTagsGroupByOK() throws Exception {
tsdb.getConfig().overrideConfig("tsd.query.enable_fuzzy", "true");
storeLongTimeSeriesSeconds(true, false);
HashMap<String, String> tags = new HashMap<String, String>(1);
tags.put("host", "*");
query.setStartTime(1356998400);
query.setEndTime(1357041600);
query.setExplicitTags(true);
query.setTimeSeries("sys.cpu.user", tags, Aggregators.SUM, false);
final DataPoints[] dps = query.run();
assertNotNull(dps);
assertEquals("sys.cpu.user", dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals("web01", dps[0].getTags().get("host"));
int value = 1;
for (DataPoint dp : dps[0]) {
assertEquals(value, dp.longValue());
value++;
}
assertEquals(300, dps[0].aggregatedSize());
// assert fuzzy
for (final MockScanner scanner : storage.getScanners()) {
assertTrue(scanner.getFilter() instanceof FilterList);
FilterList filter_list = (FilterList) scanner.getFilter();
assertEquals(2, filter_list.size());
assertTrue(filter_list.filters().get(0) instanceof FuzzyRowFilter);
assertTrue(filter_list.filters().get(1) instanceof KeyRegexpFilter);
}
}
use of net.opentsdb.storage.MockBase.MockScanner in project opentsdb by OpenTSDB.
the class TestTsdbQueryQueries method filterExplicitTagsMissing.
@Test
public void filterExplicitTagsMissing() throws Exception {
tsdb.getConfig().overrideConfig("tsd.query.enable_fuzzy", "true");
when(tag_names.getIdAsync("colo")).thenReturn(Deferred.fromResult(new byte[] { 0, 0, 0, 4 }));
when(tag_values.getIdAsync("lga")).thenReturn(Deferred.fromResult(new byte[] { 0, 0, 0, 4 }));
storeLongTimeSeriesSeconds(true, false);
HashMap<String, String> tags = new HashMap<String, String>(1);
tags.put("host", "web01");
tags.put("colo", "lga");
query.setStartTime(1356998400);
query.setEndTime(1357041600);
query.setExplicitTags(true);
query.setTimeSeries("sys.cpu.user", tags, Aggregators.SUM, false);
final DataPoints[] dps = query.run();
assertNotNull(dps);
assertEquals(0, dps.length);
// assert fuzzy
for (final MockScanner scanner : storage.getScanners()) {
assertTrue(scanner.getFilter() instanceof FilterList);
FilterList filter_list = (FilterList) scanner.getFilter();
assertEquals(2, filter_list.size());
assertTrue(filter_list.filters().get(0) instanceof FuzzyRowFilter);
assertTrue(filter_list.filters().get(1) instanceof KeyRegexpFilter);
}
}
use of net.opentsdb.storage.MockBase.MockScanner in project opentsdb by OpenTSDB.
the class TestTsdbQueryQueries method filterExplicitTagsOK.
@Test
public void filterExplicitTagsOK() throws Exception {
tsdb.getConfig().overrideConfig("tsd.query.enable_fuzzy", "true");
storeLongTimeSeriesSeconds(true, false);
HashMap<String, String> tags = new HashMap<String, String>(1);
tags.put("host", "web01");
query.setStartTime(1356998400);
query.setEndTime(1357041600);
query.setExplicitTags(true);
query.setTimeSeries("sys.cpu.user", tags, Aggregators.SUM, false);
final DataPoints[] dps = query.run();
assertNotNull(dps);
assertEquals("sys.cpu.user", dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals("web01", dps[0].getTags().get("host"));
int value = 1;
for (DataPoint dp : dps[0]) {
assertEquals(value, dp.longValue());
value++;
}
assertEquals(300, dps[0].aggregatedSize());
// assert fuzzy
for (final MockScanner scanner : storage.getScanners()) {
assertTrue(scanner.getFilter() instanceof FilterList);
FilterList filter_list = (FilterList) scanner.getFilter();
assertEquals(2, filter_list.size());
assertTrue(filter_list.filters().get(0) instanceof FuzzyRowFilter);
assertTrue(filter_list.filters().get(1) instanceof KeyRegexpFilter);
}
}
Aggregations