diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt index 8928b73a1..673590718 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt @@ -170,7 +170,7 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() { override fun preserveIndicesUponCompletion(): Boolean = true companion object { @JvmStatic - protected val isMultiNode = System.getProperty("cluster.number_of_nodes", "1").toInt() > 1 + val isMultiNode = System.getProperty("cluster.number_of_nodes", "1").toInt() > 1 protected val defaultKeepIndexSet = setOf(".opendistro_security") /** * We override preserveIndicesUponCompletion to true and use this function to clean up indices diff --git a/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt b/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt index e3ea00f44..2763329d7 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/TestHelpers.kt @@ -13,6 +13,7 @@ import org.opensearch.client.Response import org.opensearch.client.RestClient import org.opensearch.client.WarningsHandler import org.opensearch.commons.authuser.User +import org.opensearch.indexmanagement.IndexManagementRestTestCase.Companion.isMultiNode import org.opensearch.jobscheduler.spi.schedule.CronSchedule import org.opensearch.jobscheduler.spi.schedule.IntervalSchedule import org.opensearch.jobscheduler.spi.schedule.Schedule @@ -109,10 +110,16 @@ fun RestClient.makeRequest( return performRequest(request) } + fun waitFor( timeout: Instant = Instant.ofEpochSecond(20), block: () -> T ): T { + if (isMultiNode) { + // job scheduling could be skipped in multi-node tests + // https://github.com/opensearch-project/job-scheduler/issues/173 + timeout.plusSeconds(60) + } val startTime = Instant.now().toEpochMilli() do { try {