From c258552e9da3014a9b9557653304829a957bb85a Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 29 Oct 2024 11:47:15 -0400 Subject: [PATCH] Use adminClient when searching system index in integ tests (#1286) * Use adminClient when searching system index in integ tests Signed-off-by: Craig Perkins * Replace more instances Signed-off-by: Craig Perkins * Another instance Signed-off-by: Craig Perkins --------- Signed-off-by: Craig Perkins (cherry picked from commit ca2ada20d59be44d0cd10c38658eb9eb20c1d64c) --- .../IndexStateManagementRestTestCase.kt | 8 ++++---- .../resthandler/IndexStateManagementRestApiIT.kt | 4 ++-- .../indexmanagement/rollup/RollupRestTestCase.kt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt index 829a5678c..eba400beb 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt @@ -365,7 +365,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() } } """.trimIndent() - val response = client().makeRequest( + val response = adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_search", emptyMap(), StringEntity(request, APPLICATION_JSON), ) @@ -380,7 +380,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() } protected fun getManagedIndexConfigByDocId(id: String): ManagedIndexConfig? { - val response = client().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$id") + val response = adminClient().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$id") assertEquals("Request failed", RestStatus.OK, response.restStatus()) val getResponse = GetResponse.fromXContent(createParser(jsonXContent, response.entity.content)) assertTrue("Did not find managed index config", getResponse.isExists) @@ -832,7 +832,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() metadataId: String, header: BasicHeader = BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"), ): RollupMetadata { - val response = client().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId", null, header) + val response = adminClient().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId", null, header) assertEquals("Unable to get rollup metadata $metadataId", RestStatus.OK, response.restStatus()) val parser = createParser(XContentType.JSON.xContent(), response.entity.content) @@ -889,7 +889,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() metadataId: String, header: BasicHeader = BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"), ): TransformMetadata { - val response = client().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId", null, header) + val response = adminClient().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId", null, header) assertEquals("Unable to get transform metadata $metadataId", RestStatus.OK, response.restStatus()) val parser = createParser(XContentType.JSON.xContent(), response.entity.content) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/IndexStateManagementRestApiIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/IndexStateManagementRestApiIT.kt index c23b0c48a..9eeaa9886 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/IndexStateManagementRestApiIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/IndexStateManagementRestApiIT.kt @@ -148,7 +148,7 @@ class IndexStateManagementRestApiIT : IndexStateManagementRestTestCase() { fun `test mappings after policy creation`() { createRandomPolicy() - val response = client().makeRequest("GET", "/$INDEX_MANAGEMENT_INDEX/_mapping") + val response = adminClient().makeRequest("GET", "/$INDEX_MANAGEMENT_INDEX/_mapping") val parserMap = createParser(XContentType.JSON.xContent(), response.entity.content).map() as Map> val mappingsMap = parserMap[INDEX_MANAGEMENT_INDEX]!!["mappings"] as Map @@ -265,7 +265,7 @@ class IndexStateManagementRestApiIT : IndexStateManagementRestTestCase() { } } """.trimIndent() - val response = client().makeRequest( + val response = adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_search", emptyMap(), StringEntity(request, APPLICATION_JSON), ) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt index c818d293e..117ec111f 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt @@ -205,7 +205,7 @@ abstract class RollupRestTestCase : IndexManagementRestTestCase() { refresh: Boolean = true, header: BasicHeader = BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"), ): RollupMetadata { - val response = client().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId?refresh=$refresh", null, header) + val response = adminClient().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId?refresh=$refresh", null, header) assertEquals("Unable to get rollup metadata $metadataId", RestStatus.OK, response.restStatus()) return parseRollupMetadata(response) } @@ -216,7 +216,7 @@ abstract class RollupRestTestCase : IndexManagementRestTestCase() { refresh: Boolean = true, header: BasicHeader = BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"), ): RollupMetadata { - val response = client().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId?routing=$routingId&refresh=$refresh", null, header) + val response = adminClient().makeRequest("GET", "$INDEX_MANAGEMENT_INDEX/_doc/$metadataId?routing=$routingId&refresh=$refresh", null, header) assertEquals("Unable to get rollup metadata $metadataId", RestStatus.OK, response.restStatus()) return parseRollupMetadata(response)