From 9bbd136f1aeeffeaf5ed399f37655f139e258648 Mon Sep 17 00:00:00 2001 From: Vamsi Manohar Date: Wed, 31 Jul 2024 15:59:37 -0700 Subject: [PATCH] Fixed integ test delete myindex issue and wipe All indices with security enabled domain (#2878) Signed-off-by: Vamsi Manohar --- .../sql/datasource/DataSourceEnabledIT.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceEnabledIT.java b/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceEnabledIT.java index b0bc87a0c6..a53c04d871 100644 --- a/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceEnabledIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/datasource/DataSourceEnabledIT.java @@ -7,8 +7,10 @@ import static org.opensearch.sql.legacy.TestUtils.getResponseBody; +import java.io.IOException; import lombok.SneakyThrows; import org.json.JSONObject; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.opensearch.client.Request; @@ -18,9 +20,9 @@ public class DataSourceEnabledIT extends PPLIntegTestCase { - @Override - protected boolean preserveClusterUponCompletion() { - return false; + @After + public void cleanUp() throws IOException { + wipeAllClusterSettings(); } @Test @@ -39,6 +41,7 @@ public void testDataSourceCreationWithDefaultSettings() { assertSelectFromDataSourceReturnsSuccess(); assertSelectFromDummyIndexInValidDataSourceDataSourceReturnsDoesNotExist(); deleteSelfDataSourceCreated(); + deleteIndex(); } @Test @@ -55,6 +58,7 @@ public void testAfterPreviousEnable() { assertAsyncQueryApiDisabled(); setDataSourcesEnabled("transient", true); deleteSelfDataSourceCreated(); + deleteIndex(); } @SneakyThrows @@ -98,6 +102,12 @@ private void createIndex() { Assert.assertEquals(200, response.getStatusLine().getStatusCode()); } + private void deleteIndex() { + Request request = new Request("DELETE", "/myindex"); + Response response = performRequest(request); + Assert.assertEquals(200, response.getStatusLine().getStatusCode()); + } + private void createOpenSearchDataSource() { Request request = new Request("POST", "/_plugins/_query/_datasources"); request.setJsonEntity(