Skip to content

Commit 3699811

Browse files
authored
FIx async search tests - do not warn on the presence of .async-search (#117301) (#117372)
(cherry picked from commit f325c15) # Conflicts: # muted-tests.yml # test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java
1 parent 4220d0b commit 3699811

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11701170
}
11711171
final Request deleteRequest = new Request("DELETE", Strings.collectionToCommaDelimitedString(indexPatterns));
11721172
deleteRequest.addParameter("expand_wildcards", "open,closed" + (includeHidden ? ",hidden" : ""));
1173+
deleteRequest.setOptions(deleteRequest.getOptions().toBuilder().setWarningsHandler(ignoreAsyncSearchWarning()).build());
11731174
final Response response = adminClient().performRequest(deleteRequest);
11741175
try (InputStream is = response.getEntity().getContent()) {
11751176
assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged"));
@@ -1182,6 +1183,30 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11821183
}
11831184
}
11841185

1186+
// Make warnings handler that ignores the .async-search warning since .async-search may randomly appear when async requests are slow
1187+
// See: https://github.com/elastic/elasticsearch/issues/117099
1188+
protected static WarningsHandler ignoreAsyncSearchWarning() {
1189+
return new WarningsHandler() {
1190+
@Override
1191+
public boolean warningsShouldFailRequest(List<String> warnings) {
1192+
if (warnings.isEmpty()) {
1193+
return false;
1194+
}
1195+
return warnings.equals(
1196+
List.of(
1197+
"this request accesses system indices: [.async-search], "
1198+
+ "but in a future major version, direct access to system indices will be prevented by default"
1199+
)
1200+
) == false;
1201+
}
1202+
1203+
@Override
1204+
public String toString() {
1205+
return "ignore .async-search warning";
1206+
}
1207+
};
1208+
}
1209+
11851210
protected static void wipeDataStreams() throws IOException {
11861211
try {
11871212
if (hasXPack()) {

0 commit comments

Comments
 (0)