From 7c824704dd3d06ad5e917a12859fa49647d7b46f Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 10:32:32 -0500 Subject: [PATCH] Permissive warnings handler Signed-off-by: Craig Perkins --- .../resthandler/RestChangePolicyActionIT.kt | 5 +++++ .../rollup/resthandler/RestStartRollupActionIT.kt | 5 +++++ .../rollup/resthandler/RestStopRollupActionIT.kt | 5 +++++ .../resthandler/RestDeleteSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestExplainSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestGetSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestIndexSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestStartSnapshotManagementIT.kt | 9 +++++++-- .../resthandler/RestStopSnapshotManagementIT.kt | 5 +++++ .../transform/resthandler/RestDeleteTransformActionIT.kt | 5 +++++ .../resthandler/RestExplainTransformActionIT.kt | 5 +++++ 11 files changed, 57 insertions(+), 2 deletions(-) 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 ee2621bca..5d12c032b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt @@ -7,7 +7,9 @@ package org.opensearch.indexmanagement.indexstatemanagement.resthandler import org.junit.Before import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -92,6 +94,9 @@ class RestChangePolicyActionIT : IndexStateManagementRestTestCase() { fun `test nonexistent ism config index`() { if (indexExists(INDEX_MANAGEMENT_INDEX)) { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) } try { 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 e165a5b71..02eea1a64 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.rollup.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices @@ -203,6 +205,9 @@ class RestStartRollupActionIT : RollupRestAPITestCase() { fun `test start rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = 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 4789e1f50..ecc4f94b7 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.rollup.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices @@ -259,6 +261,9 @@ class RestStopRollupActionIT : RollupRestAPITestCase() { fun `test stop rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = 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 13ecd4a71..07081bd65 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -40,6 +42,9 @@ class RestDeleteSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test deleting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("DELETE", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_policy") fail("expected 404 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 ce64e240f..bf5da3c56 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -143,6 +145,9 @@ class RestExplainSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test explain sm policy when config index doesn't exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) explainSMPolicy(randomAlphaOfLength(10)) fail("expected response exception") 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 ee9eba36c..f8e400b7e 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt @@ -8,7 +8,9 @@ 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.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -51,6 +53,9 @@ class RestGetSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test getting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) getSMPolicy(randomAlphaOfLength(20)) fail("expected response exception") 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 f40467f81..0183300f3 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -132,6 +134,9 @@ class RestIndexSnapshotManagementIT : SnapshotManagementRestTestCase() { @Suppress("UNCHECKED_CAST") fun `test mappings after sm policy creation`() { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) createSMPolicy(randomSMPolicy()) 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 8f8d0c67c..ac9ed0fd5 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -61,8 +63,11 @@ class RestStartSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test starting a snapshot management policy with no config index fails`() { try { - val request = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - adminClient().performRequest(request) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() + adminClient().performRequest(deleteISMIndexRequest) 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 fa308e552..ef281e9ec 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -62,6 +64,9 @@ class RestStopSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test stopping a snapshot management policy with no config index fails`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_stop") fail("expected response exception") 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 bc58daa3e..e7ec92eb6 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.transform.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI @@ -79,6 +81,9 @@ class RestDeleteTransformActionIT : TransformRestTestCase() { try { if (indexExists(INDEX_MANAGEMENT_INDEX)) { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) } val res = client().makeRequest("DELETE", "$TRANSFORM_BASE_URI/foobarbaz") 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 b9af789d7..b301eb915 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt @@ -7,7 +7,9 @@ package org.opensearch.indexmanagement.transform.resthandler import org.junit.Assert import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI @@ -162,6 +164,9 @@ class RestExplainTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test explain transform when config doesnt exist`() { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() 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")