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 480a6dc563..9c522134a4 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 @@ -6,7 +6,6 @@ package org.opensearch.sql.datasource; import static org.opensearch.sql.legacy.TestUtils.getResponseBody; -import static org.opensearch.sql.legacy.TestsConstants.DATASOURCES; import lombok.SneakyThrows; import org.json.JSONObject; @@ -25,31 +24,25 @@ protected boolean preserveClusterUponCompletion() { } @Test - public void testDataSourceIndexIsCreatedByDefault() { - assertDataSourceCount(0); - assertSelectFromDataSourceReturnsDoesNotExist(); - assertDataSourceIndexCreated(true); - } - - @Test - public void testDataSourceIndexIsCreatedIfSettingIsEnabled() { - setDataSourcesEnabled("transient", true); + public void testAsyncQueryAPIFailureIfSettingIsDisabled() { + setDataSourcesEnabled("transient", false); assertDataSourceCount(0); assertSelectFromDataSourceReturnsDoesNotExist(); - assertDataSourceIndexCreated(true); + assertAsyncQueryApiDisabled(); } @Test - public void testDataSourceIndexIsNotCreatedIfSettingIsDisabled() { - setDataSourcesEnabled("transient", false); - assertDataSourceCount(0); - assertSelectFromDataSourceReturnsDoesNotExist(); - assertDataSourceIndexCreated(false); - assertAsyncQueryApiDisabled(); + public void testDataSourceCreationWithDefaultSettings() { + createOpenSearchDataSource(); + createIndex(); + assertDataSourceCount(1); + assertSelectFromDataSourceReturnsSuccess(); + assertSelectFromDummyIndexInValidDataSourceDataSourceReturnsDoesNotExist(); } @Test public void testAfterPreviousEnable() { + setDataSourcesEnabled("transient", true); createOpenSearchDataSource(); createIndex(); assertDataSourceCount(1); @@ -141,18 +134,6 @@ private void assertDataSourceCount(int expected) { Assert.assertEquals(expected, jsonBody.getJSONArray("datarows").length()); } - @SneakyThrows - private void assertDataSourceIndexCreated(boolean expected) { - Request request = new Request("GET", "/" + DATASOURCES); - Response response = performRequest(request); - String responseBody = getResponseBody(response); - boolean indexDoesExist = - response.getStatusLine().getStatusCode() == 200 - && responseBody.contains(DATASOURCES) - && responseBody.contains("mappings"); - Assert.assertEquals(expected, indexDoesExist); - } - @SneakyThrows private Response performRequest(Request request) { try {