From 0a75b052eb17d579a2a0d4589b171d4b30649935 Mon Sep 17 00:00:00 2001 From: Jacob Choi Date: Thu, 9 Nov 2023 21:52:27 -0500 Subject: [PATCH] using verifyMonitorStats to enhance the test efficiency Signed-off-by: Jacob Choi --- .../bwc/AlertingBackwardsCompatibilityIT.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/bwc/AlertingBackwardsCompatibilityIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/bwc/AlertingBackwardsCompatibilityIT.kt index 6c45b9c54..2c77fd480 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/bwc/AlertingBackwardsCompatibilityIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/bwc/AlertingBackwardsCompatibilityIT.kt @@ -71,10 +71,21 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() { // the test execution by a lot (might have to wait for Job Scheduler plugin integration first) // Waiting a minute to ensure the Monitor ran again at least once before checking if the job is running // on time + var passed = false OpenSearchTestCase.waitUntil({ - return@waitUntil false + try { + // Run verifyMonitorStats until all assertion test passes + verifyMonitorStats("/_plugins/_alerting") + passed = true + return@waitUntil true + } catch (e: AssertionError) { + return@waitUntil false + } }, 1, TimeUnit.MINUTES) - verifyMonitorStats("/_plugins/_alerting") + if (!passed) { + // if it hit the max time (1 minute), run verifyMonitorStats again to make sure all the tests pass + verifyMonitorStats("/_plugins/_alerting") + } } } break