@@ -1131,6 +1131,7 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11311131 }
11321132 final Request deleteRequest = new Request ("DELETE" , Strings .collectionToCommaDelimitedString (indexPatterns ));
11331133 deleteRequest .addParameter ("expand_wildcards" , "open,closed,hidden" );
1134+ deleteRequest .setOptions (deleteRequest .getOptions ().toBuilder ().setWarningsHandler (ignoreAsyncSearchWarning ()).build ());
11341135 final Response response = adminClient ().performRequest (deleteRequest );
11351136 try (InputStream is = response .getEntity ().getContent ()) {
11361137 assertTrue ((boolean ) XContentHelper .convertToMap (XContentType .JSON .xContent (), is , true ).get ("acknowledged" ));
@@ -1143,6 +1144,30 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11431144 }
11441145 }
11451146
1147+ // Make warnings handler that ignores the .async-search warning since .async-search may randomly appear when async requests are slow
1148+ // See: https://github.com/elastic/elasticsearch/issues/117099
1149+ protected static WarningsHandler ignoreAsyncSearchWarning () {
1150+ return new WarningsHandler () {
1151+ @ Override
1152+ public boolean warningsShouldFailRequest (List <String > warnings ) {
1153+ if (warnings .isEmpty ()) {
1154+ return false ;
1155+ }
1156+ return warnings .equals (
1157+ List .of (
1158+ "this request accesses system indices: [.async-search], "
1159+ + "but in a future major version, direct access to system indices will be prevented by default"
1160+ )
1161+ ) == false ;
1162+ }
1163+
1164+ @ Override
1165+ public String toString () {
1166+ return "ignore .async-search warning" ;
1167+ }
1168+ };
1169+ }
1170+
11461171 protected static void wipeDataStreams () throws IOException {
11471172 try {
11481173 if (hasXPack ()) {
0 commit comments