From 6c154685ffc2cf4a38470983233981a6b57c29ee Mon Sep 17 00:00:00 2001 From: gaobinlong Date: Wed, 11 Oct 2023 16:59:49 +0800 Subject: [PATCH] Fix integration test failure by allowing direct access to system index warning Signed-off-by: gaobinlong --- .../integtest/PluginRestTestCase.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt index cdfae6b0..73e153f9 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt @@ -380,6 +380,25 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { ?: NotificationConfigIndex.DEFAULT_SCHEMA_VERSION } + // only refresh the notification config index to avoid too many warnings + @Throws(IOException::class) + override fun refreshAllIndices() { + val refreshRequest = Request("POST", NotificationConfigIndex.INDEX_NAME + "/_refresh") + val requestOptions = RequestOptions.DEFAULT.toBuilder() + // Allow direct access to system index warning + requestOptions.setWarningsHandler { warnings: List -> + if (warnings.isEmpty()) { + return@setWarningsHandler false + } else if (warnings.size > 1) { + return@setWarningsHandler true + } else { + return@setWarningsHandler !warnings[0].startsWith("this request accesses system indices:") + } + } + refreshRequest.setOptions(requestOptions) + client().performRequest(refreshRequest) + } + protected class ClusterSetting(val type: String, val name: String, var value: Any?) { init { this.value = if (value == null) "null" else "\"" + value + "\""