diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/OpenSearchSQLRestTestCase.java b/integ-test/src/test/java/org/opensearch/sql/legacy/OpenSearchSQLRestTestCase.java index 0369ee715a..483f027506 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/OpenSearchSQLRestTestCase.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/OpenSearchSQLRestTestCase.java @@ -19,6 +19,8 @@ import org.apache.http.message.BasicHeader; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.util.EntityUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.JSONArray; import org.json.JSONObject; import org.opensearch.client.Request; @@ -35,6 +37,8 @@ */ public abstract class OpenSearchSQLRestTestCase extends OpenSearchRestTestCase { + private static final Logger LOG = LogManager.getLogger(); + protected boolean isHttps() { boolean isHttps = Optional.ofNullable(System.getProperty("https")) .map("true"::equalsIgnoreCase).orElse(false); @@ -73,9 +77,14 @@ protected static void wipeAllOpenSearchIndices() throws IOException { for (Object object : jsonArray) { JSONObject jsonObject = (JSONObject) object; String indexName = jsonObject.getString("index"); - //.opendistro_security isn't allowed to delete from cluster - if (!indexName.startsWith(".opensearch_dashboards") && !indexName.startsWith(".opendistro")) { - client().performRequest(new Request("DELETE", "/" + indexName)); + try { + // System index, mostly named .opensearch-xxx or .opendistro-xxx, are not allowed to delete + if (!indexName.startsWith(".opensearch") && !indexName.startsWith(".opendistro")) { + client().performRequest(new Request("DELETE", "/" + indexName)); + } + } catch (Exception e) { + // TODO: Ignore index delete error for now. Remove this if strict check on system index added above. + LOG.warn("Failed to delete index: " + indexName, e); } } }