From 395317dcc40762fc05b4320885c2ea27be572324 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 10 Sep 2024 21:29:22 -0400 Subject: [PATCH] Update CI check for integ-test-with-security to run all integ tests with security (#1243) * Run all integ tests with security Signed-off-by: Craig Perkins * Use adminClient when deleting ISM index in RestStopRollupActionIT Signed-off-by: Craig Perkins * Update RolloverActionIT Signed-off-by: Craig Perkins * Fix RestStopSnapshotManagementIT Signed-off-by: Craig Perkins * Fix RestChangePolicyActionIT Signed-off-by: Craig Perkins * Fix more tests Signed-off-by: Craig Perkins * Fix more tests Signed-off-by: Craig Perkins * Fix more tests Signed-off-by: Craig Perkins * Fix RestExplainTransformActionIT Signed-off-by: Craig Perkins * Fix more tests Signed-off-by: Craig Perkins * Make sure read from system index also uses adminClient Signed-off-by: Craig Perkins --------- Signed-off-by: Craig Perkins --- .github/workflows/security-test-workflow.yml | 2 +- .../IndexStateManagementRestTestCase.kt | 4 ++-- .../indexstatemanagement/action/RolloverActionIT.kt | 2 +- .../resthandler/RestChangePolicyActionIT.kt | 8 ++++++-- .../rollup/resthandler/RestStartRollupActionIT.kt | 9 ++++++--- .../rollup/resthandler/RestStopRollupActionIT.kt | 7 +++++-- .../indexmanagement/rollup/runner/RollupRunnerIT.kt | 2 +- .../snapshotmanagement/SnapshotManagementRestTestCase.kt | 4 ++-- .../resthandler/RestDeleteSnapshotManagementIT.kt | 4 +++- .../resthandler/RestExplainSnapshotManagementIT.kt | 4 +++- .../resthandler/RestGetSnapshotManagementIT.kt | 5 ++++- .../resthandler/RestIndexSnapshotManagementIT.kt | 4 +++- .../resthandler/RestStartSnapshotManagementIT.kt | 5 ++++- .../resthandler/RestStopSnapshotManagementIT.kt | 5 ++++- .../indexmanagement/transform/TransformRestTestCase.kt | 2 +- .../transform/resthandler/RestDeleteTransformActionIT.kt | 6 +++++- .../resthandler/RestExplainTransformActionIT.kt | 6 ++++-- 17 files changed, 55 insertions(+), 24 deletions(-) diff --git a/.github/workflows/security-test-workflow.yml b/.github/workflows/security-test-workflow.yml index ddfe712fa..d88750bda 100644 --- a/.github/workflows/security-test-workflow.yml +++ b/.github/workflows/security-test-workflow.yml @@ -40,7 +40,7 @@ jobs: - name: Run integration tests run: | chown -R 1000:1000 `pwd` - su `id -un 1000` -c "./gradlew integTest -Dsecurity=true -Dhttps=true --tests '*SecurityBehaviorIT'" + su `id -un 1000` -c "./gradlew integTest -Dsecurity=true -Dhttps=true --tests '*IT'" - name: Upload failed logs uses: actions/upload-artifact@v2 if: failure() diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt index b2c8d0933..1e37cdf4b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt @@ -351,7 +351,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() } """.trimIndent() val res = - client().makeRequest( + adminClient().makeRequest( "PUT", "$index/_settings", emptyMap(), StringEntity(body, ContentType.APPLICATION_JSON), ) @@ -483,7 +483,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() protected fun updateManagedIndexConfigPolicySeqNo(update: ManagedIndexConfig) { val response = - client().makeRequest( + adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_update/${update.id}", StringEntity( "{\"doc\":{\"managed_index\":{\"policy_seq_no\":\"${update.policySeqNo}\"}}}", diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/RolloverActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/RolloverActionIT.kt index a45120b6c..c12a77cba 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/RolloverActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/RolloverActionIT.kt @@ -784,7 +784,7 @@ class RolloverActionIT : IndexStateManagementRestTestCase() { } // Manually produce transaction failure val response = - client().makeRequest( + adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_update/${managedIndexConfig.id}%23metadata", StringEntity( "{\n" + diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt index 463b745d4..73e04f928 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt @@ -6,6 +6,7 @@ package org.opensearch.indexmanagement.indexstatemanagement.resthandler import org.junit.Before +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus @@ -35,7 +36,7 @@ import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StateMetaDa import org.opensearch.indexmanagement.waitFor import org.opensearch.rest.RestRequest import java.time.Instant -import java.util.Locale +import java.util.* class RestChangePolicyActionIT : IndexStateManagementRestTestCase() { private val testIndexName = javaClass.simpleName.lowercase(Locale.ROOT) @@ -89,7 +90,10 @@ class RestChangePolicyActionIT : IndexStateManagementRestTestCase() { } fun `test nonexistent ism config index`() { - if (indexExists(INDEX_MANAGEMENT_INDEX)) deleteIndex(INDEX_MANAGEMENT_INDEX) + if (indexExists(INDEX_MANAGEMENT_INDEX)) { + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) + } try { val changePolicy = ChangePolicy("some_id", null, emptyList(), false) client().makeRequest( diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt index 45a82ef39..6baf8b474 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt @@ -5,11 +5,13 @@ package org.opensearch.indexmanagement.rollup.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices import org.opensearch.indexmanagement.IndexManagementPlugin +import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.ROLLUP_JOBS_BASE_URI import org.opensearch.indexmanagement.common.model.dimension.DateHistogram import org.opensearch.indexmanagement.indexstatemanagement.util.INDEX_HIDDEN @@ -22,7 +24,7 @@ import org.opensearch.indexmanagement.waitFor import org.opensearch.jobscheduler.spi.schedule.IntervalSchedule import java.time.Instant import java.time.temporal.ChronoUnit -import java.util.Locale +import java.util.* class RestStartRollupActionIT : RollupRestAPITestCase() { private val testName = javaClass.simpleName.lowercase(Locale.ROOT) @@ -200,7 +202,8 @@ class RestStartRollupActionIT : RollupRestAPITestCase() { fun `test start rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = Settings.builder() @@ -253,7 +256,7 @@ class RestStartRollupActionIT : RollupRestAPITestCase() { // clearing the config index to prevent other tests using this multi shard index Thread.sleep(2000L) - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + adminClient().performRequest(deleteISMIndexRequest) Thread.sleep(2000L) } } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt index d4eada87d..4789e1f50 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt @@ -5,11 +5,13 @@ package org.opensearch.indexmanagement.rollup.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices import org.opensearch.indexmanagement.IndexManagementPlugin +import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.ROLLUP_JOBS_BASE_URI import org.opensearch.indexmanagement.common.model.dimension.DateHistogram import org.opensearch.indexmanagement.common.model.dimension.Terms @@ -256,7 +258,8 @@ class RestStopRollupActionIT : RollupRestAPITestCase() { fun `test stop rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = Settings.builder() @@ -313,7 +316,7 @@ class RestStopRollupActionIT : RollupRestAPITestCase() { // clearing the config index to prevent other tests using this multi shard index Thread.sleep(2000L) - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + adminClient().performRequest(deleteISMIndexRequest) Thread.sleep(2000L) } } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt index 09dedecb8..e085f6c30 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt @@ -1466,7 +1466,7 @@ class RollupRunnerIT : RollupRestTestCase() { // - Source index with pattern mapping to some closed indices private fun deleteRollupMetadata(metadataId: String) { - val response = client().makeRequest("DELETE", "${IndexManagementPlugin.INDEX_MANAGEMENT_INDEX}/_doc/$metadataId") + val response = adminClient().makeRequest("DELETE", "${IndexManagementPlugin.INDEX_MANAGEMENT_INDEX}/_doc/$metadataId") assertEquals("Unable to delete rollup metadata $metadataId", RestStatus.OK, response.restStatus()) } } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SnapshotManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SnapshotManagementRestTestCase.kt index 5c98260fa..d4078288e 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SnapshotManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SnapshotManagementRestTestCase.kt @@ -139,7 +139,7 @@ abstract class SnapshotManagementRestTestCase : IndexManagementRestTestCase() { val startTimeMillis = desiredStartTimeMillis ?: (now().toEpochMilli() - millis) val waitForActiveShards = if (isMultiNode) "all" else "1" val response = - client().makeRequest( + adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_update/${update.id}?wait_for_active_shards=$waitForActiveShards", StringEntity( "{\"doc\":{\"sm_policy\":{\"schedule\":{\"interval\":{\"start_time\":\"$startTimeMillis\"}}}}}", @@ -171,7 +171,7 @@ abstract class SnapshotManagementRestTestCase : IndexManagementRestTestCase() { val startTimeMillis = desiredStartTimeMillis ?: (now().toEpochMilli() - millis) val waitForActiveShards = if (isMultiNode) "all" else "1" val response = - client().makeRequest( + adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_update/${update.metadataID}?wait_for_active_shards=$waitForActiveShards", StringEntity( """ diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt index 7464c0e64..13ecd4a71 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt @@ -5,6 +5,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin @@ -38,7 +39,8 @@ class RestDeleteSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test deleting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { - deleteIndex(INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("DELETE", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_policy") fail("expected 404 ResponseException") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt index 1e8d19848..ce64e240f 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt @@ -5,6 +5,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus @@ -141,7 +142,8 @@ class RestExplainSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test explain sm policy when config index doesn't exist`() { try { - deleteIndex(INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) explainSMPolicy(randomAlphaOfLength(10)) fail("expected response exception") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt index d65e2a5fa..ee9eba36c 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt @@ -7,9 +7,11 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.apache.hc.core5.http.HttpHeaders import org.apache.hc.core5.http.message.BasicHeader +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin +import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.makeRequest import org.opensearch.indexmanagement.opensearchapi.convertToMap import org.opensearch.indexmanagement.snapshotmanagement.SnapshotManagementRestTestCase @@ -48,7 +50,8 @@ class RestGetSnapshotManagementIT : SnapshotManagementRestTestCase() { @Throws(Exception::class) fun `test getting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) getSMPolicy(randomAlphaOfLength(20)) fail("expected response exception") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt index 6a7975dd0..f40467f81 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt @@ -5,6 +5,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus @@ -130,7 +131,8 @@ class RestIndexSnapshotManagementIT : SnapshotManagementRestTestCase() { @Throws(Exception::class) @Suppress("UNCHECKED_CAST") fun `test mappings after sm policy creation`() { - deleteIndex(INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) createSMPolicy(randomSMPolicy()) val response = client().makeRequest("GET", "/$INDEX_MANAGEMENT_INDEX/_mapping") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt index 4ec67011a..8f8d0c67c 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt @@ -5,9 +5,11 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin +import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.makeRequest import org.opensearch.indexmanagement.snapshotmanagement.SnapshotManagementRestTestCase import org.opensearch.indexmanagement.snapshotmanagement.randomSMPolicy @@ -59,7 +61,8 @@ class RestStartSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test starting a snapshot management policy with no config index fails`() { try { - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + val request = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(request) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_start") fail("expected response exception") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt index 77569632f..fa308e552 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt @@ -5,9 +5,11 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin +import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.makeRequest import org.opensearch.indexmanagement.snapshotmanagement.SnapshotManagementRestTestCase import org.opensearch.indexmanagement.snapshotmanagement.randomSMPolicy @@ -59,7 +61,8 @@ class RestStopSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test stopping a snapshot management policy with no config index fails`() { try { - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_stop") fail("expected response exception") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRestTestCase.kt index e62f7321d..557ecc47b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRestTestCase.kt @@ -119,7 +119,7 @@ abstract class TransformRestTestCase : IndexManagementRestTestCase() { protected fun getTransformMetadata(metadataId: String): TransformMetadata { val response = - client().makeRequest( + adminClient().makeRequest( "GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId", null, BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"), ) assertEquals("Unable to get transform metadata $metadataId", RestStatus.OK, response.restStatus()) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt index 0aa807970..bc58daa3e 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt @@ -5,6 +5,7 @@ package org.opensearch.indexmanagement.transform.resthandler +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -76,7 +77,10 @@ class RestDeleteTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test deleting a transform that doesn't exist and config index doesn't exist`() { try { - if (indexExists(INDEX_MANAGEMENT_INDEX)) deleteIndex(INDEX_MANAGEMENT_INDEX) + if (indexExists(INDEX_MANAGEMENT_INDEX)) { + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) + } val res = client().makeRequest("DELETE", "$TRANSFORM_BASE_URI/foobarbaz") fail("expected 404 ResponseException: ${res.asMap()}") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt index 2a66e30a5..b9af789d7 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt @@ -6,9 +6,10 @@ package org.opensearch.indexmanagement.transform.resthandler import org.junit.Assert +import org.opensearch.client.Request import org.opensearch.client.ResponseException import org.opensearch.core.rest.RestStatus -import org.opensearch.indexmanagement.IndexManagementPlugin +import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI import org.opensearch.indexmanagement.makeRequest import org.opensearch.indexmanagement.transform.TransformRestTestCase @@ -160,7 +161,8 @@ class RestExplainTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test explain transform when config doesnt exist`() { - deleteIndex(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(deleteISMIndexRequest) val responseExplicit = client().makeRequest("GET", "$TRANSFORM_BASE_URI/no_config_some_transform/_explain") val expectedResponse = mapOf("no_config_some_transform" to "Failed to search transform metadata") assertEquals("Non-existent transform didn't return null", expectedResponse, responseExplicit.asMap())