Skip to content

Commit cda2fe6

Browse files
authored
[CI] DocsClientYamlTestSuiteIT test {yaml=reference/watcher/example-watches/example-watch-clusterstatus/line_137} failing - (#115809) (#117354)
* Ignore system index access errors in YAML test index cleanup method * Remove test mute * Swap the logic back as it was right the first time * Resolve conflict with latest merge * Move warning handler into it's own method to reduce nesting
1 parent b017356 commit cda2fe6

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ tests:
100100
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
101101
method: test {p0=transform/transforms_start_stop/Verify start transform reuses destination index}
102102
issue: https://github.com/elastic/elasticsearch/issues/115808
103-
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
104-
method: test {yaml=reference/watcher/example-watches/example-watch-clusterstatus/line_137}
105-
issue: https://github.com/elastic/elasticsearch/issues/115809
106103
- class: org.elasticsearch.search.StressSearchServiceReaperIT
107104
method: testStressReaper
108105
issue: https://github.com/elastic/elasticsearch/issues/115816

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.apache.http.ssl.SSLContextBuilder;
2727
import org.apache.http.ssl.SSLContexts;
2828
import org.apache.http.util.EntityUtils;
29+
import org.apache.logging.log4j.LogManager;
30+
import org.apache.logging.log4j.Logger;
2931
import org.elasticsearch.Build;
3032
import org.elasticsearch.TransportVersion;
3133
import org.elasticsearch.TransportVersions;
@@ -158,6 +160,8 @@ public abstract class ESRestTestCase extends ESTestCase {
158160

159161
private static final Pattern SEMANTIC_VERSION_PATTERN = Pattern.compile("^(\\d+\\.\\d+\\.\\d+)\\D?.*");
160162

163+
private static final Logger SUITE_LOGGER = LogManager.getLogger(ESRestTestCase.class);
164+
161165
/**
162166
* Convert the entity from a {@link Response} into a map of maps.
163167
* Consumes the underlying HttpEntity, releasing any resources it may be holding.
@@ -1111,7 +1115,14 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11111115
}
11121116
final Request deleteRequest = new Request("DELETE", Strings.collectionToCommaDelimitedString(indexPatterns));
11131117
deleteRequest.addParameter("expand_wildcards", "open,closed,hidden");
1114-
deleteRequest.setOptions(deleteRequest.getOptions().toBuilder().setWarningsHandler(ignoreAsyncSearchWarning()).build());
1118+
1119+
// If system index warning, ignore but log
1120+
// See: https://github.com/elastic/elasticsearch/issues/117099
1121+
// and: https://github.com/elastic/elasticsearch/issues/115809
1122+
deleteRequest.setOptions(
1123+
RequestOptions.DEFAULT.toBuilder().setWarningsHandler(ESRestTestCase::ignoreSystemIndexAccessWarnings)
1124+
);
1125+
11151126
final Response response = adminClient().performRequest(deleteRequest);
11161127
try (InputStream is = response.getEntity().getContent()) {
11171128
assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged"));
@@ -1124,28 +1135,16 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11241135
}
11251136
}
11261137

1127-
// Make warnings handler that ignores the .async-search warning since .async-search may randomly appear when async requests are slow
1128-
// See: https://github.com/elastic/elasticsearch/issues/117099
1129-
protected static WarningsHandler ignoreAsyncSearchWarning() {
1130-
return new WarningsHandler() {
1131-
@Override
1132-
public boolean warningsShouldFailRequest(List<String> warnings) {
1133-
if (warnings.isEmpty()) {
1134-
return false;
1135-
}
1136-
return warnings.equals(
1137-
List.of(
1138-
"this request accesses system indices: [.async-search], "
1139-
+ "but in a future major version, direct access to system indices will be prevented by default"
1140-
)
1141-
) == false;
1138+
private static boolean ignoreSystemIndexAccessWarnings(List<String> warnings) {
1139+
for (String warning : warnings) {
1140+
if (warning.startsWith("this request accesses system indices:")) {
1141+
SUITE_LOGGER.warn("Ignoring system index access warning during test cleanup: {}", warning);
1142+
} else {
1143+
return true;
11421144
}
1145+
}
11431146

1144-
@Override
1145-
public String toString() {
1146-
return "ignore .async-search warning";
1147-
}
1148-
};
1147+
return false;
11491148
}
11501149

11511150
protected static void wipeDataStreams() throws IOException {

0 commit comments

Comments
 (0)