Skip to content

Commit 6ff0246

Browse files
authored
Fixing randomization issue for RankDocsSortBuilderTests (#112598)
Closes #112312. YetAnotherRandomizationIssue :) Under some weird seeds we could end up with 0-length `RankDoc` arrays for both the original and the mutated `RankDocsSortBuilder` instances. In this PR we just ensure that a 0-length mutation will not be possible.
1 parent a07d398 commit 6ff0246

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ tests:
121121
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
122122
method: testDeleteJobAsync
123123
issue: https://github.com/elastic/elasticsearch/issues/112212
124-
- class: org.elasticsearch.search.retriever.rankdoc.RankDocsSortBuilderTests
125-
method: testEqualsAndHashcode
126-
issue: https://github.com/elastic/elasticsearch/issues/112312
127124
- class: org.elasticsearch.search.retriever.RankDocRetrieverBuilderIT
128125
method: testRankDocsRetrieverWithCollapse
129126
issue: https://github.com/elastic/elasticsearch/issues/112254

server/src/test/java/org/elasticsearch/search/retriever/rankdoc/RankDocsSortBuilderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private RankDoc[] randomRankDocs(int totalDocs) {
4444
@Override
4545
protected RankDocsSortBuilder mutate(RankDocsSortBuilder original) throws IOException {
4646
RankDocsSortBuilder mutated = new RankDocsSortBuilder(original);
47-
mutated.rankDocs(randomRankDocs(original.rankDocs().length + randomInt(100)));
47+
mutated.rankDocs(randomRankDocs(original.rankDocs().length + randomIntBetween(10, 100)));
4848
return mutated;
4949
}
5050

0 commit comments

Comments
 (0)