Browse Source

[TEST] Reduce number of buckets created in InternalDateHistogramTests

New that we test with min_doc_count set to 0 as well, we may end up generating a lot more buckets. This commit adjusts the min bound and max bound, as well as the offset for each randomly generated agg instance so that we don't end up hitting the 10.000 max buckets limit.

Relates to #36064
Luca Cavanna 6 years ago
parent
commit
43ea498f2f

+ 2 - 2
server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogramTests.java

@@ -71,7 +71,7 @@ public class InternalDateHistogramTests extends InternalMultiBucketAggregationTe
                 //it's ok if min and max are outside the range of the generated buckets, that will just mean that
                 //empty buckets won't be added before the first bucket and/or after the last one
                 long min = baseMillis - intervalMillis * randomNumberOfBuckets();
-                long max = baseMillis + randomNumberOfBuckets() * intervalMillis + randomNumberOfBuckets();
+                long max = baseMillis + randomNumberOfBuckets() * intervalMillis;
                 extendedBounds = new ExtendedBounds(min, max);
             }
             emptyBucketInfo = new InternalDateHistogram.EmptyBucketInfo(rounding, InternalAggregations.EMPTY, extendedBounds);
@@ -86,7 +86,7 @@ public class InternalDateHistogramTests extends InternalMultiBucketAggregationTe
         int nbBuckets = randomNumberOfBuckets();
         List<InternalDateHistogram.Bucket> buckets = new ArrayList<>(nbBuckets);
         //avoid having different random instance start from exactly the same base
-        long startingDate = baseMillis - intervalMillis * randomIntBetween(0, 100);
+        long startingDate = baseMillis - intervalMillis * randomNumberOfBuckets();
         for (int i = 0; i < nbBuckets; i++) {
             //rarely leave some holes to be filled up with empty buckets in case minDocCount is set to 0
             if (frequently()) {