From 92acc2a8a8bb7b5b88cad58edd531cc0f9c0a516 Mon Sep 17 00:00:00 2001 From: Subhobrata Dey Date: Sun, 30 Jun 2024 18:29:42 -0700 Subject: [PATCH] fix multi-node test failures (#1588) Signed-off-by: Subhobrata Dey --- .../RemoteDocumentLevelMonitorRunner.kt | 7 +++---- sample-remote-monitor-plugin/build.gradle | 2 -- .../alerting/spi/RemoteMonitorRunner.kt | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/remote/monitors/RemoteDocumentLevelMonitorRunner.kt b/alerting/src/main/kotlin/org/opensearch/alerting/remote/monitors/RemoteDocumentLevelMonitorRunner.kt index aa0d186e6..c74b4e23c 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/remote/monitors/RemoteDocumentLevelMonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/remote/monitors/RemoteDocumentLevelMonitorRunner.kt @@ -18,7 +18,6 @@ import org.opensearch.cluster.routing.ShardRouting import org.opensearch.cluster.service.ClusterService import org.opensearch.commons.alerting.action.DocLevelMonitorFanOutResponse import org.opensearch.commons.alerting.model.ActionRunResult -import org.opensearch.commons.alerting.model.DocLevelMonitorInput import org.opensearch.commons.alerting.model.DocumentLevelTriggerRunResult import org.opensearch.commons.alerting.model.InputRunResults import org.opensearch.commons.alerting.model.Monitor @@ -53,7 +52,7 @@ class RemoteDocumentLevelMonitorRunner : MonitorRunner() { try { validate(monitor) } catch (e: Exception) { - logger.error("Failed to start Document-level-monitor. Error: ${e.message}") + logger.error("Failed to start Document-level-monitor. Error: $e") monitorResult = monitorResult.copy(error = AlertingException.wrap(e)) } @@ -199,11 +198,11 @@ class RemoteDocumentLevelMonitorRunner : MonitorRunner() { throw IOException("Only one input is supported with remote document-level-monitor.") } - if (monitor.inputs[0].name() != DocLevelMonitorInput.DOC_LEVEL_INPUT_FIELD) { + if (monitor.inputs[0].name() != RemoteDocLevelMonitorInput.REMOTE_DOC_LEVEL_MONITOR_INPUT_FIELD) { throw IOException("Invalid input with remote document-level-monitor.") } - if ((monitor.inputs[0] as DocLevelMonitorInput).indices.isEmpty()) { + if ((monitor.inputs[0] as RemoteDocLevelMonitorInput).docLevelMonitorInput.indices.isEmpty()) { throw IllegalArgumentException("DocLevelMonitorInput has no indices") } } diff --git a/sample-remote-monitor-plugin/build.gradle b/sample-remote-monitor-plugin/build.gradle index 8941a3855..e1d38dbea 100644 --- a/sample-remote-monitor-plugin/build.gradle +++ b/sample-remote-monitor-plugin/build.gradle @@ -44,8 +44,6 @@ dependencies { compileOnly "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}" - // Needed for integ tests - zipArchive group: 'org.opensearch.plugin', name:'alerting', version: "${opensearch_build}" } def es_tmp_dir = rootProject.file('build/private/es_tmp').absoluteFile diff --git a/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt b/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt index bf4ee9601..a2ceac7ba 100644 --- a/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt +++ b/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt @@ -12,7 +12,12 @@ import org.opensearch.cluster.service.ClusterService import org.opensearch.commons.alerting.action.DocLevelMonitorFanOutAction import org.opensearch.commons.alerting.action.DocLevelMonitorFanOutRequest import org.opensearch.commons.alerting.action.DocLevelMonitorFanOutResponse -import org.opensearch.commons.alerting.model.* +import org.opensearch.commons.alerting.model.IndexExecutionContext +import org.opensearch.commons.alerting.model.Monitor +import org.opensearch.commons.alerting.model.MonitorMetadata +import org.opensearch.commons.alerting.model.MonitorRunResult +import org.opensearch.commons.alerting.model.TriggerRunResult +import org.opensearch.commons.alerting.model.WorkflowRunContext import org.opensearch.commons.alerting.util.AlertingException import org.opensearch.core.action.ActionListener import org.opensearch.core.common.breaker.CircuitBreakingException @@ -85,7 +90,16 @@ open class RemoteMonitorRunner { dryrun, monitorMetadata, executionId, - indexExecutionContext = null, + indexExecutionContext = IndexExecutionContext( + listOf(), + mutableMapOf(), + mutableMapOf(), + "", + "", + listOf(), + listOf(), + listOf() + ), nodeShardAssignments[node.key]!!.toList(), concreteIndices, workflowRunContext