diff --git a/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceAPIsIT.java b/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceAPIsIT.java index bafa14c517..dc41d1fa77 100644 --- a/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceAPIsIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceAPIsIT.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; import lombok.SneakyThrows; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -37,14 +39,20 @@ public class DataSourceAPIsIT extends PPLIntegTestCase { + public static final Logger LOG = LogManager.getLogger(DataSourceAPIsIT.class); + @Override protected void init() throws Exception { + LOG.error("Before init"); loadIndex(Index.DATASOURCES); + LOG.error("After init"); } @After public void cleanUp() throws IOException { + LOG.error("Before clean up"); wipeAllClusterSettings(); + LOG.error("After clean up"); } @AfterClass 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 d4679d7ed5..a46ac83f76 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 @@ -171,6 +171,7 @@ public static void closeRemoteClients() throws IOException { } protected static void wipeAllOpenSearchIndices() throws IOException { + LOG.error("Inside Wipe All Opensearch Indices"); wipeAllOpenSearchIndices(client()); if (remoteClient() != null) { wipeAllOpenSearchIndices(remoteClient()); @@ -180,6 +181,7 @@ protected static void wipeAllOpenSearchIndices() throws IOException { protected static void wipeAllOpenSearchIndices(RestClient client) throws IOException { // include all the indices, included hidden indices. // https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html#cat-indices-api-query-params +<<<<<<< Updated upstream Response response = client.performRequest(new Request("GET", "/_cat/indices?format=json&expand_wildcards=all")); JSONArray jsonArray = new JSONArray(EntityUtils.toString(response.getEntity(), "UTF-8")); @@ -190,6 +192,27 @@ protected static void wipeAllOpenSearchIndices(RestClient client) throws IOExcep // 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)); +======= + try { + Response response = + client.performRequest( + new Request("GET", "/_cat/indices?format=json&expand_wildcards=all")); + JSONArray jsonArray = new JSONArray(EntityUtils.toString(response.getEntity(), "UTF-8")); + for (Object object : jsonArray) { + JSONObject jsonObject = (JSONObject) object; + String indexName = jsonObject.getString("index"); + 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)); + LOG.info("Deleted index: {}", 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); +>>>>>>> Stashed changes } } catch (Exception e) { // TODO: Ignore index delete error for now. Remove this if strict check on system index