Skip to content

Commit bdd62d7

Browse files
authored
Fix aggs test failures (#74750)
The tests for the debugging information in the filters aggregation where too specific for the kind of randomization we run with. They asserted that the indices contained only a single segment which is *usually* true, but our test randomization framework sometimes emit many segmented indices, just to exercise the code. That's a good thing. But the tests had a wrong assertion. This swaps the assertion from `equalTo(1)` to `greaterThanOrEqualTo(1)`. Closes #74677
1 parent 9c01598 commit bdd62d7

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

server/src/test/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregatorTests.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
import static io.github.nik9000.mapmatcher.MapMatcher.matchesMap;
8989
import static org.hamcrest.Matchers.equalTo;
9090
import static org.hamcrest.Matchers.greaterThan;
91+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
9192
import static org.hamcrest.Matchers.hasSize;
9293
import static org.hamcrest.Matchers.instanceOf;
9394
import static org.hamcrest.Matchers.nullValue;
@@ -390,7 +391,7 @@ public void testRangeFilter() throws IOException {
390391
matchesMap().entry("segments_with_doc_count_field", 0)
391392
.entry("segments_with_deleted_docs", 0)
392393
.entry("segments_collected", 0)
393-
.entry("segments_counted", 1)
394+
.entry("segments_counted", greaterThanOrEqualTo(1))
394395
.entry("filters", matchesList().item(matchesMap().entry("query", "test:[1577836800000 TO 1583020799999]")))
395396
)
396397
);
@@ -450,7 +451,7 @@ public void testMatchAll() throws IOException {
450451
debug,
451452
matchesMap().entry(
452453
"test",
453-
matchesMap().entry("segments_counted", 1)
454+
matchesMap().entry("segments_counted", greaterThanOrEqualTo(1))
454455
.entry("segments_collected", 0)
455456
.entry("segments_with_doc_count_field", 0)
456457
.entry("segments_with_deleted_docs", 0)
@@ -488,9 +489,9 @@ public void testMatchAllWithDocCount() throws IOException {
488489
debug,
489490
matchesMap().entry(
490491
"test",
491-
matchesMap().entry("segments_counted", 1)
492+
matchesMap().entry("segments_counted", greaterThanOrEqualTo(1))
492493
.entry("segments_collected", 0)
493-
.entry("segments_with_doc_count_field", 1)
494+
.entry("segments_with_doc_count_field", greaterThanOrEqualTo(1))
494495
.entry("segments_with_deleted_docs", 0)
495496
.entry(
496497
"filters",
@@ -558,7 +559,7 @@ public void onCache(ShardId shardId, Accountable accountable) {}
558559
aggregator.collectDebugInfo(debug::put);
559560
assertMap(
560561
debug,
561-
matchesMap().entry("segments_counted", 1)
562+
matchesMap().entry("segments_counted", greaterThanOrEqualTo(1))
562563
.entry("segments_collected", 0)
563564
.entry("segments_with_doc_count_field", 0)
564565
.entry("segments_with_deleted_docs", 0)
@@ -645,7 +646,7 @@ public void testMatchNoneFilter() throws IOException {
645646
matchesMap().entry("segments_with_doc_count_field", 0)
646647
.entry("segments_with_deleted_docs", 0)
647648
.entry("segments_collected", 0)
648-
.entry("segments_counted", 1)
649+
.entry("segments_counted", greaterThanOrEqualTo(1))
649650
.entry(
650651
"filters",
651652
matchesList().item(
@@ -682,7 +683,7 @@ public void testMatchNoneTopLevel() throws IOException {
682683
matchesMap().entry("segments_with_doc_count_field", 0)
683684
.entry("segments_with_deleted_docs", 0)
684685
.entry("segments_collected", 0)
685-
.entry("segments_counted", 1)
686+
.entry("segments_counted", greaterThanOrEqualTo(1))
686687
.entry(
687688
"filters",
688689
matchesList().item(
@@ -721,7 +722,7 @@ public void testTermFilter() throws IOException {
721722
matchesMap().entry("segments_with_doc_count_field", 0)
722723
.entry("segments_with_deleted_docs", 0)
723724
.entry("segments_collected", 0)
724-
.entry("segments_counted", 1)
725+
.entry("segments_counted", greaterThanOrEqualTo(1))
725726
.entry(
726727
"filters",
727728
matchesList().item(
@@ -762,7 +763,7 @@ public void testTermTopLevel() throws IOException {
762763
matchesMap().entry("segments_with_doc_count_field", 0)
763764
.entry("segments_with_deleted_docs", 0)
764765
.entry("segments_collected", 0)
765-
.entry("segments_counted", 1)
766+
.entry("segments_counted", greaterThanOrEqualTo(1))
766767
.entry(
767768
"filters",
768769
matchesList().item(
@@ -849,7 +850,7 @@ public void testSubAggs() throws IOException {
849850
"test",
850851
matchesMap().entry("segments_with_doc_count_field", 0)
851852
.entry("segments_with_deleted_docs", 0)
852-
.entry("segments_collected", 1)
853+
.entry("segments_collected", greaterThanOrEqualTo(1))
853854
.entry("segments_counted", 0)
854855
.entry(
855856
"filters",
@@ -925,7 +926,7 @@ public void testSubAggsManyDocs() throws IOException {
925926
"test",
926927
matchesMap().entry("segments_with_doc_count_field", 0)
927928
.entry("segments_with_deleted_docs", 0)
928-
.entry("segments_collected", 1)
929+
.entry("segments_collected", greaterThanOrEqualTo(1))
929930
.entry("segments_counted", 0)
930931
.entry("filters", hasSize(2))
931932
).entry("test.s", matchesMap()).entry("test.m", matchesMap())
@@ -1004,7 +1005,7 @@ public void testSubAggsManyFilters() throws IOException {
10041005
"test",
10051006
matchesMap().entry("segments_with_doc_count_field", 0)
10061007
.entry("segments_with_deleted_docs", 0)
1007-
.entry("segments_collected", 1)
1008+
.entry("segments_collected", greaterThanOrEqualTo(1))
10081009
.entry("segments_counted", 0)
10091010
.entry("filters", hasSize(buckets.size()))
10101011
).entry("test.s", matchesMap()).entry("test.m", matchesMap())

0 commit comments

Comments
 (0)