diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt index 42060e506..27a653d5f 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt @@ -1429,7 +1429,7 @@ class MonitorRunnerServiceIT : AlertingRestTestCase() { // Execute Monitor and check that both Alerts were updated OpenSearchTestCase.waitUntil({ - return@waitUntil (searchAlerts(monitor, AlertIndices.ALL_ALERT_INDEX_PATTERN).size == 2) + return@waitUntil false }, 200, TimeUnit.MILLISECONDS) executeMonitor(monitor.id) currentAlerts = searchAlerts(monitor, AlertIndices.ALL_ALERT_INDEX_PATTERN) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt index 72a12ed95..25e8d319d 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt @@ -812,8 +812,9 @@ class MonitorRestApiIT : AlertingRestTestCase() { // Wait 5 seconds for event to be processed and alerts moved OpenSearchTestCase.waitUntil({ + val alerts = searchAlerts(monitor) val historyAlerts = searchAlerts(monitor, AlertIndices.ALERT_HISTORY_WRITE_INDEX) - return@waitUntil (historyAlerts.size == 1) + return@waitUntil (alerts.isEmpty() && historyAlerts.size == 1) }, 5, TimeUnit.SECONDS) val alerts = searchAlerts(monitor) @@ -846,8 +847,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { // Wait 5 seconds for event to be processed and alerts moved OpenSearchTestCase.waitUntil({ - val historyAlerts = searchAlerts(monitor, AlertIndices.ALERT_HISTORY_WRITE_INDEX) - return@waitUntil (historyAlerts.size == 1) + return@waitUntil false }, 5, TimeUnit.SECONDS) val alerts = searchAlerts(monitor)