Search in sources :

Example 51 with TSQuery

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

the class TestQueryRpc method parseQueryMTypeWTag.

@Test
public void parseQueryMTypeWTag() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=web01}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    assertNotNull(sub.getTags());
    assertEquals("literal_or(web01)", sub.getTags().get("host"));
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 52 with TSQuery

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

the class TestQueryRpc method parseQueryTSUIDTypeWRateAndDS.

@Test
public void parseQueryTSUIDTypeWRateAndDS() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&tsuid=sum:1m-sum:rate:010101");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    assertNotNull(tsq);
    assertEquals("1h-ago", tsq.getStart());
    assertNotNull(tsq.getQueries());
    TSSubQuery sub = tsq.getQueries().get(0);
    assertNotNull(sub);
    assertEquals("sum", sub.getAggregator());
    assertEquals(1, sub.getTsuids().size());
    assertEquals("010101", sub.getTsuids().get(0));
    assertEquals("1m-sum", sub.getDownsample());
    assertTrue(sub.getRate());
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 53 with TSQuery

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

the class TestQueryRpc method parseQueryTSUIDTypeMulti.

@Test
public void parseQueryTSUIDTypeMulti() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&tsuid=sum:010101,020202");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    assertNotNull(tsq);
    assertEquals("1h-ago", tsq.getStart());
    assertNotNull(tsq.getQueries());
    TSSubQuery sub = tsq.getQueries().get(0);
    assertNotNull(sub);
    assertEquals("sum", sub.getAggregator());
    assertEquals(2, sub.getTsuids().size());
    assertEquals("010101", sub.getTsuids().get(0));
    assertEquals("020202", sub.getTsuids().get(1));
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 54 with TSQuery

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

the class TestQueryRpc method parseQueryMTypeWGroupByWildcardImplicit.

@Test
public void parseQueryMTypeWGroupByWildcardImplicit() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=*quirm}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    sub.validateAndSetQuery();
    assertEquals(1, sub.getFilters().size());
    assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TagVWildcardFilter(net.opentsdb.query.filter.TagVWildcardFilter) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 55 with TSQuery

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

the class TestQueryRpc method parseQueryMTypeWExplicitAndRate.

@Test
public void parseQueryMTypeWExplicitAndRate() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:explicit_tags:rate:sys.cpu.0{host=web01}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    assertNotNull(sub.getTags());
    assertEquals("literal_or(web01)", sub.getTags().get("host"));
    assertTrue(sub.getRate());
    assertTrue(sub.getExplicitTags());
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TSSubQuery(net.opentsdb.core.TSSubQuery) 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