瀏覽代碼

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
Nik Everett 4 年之前
父節點
當前提交
bdd62d76c3

+ 13 - 12
server/src/test/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregatorTests.java

@@ -88,6 +88,7 @@ import static io.github.nik9000.mapmatcher.MapMatcher.assertMap;
 import static io.github.nik9000.mapmatcher.MapMatcher.matchesMap;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.nullValue;
@@ -390,7 +391,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                     matchesMap().entry("segments_with_doc_count_field", 0)
                         .entry("segments_with_deleted_docs", 0)
                         .entry("segments_collected", 0)
-                        .entry("segments_counted", 1)
+                        .entry("segments_counted", greaterThanOrEqualTo(1))
                         .entry("filters", matchesList().item(matchesMap().entry("query", "test:[1577836800000 TO 1583020799999]")))
                 )
             );
@@ -450,7 +451,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                     debug,
                     matchesMap().entry(
                         "test",
-                        matchesMap().entry("segments_counted", 1)
+                        matchesMap().entry("segments_counted", greaterThanOrEqualTo(1))
                             .entry("segments_collected", 0)
                             .entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
@@ -488,9 +489,9 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                     debug,
                     matchesMap().entry(
                         "test",
-                        matchesMap().entry("segments_counted", 1)
+                        matchesMap().entry("segments_counted", greaterThanOrEqualTo(1))
                             .entry("segments_collected", 0)
-                            .entry("segments_with_doc_count_field", 1)
+                            .entry("segments_with_doc_count_field", greaterThanOrEqualTo(1))
                             .entry("segments_with_deleted_docs", 0)
                             .entry(
                                 "filters",
@@ -558,7 +559,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                 aggregator.collectDebugInfo(debug::put);
                 assertMap(
                     debug,
-                    matchesMap().entry("segments_counted", 1)
+                    matchesMap().entry("segments_counted", greaterThanOrEqualTo(1))
                         .entry("segments_collected", 0)
                         .entry("segments_with_doc_count_field", 0)
                         .entry("segments_with_deleted_docs", 0)
@@ -645,7 +646,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
                             .entry("segments_collected", 0)
-                            .entry("segments_counted", 1)
+                            .entry("segments_counted", greaterThanOrEqualTo(1))
                             .entry(
                                 "filters",
                                 matchesList().item(
@@ -682,7 +683,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
                             .entry("segments_collected", 0)
-                            .entry("segments_counted", 1)
+                            .entry("segments_counted", greaterThanOrEqualTo(1))
                             .entry(
                                 "filters",
                                 matchesList().item(
@@ -721,7 +722,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
                             .entry("segments_collected", 0)
-                            .entry("segments_counted", 1)
+                            .entry("segments_counted", greaterThanOrEqualTo(1))
                             .entry(
                                 "filters",
                                 matchesList().item(
@@ -762,7 +763,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
                             .entry("segments_collected", 0)
-                            .entry("segments_counted", 1)
+                            .entry("segments_counted", greaterThanOrEqualTo(1))
                             .entry(
                                 "filters",
                                 matchesList().item(
@@ -849,7 +850,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         "test",
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
-                            .entry("segments_collected", 1)
+                            .entry("segments_collected", greaterThanOrEqualTo(1))
                             .entry("segments_counted", 0)
                             .entry(
                                 "filters",
@@ -925,7 +926,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         "test",
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
-                            .entry("segments_collected", 1)
+                            .entry("segments_collected", greaterThanOrEqualTo(1))
                             .entry("segments_counted", 0)
                             .entry("filters", hasSize(2))
                     ).entry("test.s", matchesMap()).entry("test.m", matchesMap())
@@ -1004,7 +1005,7 @@ public class FiltersAggregatorTests extends AggregatorTestCase {
                         "test",
                         matchesMap().entry("segments_with_doc_count_field", 0)
                             .entry("segments_with_deleted_docs", 0)
-                            .entry("segments_collected", 1)
+                            .entry("segments_collected", greaterThanOrEqualTo(1))
                             .entry("segments_counted", 0)
                             .entry("filters", hasSize(buckets.size()))
                     ).entry("test.s", matchesMap()).entry("test.m", matchesMap())