From 18dfdc4f0d190c0b1a7909f5936b7be546dc4e70 Mon Sep 17 00:00:00 2001 From: Yuan Liu Date: Thu, 11 Oct 2018 16:04:57 +0800 Subject: [PATCH] add test for es alert when group by has no limit --- pkg/tsdb/elasticsearch/time_series_query_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/elasticsearch/time_series_query_test.go b/pkg/tsdb/elasticsearch/time_series_query_test.go index 49bf5f5bc75..fe8ae0fa8f2 100644 --- a/pkg/tsdb/elasticsearch/time_series_query_test.go +++ b/pkg/tsdb/elasticsearch/time_series_query_test.go @@ -60,7 +60,7 @@ func TestExecuteTimeSeriesQuery(t *testing.T) { _, err := executeTsdbQuery(c, `{ "timeField": "@timestamp", "bucketAggs": [ - { "type": "terms", "field": "@host", "id": "2" }, + { "type": "terms", "field": "@host", "id": "2", "settings": { "size": "0", "order": "asc" } }, { "type": "date_histogram", "field": "@timestamp", "id": "3" } ], "metrics": [{"type": "count", "id": "1" }] @@ -69,7 +69,9 @@ func TestExecuteTimeSeriesQuery(t *testing.T) { sr := c.multisearchRequests[0].Requests[0] firstLevel := sr.Aggs[0] So(firstLevel.Key, ShouldEqual, "2") - So(firstLevel.Aggregation.Aggregation.(*es.TermsAggregation).Field, ShouldEqual, "@host") + termsAgg := firstLevel.Aggregation.Aggregation.(*es.TermsAggregation) + So(termsAgg.Field, ShouldEqual, "@host") + So(termsAgg.Size, ShouldEqual, 500) secondLevel := firstLevel.Aggregation.Aggs[0] So(secondLevel.Key, ShouldEqual, "3") So(secondLevel.Aggregation.Aggregation.(*es.DateHistogramAgg).Field, ShouldEqual, "@timestamp")