From b7ddbb693128e5de31482a0d2bc8c16eef710662 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 2 Aug 2024 18:16:03 -0400 Subject: [PATCH] Use adminClient instead of client when interacting with system index in integTests (#1222) --- .../opensearch/indexmanagement/IndexManagementIndicesIT.kt | 2 +- .../opensearch/indexmanagement/IndexManagementRestTestCase.kt | 4 ++-- .../org/opensearch/indexmanagement/SecurityRestTestCase.kt | 2 +- .../notification/filter/NotificationActionListenerIT.kt | 2 +- .../notification/resthandler/LRONConfigRestTestCase.kt | 2 +- .../notification/resthandler/RestIndexLRONConfigActionIT.kt | 2 +- .../indexstatemanagement/IndexStateManagementRestTestCase.kt | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementIndicesIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementIndicesIT.kt index 24a46ace9..21612f19c 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementIndicesIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementIndicesIT.kt @@ -135,7 +135,7 @@ class IndexManagementIndicesIT : IndexStateManagementRestTestCase() { .replace("\"schema_version\": $configSchemaVersion", "\"schema_version\": 0") val entity = StringEntity(mapping, ContentType.APPLICATION_JSON) - client().makeRequest( + adminClient().makeRequest( RestRequest.Method.PUT.toString(), "/$INDEX_MANAGEMENT_INDEX/_mapping", emptyMap(), entity, ) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt index bb51a1d6b..a55809379 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt @@ -219,7 +219,7 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() { // Since from the log, this happens very fast (within 0.1~0.2s), the above cluster explain may not have the granularity to catch this. logger.info("Update rollup start time to $startTimeMillis") val response = - client().makeRequest( + adminClient().makeRequest( "POST", "${IndexManagementPlugin.INDEX_MANAGEMENT_INDEX}/_update/${update.id}?wait_for_active_shards=$waitForActiveShards&refresh=true", StringEntity( "{\"doc\":{\"rollup\":{\"schedule\":{\"interval\":{\"start_time\":" + @@ -249,7 +249,7 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() { val startTimeMillis = desiredStartTimeMillis ?: (Instant.now().toEpochMilli() - millis) val waitForActiveShards = if (isMultiNode) "all" else "1" val response = - client().makeRequest( + adminClient().makeRequest( "POST", "${IndexManagementPlugin.INDEX_MANAGEMENT_INDEX}/_update/${update.id}?wait_for_active_shards=$waitForActiveShards", StringEntity( "{\"doc\":{\"transform\":{\"schedule\":{\"interval\":{\"start_time\":" + diff --git a/src/test/kotlin/org/opensearch/indexmanagement/SecurityRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/SecurityRestTestCase.kt index d6125a7d8..f6f4231f9 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/SecurityRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/SecurityRestTestCase.kt @@ -492,7 +492,7 @@ abstract class SecurityRestTestCase : IndexManagementRestTestCase() { } protected fun deleteIndexByName(index: String) { - executeRequest(request = Request(RestRequest.Method.DELETE.name, "/$index"), client = client()) + executeRequest(request = Request(RestRequest.Method.DELETE.name, "/$index"), client = adminClient()) } protected fun validateSourceIndex(indexName: String) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/NotificationActionListenerIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/NotificationActionListenerIT.kt index d95bc26a1..17c855d09 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/NotificationActionListenerIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/NotificationActionListenerIT.kt @@ -401,7 +401,7 @@ class NotificationActionListenerIT : IndexManagementRestTestCase() { closeIndex("source-index") // delete system index - client.makeRequest("DELETE", IndexManagementPlugin.CONTROL_CENTER_INDEX) + adminClient().makeRequest("DELETE", IndexManagementPlugin.CONTROL_CENTER_INDEX) val response = client.makeRequest( diff --git a/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/LRONConfigRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/LRONConfigRestTestCase.kt index 00e62a2d1..327e14550 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/LRONConfigRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/LRONConfigRestTestCase.kt @@ -31,7 +31,7 @@ abstract class LRONConfigRestTestCase : IndexManagementRestTestCase() { @After fun removeAllDocs() { try { - client().makeRequest( + adminClient().makeRequest( "POST", "${IndexManagementPlugin.CONTROL_CENTER_INDEX}/_delete_by_query", mapOf("refresh" to "true"), diff --git a/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/RestIndexLRONConfigActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/RestIndexLRONConfigActionIT.kt index 1e7cdd79a..aa83df837 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/RestIndexLRONConfigActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/controlcenter/notification/resthandler/RestIndexLRONConfigActionIT.kt @@ -182,7 +182,7 @@ class RestIndexLRONConfigActionIT : LRONConfigRestTestCase() { val lronConfig = randomLRONConfig(taskId = randomTaskId(nodeId = nodeIdsInRestIT.random())) createLRONConfig(lronConfig) - val response = client().makeRequest("GET", "/${IndexManagementPlugin.CONTROL_CENTER_INDEX}/_mapping") + val response = adminClient().makeRequest("GET", "/${IndexManagementPlugin.CONTROL_CENTER_INDEX}/_mapping") val parserMap = createParser(XContentType.JSON.xContent(), response.entity.content).map() as Map> val mappingsMap = parserMap[IndexManagementPlugin.CONTROL_CENTER_INDEX]!!["mappings"] as Map val expected = diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt index 21f27f5af..b2c8d0933 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt @@ -469,7 +469,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() val waitForActiveShards = if (isMultiNode) "all" else "1" val endpoint = "$INDEX_MANAGEMENT_INDEX/_update/${update.id}?wait_for_active_shards=$waitForActiveShards;retry_on_conflict=$retryOnConflict" val response = - client().makeRequest( + adminClient().makeRequest( "POST", endpoint, StringEntity( "{\"doc\":{\"managed_index\":{\"schedule\":{\"interval\":{\"start_time\":" +