Просмотр исходного кода

[TEST] Remove assert on non scored doc from SearchTimeoutIT (#122198)

In the recent rewrite of SearchTimeoutIT, an edge case was not considered
for the situation where a specific segment may not score any document.
In that case, other shards and their segments will raise a timeout anyway.
Luca Cavanna 8 месяцев назад
Родитель
Сommit
a1b2f3d39d

+ 5 - 4
server/src/internalClusterTest/java/org/elasticsearch/search/SearchTimeoutIT.java

@@ -240,13 +240,14 @@ public class SearchTimeoutIT extends ESIntegTestCase {
                                             for (int doc = min; doc < max; ++doc) {
                                                 if (acceptDocs == null || acceptDocs.get(doc)) {
                                                     collector.collect(doc);
-                                                    // collect one doc, then throw a timeout, this ensures partial results will be returned
+                                                    // collect one doc per segment, only then throw a timeout: this ensures partial
+                                                    // results are returned
                                                     ((ContextIndexSearcher) searcher).throwTimeExceededException();
                                                 }
                                             }
-                                            throw new AssertionError(
-                                                "Should have thrown a time exceeded exception: [min: " + min + " - max: " + max + "]"
-                                            );
+                                            // there is a slight chance that no docs are scored for a specific segment.
+                                            // other shards / slices will throw the timeout anyway, one is enough.
+                                            return max == maxDoc ? DocIdSetIterator.NO_MORE_DOCS : max;
                                         }
 
                                         @Override