Search in sources :

Example 31 with TSQuery

use of net.opentsdb.core.TSQuery in project opentsdb by OpenTSDB.

the class TestQueryStats method testEqualsSame.

@Test
public void testEqualsSame() throws Exception {
    final TSQuery query = new TSQuery();
    query.setStart("1h-ago");
    final QueryStats stats = new QueryStats(remote, query, headers);
    assertTrue(stats.equals(stats));
}
Also used : TSQuery(net.opentsdb.core.TSQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 32 with TSQuery

use of net.opentsdb.core.TSQuery in project opentsdb by OpenTSDB.

the class TestQueryStats method ctor.

@Test
public void ctor() throws Exception {
    final TSQuery query = new TSQuery();
    query.setStart("1h-ago");
    final QueryStats stats = new QueryStats(remote, query, headers);
    assertNotNull(stats);
    final Map<String, Object> map = QueryStats.getRunningAndCompleteStats();
    assertNotNull(map);
    assertEquals(1, ((List<Object>) map.get("running")).size());
    assertEquals(0, ((Collection<QueryStats>) map.get("completed")).size());
    assertSame(headers, stats.getRequestHeaders());
}
Also used : TSQuery(net.opentsdb.core.TSQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 33 with TSQuery

use of net.opentsdb.core.TSQuery in project opentsdb by OpenTSDB.

the class TestQueryStats method getStatTime.

@Test
public void getStatTime() throws Exception {
    final TSQuery query = new TSQuery();
    query.setStart("1h-ago");
    final QueryStats stats = new QueryStats(remote, query, headers);
    stats.markSerializationSuccessful();
    assertEquals(1000.0, stats.getTimeStat(QueryStat.PROCESSING_PRE_WRITE_TIME), 0.001);
    assertEquals(Double.NaN, stats.getTimeStat(QueryStat.AVG_AGGREGATION_TIME), 0.001);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 34 with TSQuery

use of net.opentsdb.core.TSQuery in project opentsdb by OpenTSDB.

the class TestQueryStats method ctorNullRemote.

@Test(expected = IllegalArgumentException.class)
public void ctorNullRemote() throws Exception {
    final TSQuery query = new TSQuery();
    query.setStart("1h-ago");
    new QueryStats(null, query, headers);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 35 with TSQuery

use of net.opentsdb.core.TSQuery 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();
}
Also used : TSQuery(net.opentsdb.core.TSQuery) MockDataPoints(net.opentsdb.storage.MockDataPoints) NoSuchUniqueId(net.opentsdb.uid.NoSuchUniqueId) ArrayList(java.util.ArrayList) DataPoints(net.opentsdb.core.DataPoints) MockDataPoints(net.opentsdb.storage.MockDataPoints) Matchers.anyString(org.mockito.Matchers.anyString) Annotation(net.opentsdb.meta.Annotation) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

TSQuery (net.opentsdb.core.TSQuery)63 Test (org.junit.Test)57 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)57 TSSubQuery (net.opentsdb.core.TSSubQuery)30 ArrayList (java.util.ArrayList)18 DataPoints (net.opentsdb.core.DataPoints)17 Annotation (net.opentsdb.meta.Annotation)15 MockDataPoints (net.opentsdb.storage.MockDataPoints)13 Matchers.anyString (org.mockito.Matchers.anyString)10 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)9 TagVWildcardFilter (net.opentsdb.query.filter.TagVWildcardFilter)7 Query (net.opentsdb.core.Query)4 Callback (com.stumbleupon.async.Callback)3 IOException (java.io.IOException)3 NoSuchUniqueId (net.opentsdb.uid.NoSuchUniqueId)3 Deferred (com.stumbleupon.async.Deferred)2 List (java.util.List)2 DataPoint (net.opentsdb.core.DataPoint)2 QueryException (net.opentsdb.core.QueryException)2 TagVLiteralOrFilter (net.opentsdb.query.filter.TagVLiteralOrFilter)2