From dd10cf28070eceac20c5a567d4eb9e0065a44b6f Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Tue, 3 Oct 2023 22:56:08 -0700 Subject: [PATCH] Add timeout for multinode tests Signed-off-by: bowenlan-amzn --- .../kotlin/org/opensearch/indexmanagement/TestHelpers.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt b/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt index 0ce249203..4b7ad50e8 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt @@ -114,17 +114,18 @@ fun waitFor( timeout: Instant = Instant.ofEpochSecond(20), block: () -> T ): T { + var to = timeout if (isMultiNode) { // job scheduling could be skipped in multi-node tests // https://github.com/opensearch-project/job-scheduler/issues/173 - timeout.plusSeconds(60) + to = timeout.plusSeconds(60) } val startTime = Instant.now().toEpochMilli() do { try { return block() } catch (e: Throwable) { - if ((Instant.now().toEpochMilli() - startTime) > timeout.toEpochMilli()) { + if ((Instant.now().toEpochMilli() - startTime) > to.toEpochMilli()) { throw e } else { Thread.sleep(100L)