use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestHttpJsonSerializer method formatQueryAsyncV1NoSuchTagId.
@Test(expected = DeferredGroupException.class)
public void formatQueryAsyncV1NoSuchTagId() throws Exception {
setupFormatQuery();
HttpQuery query = NettyMocks.getQuery(tsdb, "");
HttpJsonSerializer serdes = new HttpJsonSerializer(query);
final TSQuery data_query = getTestQuery(false);
validateTestQuery(data_query);
final DataPoints dps = new MockDataPoints().getMock();
final List<DataPoints[]> results = new ArrayList<DataPoints[]>(1);
results.add(new DataPoints[] { dps });
when(dps.getTagsAsync()).thenReturn(Deferred.<Map<String, String>>fromError(new NoSuchUniqueId("No such tagv", new byte[] { 0, 0, 1 })));
serdes.formatQueryAsyncV1(data_query, results, Collections.<Annotation>emptyList()).joinUninterruptibly();
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestHttpJsonSerializer method formatQueryAsyncV1UnexpectedAggException.
@Test(expected = RuntimeException.class)
public void formatQueryAsyncV1UnexpectedAggException() throws Exception {
setupFormatQuery();
HttpQuery query = NettyMocks.getQuery(tsdb, "");
HttpJsonSerializer serdes = new HttpJsonSerializer(query);
final TSQuery data_query = getTestQuery(false);
validateTestQuery(data_query);
final MockDataPoints mdps = new MockDataPoints();
final List<DataPoints[]> results = new ArrayList<DataPoints[]>(1);
results.add(new DataPoints[] { mdps.getMock() });
when(mdps.getMockDP().timestamp()).thenThrow(new RuntimeException("Unexpected error"));
serdes.formatQueryAsyncV1(data_query, results, Collections.<Annotation>emptyList()).joinUninterruptibly();
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestHttpJsonSerializer method formatQueryAsyncTimeFilterV1.
@Test
public void formatQueryAsyncTimeFilterV1() throws Exception {
setupFormatQuery();
HttpQuery query = NettyMocks.getQuery(tsdb, "");
HttpJsonSerializer serdes = new HttpJsonSerializer(query);
final TSQuery data_query = getTestQuery(false, false);
final List<DataPoints[]> results = new ArrayList<DataPoints[]>(1);
results.add(new DataPoints[] { new MockDataPoints().getMock() });
data_query.setEnd("1357000500");
validateTestQuery(data_query);
ChannelBuffer cb = serdes.formatQueryAsyncV1(data_query, results, Collections.<Annotation>emptyList()).joinUninterruptibly();
assertNotNull(cb);
final String json = cb.toString(Charset.forName("UTF-8"));
assertTrue(json.contains("\"metric\":\"system.cpu.user\","));
assertTrue(json.contains("\"1356998700\":1,"));
assertTrue(json.contains("\"1357000500\":7"));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestHttpJsonSerializer method formatQueryAsyncV1wStatsSummary.
@Test
public void formatQueryAsyncV1wStatsSummary() throws Exception {
setupFormatQuery();
final HttpQuery query = NettyMocks.getQuery(tsdb, "");
final HttpJsonSerializer serdes = new HttpJsonSerializer(query);
final TSQuery data_query = getTestQuery(true, true);
validateTestQuery(data_query);
final List<DataPoints[]> results = new ArrayList<DataPoints[]>(1);
results.add(new DataPoints[] { new MockDataPoints().getMock() });
final ChannelBuffer cb = serdes.formatQueryAsyncV1(data_query, results, Collections.<Annotation>emptyList()).joinUninterruptibly();
assertNotNull(cb);
final String json = cb.toString(Charset.forName("UTF-8"));
assertTrue(json.contains("\"metric\":\"system.cpu.user\","));
assertTrue(json.contains("\"1356998700\":1,"));
assertTrue(json.contains("\"1357058700\":201"));
//assert stats
assertTrue(json.contains("\"stats\":{"));
assertTrue(json.contains("\"emittedDPs\":401"));
System.out.println(json);
//assert stats summary
assertTrue(json.contains("{\"statsSummary\":{"));
assertTrue(json.contains("\"serializationTime\":"));
assertTrue(json.contains("\"processingPreWriteTime\":"));
assertTrue(json.contains("\"queryIdx_00\":"));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestHttpJsonSerializer method formatQueryAsyncV1.
@Test
public void formatQueryAsyncV1() throws Exception {
setupFormatQuery();
HttpQuery query = NettyMocks.getQuery(tsdb, "");
HttpJsonSerializer serdes = new HttpJsonSerializer(query);
final TSQuery data_query = getTestQuery(false);
validateTestQuery(data_query);
final List<DataPoints[]> results = new ArrayList<DataPoints[]>(1);
results.add(new DataPoints[] { new MockDataPoints().getMock() });
ChannelBuffer cb = serdes.formatQueryAsyncV1(data_query, results, Collections.<Annotation>emptyList()).joinUninterruptibly();
assertNotNull(cb);
final String json = cb.toString(Charset.forName("UTF-8"));
assertTrue(json.contains("\"metric\":\"system.cpu.user\","));
assertTrue(json.contains("\"1356998700\":1,"));
assertTrue(json.contains("\"1357058700\":201"));
assertFalse(json.contains("\"timeTotal\""));
assertTrue(json.contains("\"tsuid\":\"000001000001000001\""));
assertFalse(json.contains("\"query\":"));
}
Aggregations