Skip to content

Commit 043f45a

Browse files
authored
Fix failing SearchQueryThenFetchAsyncActionTests (#114630)
The version randomization has been changed recently with the unintended effect that now randomized "old" and "new" versions can be the same, and new versions can even be lower than old versions. This change corrects this by going back to the previous version randomization logic. Closes #114593
1 parent e578533 commit 043f45a

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,9 @@ tests:
297297
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
298298
method: test {categorize.Categorize SYNC}
299299
issue: https://github.com/elastic/elasticsearch/issues/113722
300-
- class: org.elasticsearch.action.search.SearchQueryThenFetchAsyncActionTests
301-
method: testMinimumVersionSameAsNewVersion
302-
issue: https://github.com/elastic/elasticsearch/issues/114593
303300
- class: org.elasticsearch.xpack.security.support.SecurityIndexManagerIntegTests
304301
method: testOnIndexAvailableForSearchIndexAlreadyAvailable
305302
issue: https://github.com/elastic/elasticsearch/issues/114608
306-
- class: org.elasticsearch.action.search.SearchQueryThenFetchAsyncActionTests
307-
method: testMinimumVersionShardDuringPhaseExecution
308-
issue: https://github.com/elastic/elasticsearch/issues/114611
309303
- class: org.elasticsearch.kibana.KibanaThreadPoolIT
310304
method: testBlockedThreadPoolsRejectUserRequests
311305
issue: https://github.com/elastic/elasticsearch/issues/113939

server/src/test/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncActionTests.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,21 @@ public void run() {
258258
}
259259
}
260260

261-
public void testMinimumVersionSameAsNewVersion() throws Exception {
261+
public void testMinimumVersionSameAsNewVersion() {
262262
var newVersion = VersionInformation.CURRENT;
263263
var oldVersion = new VersionInformation(
264-
VersionUtils.randomCompatibleVersion(random(), VersionUtils.getPreviousVersion()),
264+
VersionUtils.randomVersionBetween(
265+
random(),
266+
Version.CURRENT.minimumCompatibilityVersion(),
267+
VersionUtils.getPreviousVersion(newVersion.nodeVersion())
268+
),
265269
IndexVersions.MINIMUM_COMPATIBLE,
266270
IndexVersionUtils.randomCompatibleVersion(random())
267271
);
268272
testMixedVersionsShardsSearch(newVersion, oldVersion, newVersion.nodeVersion());
269273
}
270274

271-
public void testMinimumVersionBetweenNewAndOldVersion() throws Exception {
275+
public void testMinimumVersionBetweenNewAndOldVersion() {
272276
var oldVersion = new VersionInformation(
273277
VersionUtils.getFirstVersion(),
274278
IndexVersions.MINIMUM_COMPATIBLE,
@@ -290,8 +294,7 @@ public void testMinimumVersionBetweenNewAndOldVersion() throws Exception {
290294
testMixedVersionsShardsSearch(newVersion, oldVersion, minVersion);
291295
}
292296

293-
private void testMixedVersionsShardsSearch(VersionInformation oldVersion, VersionInformation newVersion, Version minVersion)
294-
throws Exception {
297+
private void testMixedVersionsShardsSearch(VersionInformation oldVersion, VersionInformation newVersion, Version minVersion) {
295298
final TransportSearchAction.SearchTimeProvider timeProvider = new TransportSearchAction.SearchTimeProvider(
296299
0,
297300
System.nanoTime(),
@@ -372,7 +375,6 @@ public void onResponse(SearchResponse response) {
372375
responses.add(response);
373376
}
374377

375-
;
376378
},
377379
shardsIter,
378380
timeProvider,
@@ -397,7 +399,11 @@ public void onResponse(SearchResponse response) {
397399
public void testMinimumVersionSameAsOldVersion() throws Exception {
398400
var newVersion = VersionInformation.CURRENT;
399401
var oldVersion = new VersionInformation(
400-
VersionUtils.randomCompatibleVersion(random(), VersionUtils.getPreviousVersion()),
402+
VersionUtils.randomVersionBetween(
403+
random(),
404+
Version.CURRENT.minimumCompatibilityVersion(),
405+
VersionUtils.getPreviousVersion(newVersion.nodeVersion())
406+
),
401407
IndexVersions.MINIMUM_COMPATIBLE,
402408
IndexVersionUtils.randomCompatibleVersion(random())
403409
);
@@ -553,7 +559,11 @@ public void run() {
553559
public void testMinimumVersionShardDuringPhaseExecution() throws Exception {
554560
var newVersion = VersionInformation.CURRENT;
555561
var oldVersion = new VersionInformation(
556-
VersionUtils.randomCompatibleVersion(random(), VersionUtils.getPreviousVersion()),
562+
VersionUtils.randomVersionBetween(
563+
random(),
564+
Version.CURRENT.minimumCompatibilityVersion(),
565+
VersionUtils.getPreviousVersion(newVersion.nodeVersion())
566+
),
557567
IndexVersions.MINIMUM_COMPATIBLE,
558568
IndexVersionUtils.randomCompatibleVersion(random())
559569
);

0 commit comments

Comments
 (0)