Skip to content

Commit f325c15

Browse files
authored
FIx async search tests - do not warn on the presence of .async-search (#117301)
1 parent 9b4c89d commit f325c15

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,6 @@ tests:
214214
- class: org.elasticsearch.upgrades.QueryBuilderBWCIT
215215
method: testQueryBuilderBWC {cluster=UPGRADED}
216216
issue: https://github.com/elastic/elasticsearch/issues/116990
217-
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
218-
method: test {yaml=reference/esql/esql-across-clusters/line_197}
219-
issue: https://github.com/elastic/elasticsearch/issues/117099
220217
- class: org.elasticsearch.xpack.apmdata.APMYamlTestSuiteIT
221218
method: test {yaml=/10_apm/Test template reinstallation}
222219
issue: https://github.com/elastic/elasticsearch/issues/116445

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
@@ -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

Comments
 (0)