Skip to content

Commit

Permalink
Integ test logging
Browse files Browse the repository at this point in the history
Signed-off-by: Vamsi Manohar <[email protected]>
  • Loading branch information
vmmusings committed Mar 21, 2024
1 parent 109af96 commit d77ef30
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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"));
Expand All @@ -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
Expand Down

0 comments on commit d77ef30

Please sign in to comment.