Skip to content

Commit

Permalink
Add timeout for multinode tests
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Oct 4, 2023
1 parent 8b0cd6d commit dd10cf2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,18 @@ fun <T> 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)
Expand Down

0 comments on commit dd10cf2

Please sign in to comment.