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);
}
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());
}
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());
}
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());
}
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);
}
Aggregations