Skip to content

Commit

Permalink
FIx async search tests - do not warn on the presence of .async-search (
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev authored Nov 22, 2024
1 parent 9b4c89d commit f325c15
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ tests:
- class: org.elasticsearch.upgrades.QueryBuilderBWCIT
method: testQueryBuilderBWC {cluster=UPGRADED}
issue: https://github.com/elastic/elasticsearch/issues/116990
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
method: test {yaml=reference/esql/esql-across-clusters/line_197}
issue: https://github.com/elastic/elasticsearch/issues/117099
- class: org.elasticsearch.xpack.apmdata.APMYamlTestSuiteIT
method: test {yaml=/10_apm/Test template reinstallation}
issue: https://github.com/elastic/elasticsearch/issues/116445
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
}
final Request deleteRequest = new Request("DELETE", Strings.collectionToCommaDelimitedString(indexPatterns));
deleteRequest.addParameter("expand_wildcards", "open,closed,hidden");
deleteRequest.setOptions(deleteRequest.getOptions().toBuilder().setWarningsHandler(ignoreAsyncSearchWarning()).build());
final Response response = adminClient().performRequest(deleteRequest);
try (InputStream is = response.getEntity().getContent()) {
assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged"));
Expand All @@ -1143,6 +1144,30 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
}
}

// Make warnings handler that ignores the .async-search warning since .async-search may randomly appear when async requests are slow
// See: https://github.com/elastic/elasticsearch/issues/117099
protected static WarningsHandler ignoreAsyncSearchWarning() {
return new WarningsHandler() {
@Override
public boolean warningsShouldFailRequest(List<String> warnings) {
if (warnings.isEmpty()) {
return false;
}
return warnings.equals(
List.of(
"this request accesses system indices: [.async-search], "
+ "but in a future major version, direct access to system indices will be prevented by default"
)
) == false;
}

@Override
public String toString() {
return "ignore .async-search warning";
}
};
}

protected static void wipeDataStreams() throws IOException {
try {
if (hasXPack()) {
Expand Down

0 comments on commit f325c15

Please sign in to comment.