ListQueryResource { public ListQueryAPIResponseEntity listQuery(@QueryParam("query") String query, @QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime, @QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey, @QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries, @QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top, @QueryParam("filterIfMissing") boolean filterIfMissing, @QueryParam("parallel") int parallel, @QueryParam("metricName") String metricName){ return listQuery(query, startTime, endTime, pageSize, startRowkey, treeAgg, timeSeries, intervalmin, top, filterIfMissing, parallel, metricName,true); }  ListQueryAPIResponseEntity listQuery(@QueryParam("query") String query,
												@QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
												@QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey,
												@QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries,
												@QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
												@QueryParam("filterIfMissing") boolean filterIfMissing,
												@QueryParam("parallel") int parallel,
												@QueryParam("metricName") String metricName); @GET @Produces({MediaType.APPLICATION_JSON}) ListQueryAPIResponseEntity listQuery(@QueryParam("query") String query, 
			@QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
			@QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey, 
			@QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries, 
			@QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
			@QueryParam("filterIfMissing") boolean filterIfMissing,
			@QueryParam("parallel") int parallel,
			@QueryParam("metricName") String metricName,
			@QueryParam("verbose") Boolean verbose); @GET @Path("/legacy") @Produces({MediaType.APPLICATION_JSON}) @Deprecated ListQueryAPIResponseEntity listQueryWithoutCoprocessor(@QueryParam("query") String query,
	                                                              @QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
	                                                              @QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey,
	                                                              @QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries,
	                                                              @QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
	                                                              @QueryParam("filterIfMissing") boolean filterIfMissing,
	                                                              @QueryParam("parallel") int parallel,
	                                                              @QueryParam("metricName") String metricName,
																  @QueryParam("verbose") Boolean verbose); @GET @Path("/jsonp") @Produces({"application/x-javascript", "application/json", "application/xml"}) JSONWithPadding listQueryWithJsonp(@QueryParam("query") String query, 
			@QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
			@QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey, 
			@QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries, 
			@QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
			@QueryParam("filterIfMissing") boolean filterIfMissing,
			@QueryParam("parallel") int parallel,
			@QueryParam("update") String callback,
			@QueryParam("verbose") boolean verbose);  }
@Test public void testMetricQuery() throws Exception { long _startTime = System.currentTimeMillis(); List<String> rowKeys = prepareMetricEntity(startTime,200); long _endTime = startTime+ 200 * 3600*1000; String startTime = DateTimeUtil.secondsToHumanDate(_startTime / 1000); String endTime = DateTimeUtil.secondsToHumanDate((_endTime + 1000) / 1000); ListQueryResource resource = new ListQueryResource(); String query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}"; ListQueryAPIResponseEntity response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]{EXP{@value/3}}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]{*}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); }
@Test public void testMetricQueryWithSort() throws Exception { long _startTime = System.currentTimeMillis(); List<String> rowKeys = prepareMetricEntity(startTime,200); long _endTime = startTime+ 200 * 3600*1000; String startTime = DateTimeUtil.secondsToHumanDate(_startTime / 1000); String endTime = DateTimeUtil.secondsToHumanDate((_endTime + 1000) / 1000); ListQueryResource resource = new ListQueryResource(); String query; ListQueryAPIResponseEntity response; query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}.{avg(value) desc}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}.{sum(value) desc}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}.{max(value) asc}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test"); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); }
@Test public void testPartitionBasedQuery() throws InstantiationException, IllegalAccessException { String[] partitions = new String[2]; partitions[0] = "cluster"; partitions[1] = "datacenter"; EntityDefinitionManager.registerEntity(TestLogAPIEntity.class); EntityDefinition entityDef = EntityDefinitionManager.getEntityByServiceName("TestLogAPIEntity"); entityDef.setPartitions(partitions); entityDef.setTimeSeries(true); ListQueryResource resource = new ListQueryResource(); String query = "TestLogAPIEntity[]{@cluster}"; String startTime = DateTimeUtil.secondsToHumanDate(System.currentTimeMillis() / 1000); String endTime = DateTimeUtil.secondsToHumanDate((System.currentTimeMillis() + 1000) / 1000); ListQueryAPIResponseEntity response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertFalse(response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" ]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertFalse(response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\"]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "TestLogAPIEntity[(@cluster=\"cluster1\") OR (@cluster=\"cluster1\" AND @datacenter=\"dc1\")]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertFalse(response.isSuccess()); query = "TestLogAPIEntity[(@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1=\"value1\") OR (@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag2=\"value2\")]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1=\"value1\" OR @tag2=\"value2\")]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1!=\"value1\" or @tag2=~\"value2\" or ((@tag3 contains \"value3\") or (@tag3 not contains \"value3\")) or @tag4 !=~ \"value4\" or @tag5 in (\"value5-1\",\"value5-2\",\"value5-3\") or @tag6 not in (\"value5-1\",\"value5-2\",\"value5-3\"))]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag5 in (\"value5-1\",\"value5,2\"))]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue(response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1 < \"value1\")]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertFalse("Tag with unsupported operation, should get exception",response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND " + "(@field1 < 1 or @field2 = 2 or @field3 = 13456789 or @field4 = 987654321 or @field5 = 5.6 or @field7 < \"value7\")]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Field with numeric, should success",response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@field1 < -1)]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Field supporte negative numeric value, should get exception", response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1 in (\"\\\"value1-part1\\\",\\\"value1-part2\\\"\",\"value2\"))]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support escaped quotes, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1 is null ]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1 is not null]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is not null, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1 is not null]{*}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is not null, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{@cluster}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support expression in filter, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{EXP{@field1 + @field2} }"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support expression in output, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{EXP{@field1 + @field2} as A}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support expression output with alias, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{@cluster,EXP{@field1 + @field2} as A}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null,true); Assert.assertNotNull(response); Assert.assertTrue("Support parameter \"verbose\" is true, should success: "+query,response.isSuccess()); query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{@cluster,EXP{@field1 + @field2} as A}"; response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null,false); Assert.assertNotNull(response); Assert.assertTrue("Support parameter \"verbose\" is false, should success: "+query,response.isSuccess()); }
@Test public void testObjectTypeFieldQuery() throws IllegalAccessException, InstantiationException { String startTime = DateTimeUtil.secondsToHumanDate(System.currentTimeMillis() / 1000); String endTime = DateTimeUtil.secondsToHumanDate((System.currentTimeMillis() + 1000) / 1000); String[] partitions = new String[2]; partitions[0] = "cluster"; partitions[1] = "datacenter"; EntityDefinitionManager.registerEntity(TestLogAPIEntity.class); EntityDefinition entityDef = EntityDefinitionManager.getEntityByServiceName("TestLogAPIEntity"); entityDef.setPartitions(partitions); entityDef.setTimeSeries(true); ListQueryResource resource = new ListQueryResource(); String query = "TestLogAPIEntity[]{@cluster}"; query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND " + "(@field1 < 1 or @field2 = 2 or @field3 = 13456789 or @field4 = 987654321 or @field5 = 5.6 or @field7 < \"value7\")]{@cluster}"; ListQueryAPIResponseEntity response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Field with numeric, should success",response.isSuccess()); }
@Test public void testFlatAggregateQuery(){ ListQueryResource resource = new ListQueryResource(); ListQueryAPIResponseEntity response = null; String query = null; String start = DateTimeUtil.secondsToHumanDate(0); String end = DateTimeUtil.secondsToHumanDate((endTime + 24 * 3600) / 1000); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(field1)}.{max(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(field1)}.{min(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(field1)}.{sum(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(field1)}.{avg(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}.{count desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster,@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{sum(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: " + query, response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster,@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{count desc}"; response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: " + query, response.isSuccess()); }
@Test public void testTimeSeriesAggregateQuery(){ ListQueryResource resource = new ListQueryResource(); ListQueryAPIResponseEntity response = null; String query = null; String start = DateTimeUtil.secondsToHumanDate(startTime / 1000); String end = DateTimeUtil.secondsToHumanDate((endTime + 1000) / 1000); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(field1)}.{max(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(field1)}.{min(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(field1)}.{sum(field1) desc}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(field1)}.{avg(field1) asc}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: "+query,response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster,@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{max(field1) asc}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: " + query, response.isSuccess()); query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster,@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{count desc}"; response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 1000, false, 0, null); Assert.assertNotNull(response); Assert.assertTrue("Support is null, should success: " + query, response.isSuccess()); }