From ccd745d71bfe3d6344b8acb63040f45d3562e9b7 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 29 Oct 2024 10:13:56 -0400 Subject: [PATCH 1/3] Use adminClient when searching system index in integ tests Signed-off-by: Craig Perkins --- .../indexstatemanagement/IndexStateManagementRestTestCase.kt | 4 ++-- .../opensearch/indexmanagement/rollup/RollupRestTestCase.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt index 1e37cdf4b..40027330e 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt @@ -379,7 +379,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase() } """.trimIndent() val response = - client().makeRequest( + adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_search", emptyMap(), StringEntity(request, ContentType.APPLICATION_JSON), ) @@ -854,7 +854,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) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt index 6e527abfb..11ff005be 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt @@ -209,7 +209,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) } From a01f29777c2d60ed668b1910250084c4051d9137 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 29 Oct 2024 10:25:29 -0400 Subject: [PATCH 2/3] Replace more instances Signed-off-by: Craig Perkins --- .../indexstatemanagement/IndexStateManagementRestTestCase.kt | 4 ++-- .../resthandler/IndexStateManagementRestApiIT.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt index 40027330e..68c25a6d6 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementRestTestCase.kt @@ -394,7 +394,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) @@ -911,7 +911,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 a102d4e8e..f3ce9bc02 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/IndexStateManagementRestApiIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/IndexStateManagementRestApiIT.kt @@ -150,7 +150,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 @@ -271,7 +271,7 @@ class IndexStateManagementRestApiIT : IndexStateManagementRestTestCase() { } """.trimIndent() val response = - client().makeRequest( + adminClient().makeRequest( "POST", "$INDEX_MANAGEMENT_INDEX/_search", emptyMap(), StringEntity(request, ContentType.APPLICATION_JSON), ) From 8d9c0e7d4460dc0610f5cd35f094017a8f3831fc Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 29 Oct 2024 10:56:54 -0400 Subject: [PATCH 3/3] Another instance Signed-off-by: Craig Perkins --- .../org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt index 11ff005be..12e75b4e3 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/RollupRestTestCase.kt @@ -220,7 +220,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)