Skip to content

Commit a1b2f3d

Browse files
authored
[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.
1 parent 210f854 commit a1b2f3d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/SearchTimeoutIT.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ public float score() {
240240
for (int doc = min; doc < max; ++doc) {
241241
if (acceptDocs == null || acceptDocs.get(doc)) {
242242
collector.collect(doc);
243-
// collect one doc, then throw a timeout, this ensures partial results will be returned
243+
// collect one doc per segment, only then throw a timeout: this ensures partial
244+
// results are returned
244245
((ContextIndexSearcher) searcher).throwTimeExceededException();
245246
}
246247
}
247-
throw new AssertionError(
248-
"Should have thrown a time exceeded exception: [min: " + min + " - max: " + max + "]"
249-
);
248+
// there is a slight chance that no docs are scored for a specific segment.
249+
// other shards / slices will throw the timeout anyway, one is enough.
250+
return max == maxDoc ? DocIdSetIterator.NO_MORE_DOCS : max;
250251
}
251252

252253
@Override

0 commit comments

Comments
 (0)