|
26 | 26 | import org.apache.http.ssl.SSLContextBuilder; |
27 | 27 | import org.apache.http.ssl.SSLContexts; |
28 | 28 | import org.apache.http.util.EntityUtils; |
| 29 | +import org.apache.logging.log4j.LogManager; |
| 30 | +import org.apache.logging.log4j.Logger; |
29 | 31 | import org.elasticsearch.Build; |
30 | 32 | import org.elasticsearch.TransportVersion; |
31 | 33 | import org.elasticsearch.TransportVersions; |
@@ -160,6 +162,8 @@ public abstract class ESRestTestCase extends ESTestCase { |
160 | 162 |
|
161 | 163 | private static final Pattern SEMANTIC_VERSION_PATTERN = Pattern.compile("^(\\d+\\.\\d+\\.\\d+)\\D?.*"); |
162 | 164 |
|
| 165 | + private static final Logger SUITE_LOGGER = LogManager.getLogger(ESRestTestCase.class); |
| 166 | + |
163 | 167 | /** |
164 | 168 | * Convert the entity from a {@link Response} into a map of maps. |
165 | 169 | * Consumes the underlying HttpEntity, releasing any resources it may be holding. |
@@ -1131,6 +1135,19 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE |
1131 | 1135 | } |
1132 | 1136 | final Request deleteRequest = new Request("DELETE", Strings.collectionToCommaDelimitedString(indexPatterns)); |
1133 | 1137 | deleteRequest.addParameter("expand_wildcards", "open,closed,hidden"); |
| 1138 | + |
| 1139 | + // If system index warning, ignore but log |
| 1140 | + deleteRequest.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(warnings -> { |
| 1141 | + for (String warning : warnings) { |
| 1142 | + if (warning.startsWith("this request accesses system indices:")) { |
| 1143 | + SUITE_LOGGER.warn("Ignoring system index access warning during test cleanup: {}", warning); |
| 1144 | + } else { |
| 1145 | + return true; |
| 1146 | + } |
| 1147 | + } |
| 1148 | + return false; |
| 1149 | + })); |
| 1150 | + |
1134 | 1151 | final Response response = adminClient().performRequest(deleteRequest); |
1135 | 1152 | try (InputStream is = response.getEntity().getContent()) { |
1136 | 1153 | assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged")); |
|
0 commit comments