Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.opensearch.Version
import org.opensearch.common.CheckedFunction
import org.opensearch.commons.alerting.model.remote.monitors.RemoteMonitorTrigger
import org.opensearch.commons.alerting.util.IndexUtils.Companion.MONITOR_MAX_INPUTS
import org.opensearch.commons.alerting.util.IndexUtils.Companion.MONITOR_MAX_TRIGGERS
Comment thread
manaswini1920 marked this conversation as resolved.
Resolved
import org.opensearch.commons.alerting.util.IndexUtils.Companion.NO_SCHEMA_VERSION
import org.opensearch.commons.alerting.util.IndexUtils.Companion._ID
import org.opensearch.commons.alerting.util.IndexUtils.Companion._VERSION
Expand Down Expand Up @@ -76,7 +75,6 @@ data class Monitor(
require(enabledTime == null)
}
require(inputs.size <= MONITOR_MAX_INPUTS) { "Monitors can only have $MONITOR_MAX_INPUTS search input." }
require(triggers.size <= MONITOR_MAX_TRIGGERS) { "Monitors can only support up to $MONITOR_MAX_TRIGGERS triggers." }
Comment thread
manaswini1920 marked this conversation as resolved.
Resolved
if (this.isBucketLevelMonitor()) {
inputs.forEach { input ->
require(input is SearchInput) { "Unsupported input [$input] for Monitor" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class IndexUtils {
const val MONITOR_MAX_INPUTS = 1
const val WORKFLOW_MAX_INPUTS = 1

const val MONITOR_MAX_TRIGGERS = 10

const val _ID = "_id"
const val _VERSION = "_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package org.opensearch.commons.alerting
import org.junit.jupiter.api.Test
import org.opensearch.commons.alerting.model.Trigger
import org.opensearch.test.OpenSearchTestCase
import java.lang.IllegalArgumentException
import java.time.Instant
import kotlin.test.assertEquals

internal class MonitorTests {
@Test
Expand All @@ -27,20 +27,17 @@ internal class MonitorTests {
}

@Test
fun `test max triggers`() {
fun `test monitor allows more than 10 triggers`() {
val monitor = randomQueryLevelMonitor()

val tooManyTriggers = mutableListOf<Trigger>()
val manyTriggers = mutableListOf<Trigger>()
var i = 0
while (i <= 10) {
tooManyTriggers.add(randomQueryLevelTrigger())
manyTriggers.add(randomQueryLevelTrigger())
++i
}

try {
monitor.copy(triggers = tooManyTriggers)
OpenSearchTestCase.fail("Monitor with too many triggers should be rejected.")
} catch (e: IllegalArgumentException) {
}
val monitorWithManyTriggers = monitor.copy(triggers = manyTriggers)
assertEquals(11, monitorWithManyTriggers.triggers.size)
}
}
Loading