Search in sources :

Example 26 with TSQuery

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

the class TestQueryStats method ctorNullQuery.

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

Example 27 with TSQuery

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

the class TestQueryStats method markComplete.

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

Example 28 with TSQuery

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

the class TestQueryStats method executed.

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

Example 29 with TSQuery

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

the class TestQueryStats method executedTwice.

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

Example 30 with TSQuery

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

the class TestQueryStats method testHashCodeandEquals.

@Test
public void testHashCodeandEquals() throws Exception {
    final TSQuery query = new TSQuery();
    query.setStart("1h-ago");
    final QueryStats stats = new QueryStats(remote, query, headers);
    assertNotNull(stats);
    final int hash_a = stats.hashCode();
    // have to mark the old one as complete before we can test equality
    stats.markSerializationSuccessful();
    final TSQuery query2 = new TSQuery();
    query2.setStart("1h-ago");
    final QueryStats stats2 = new QueryStats(remote, query2, headers);
    assertNotNull(stats);
    assertEquals(hash_a, stats2.hashCode());
    assertEquals(stats, stats2);
    assertFalse(stats == stats2);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) 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