Skip to content

Commit 4428e9b

Browse files
committed
[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
1 parent feed66f commit 4428e9b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void setUp() throws Exception {
7171
//it's ok if min and max are outside the range of the generated buckets, that will just mean that
7272
//empty buckets won't be added before the first bucket and/or after the last one
7373
long min = baseMillis - intervalMillis * randomNumberOfBuckets();
74-
long max = baseMillis + randomNumberOfBuckets() * intervalMillis + randomNumberOfBuckets();
74+
long max = baseMillis + randomNumberOfBuckets() * intervalMillis;
7575
extendedBounds = new ExtendedBounds(min, max);
7676
}
7777
emptyBucketInfo = new InternalDateHistogram.EmptyBucketInfo(rounding, InternalAggregations.EMPTY, extendedBounds);
@@ -86,7 +86,7 @@ protected InternalDateHistogram createTestInstance(String name,
8686
int nbBuckets = randomNumberOfBuckets();
8787
List<InternalDateHistogram.Bucket> buckets = new ArrayList<>(nbBuckets);
8888
//avoid having different random instance start from exactly the same base
89-
long startingDate = baseMillis - intervalMillis * randomIntBetween(0, 100);
89+
long startingDate = baseMillis - intervalMillis * randomNumberOfBuckets();
9090
for (int i = 0; i < nbBuckets; i++) {
9191
//rarely leave some holes to be filled up with empty buckets in case minDocCount is set to 0
9292
if (frequently()) {

0 commit comments

Comments
 (0)