Skip to content

Commit

Permalink
Initializes the job index before each test
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Downs <[email protected]>
  • Loading branch information
downsrob committed Dec 2, 2021
1 parent c739190 commit 8408320
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import org.opensearch.client.Request
import org.opensearch.client.RequestOptions
import org.opensearch.client.Response
import org.opensearch.client.RestClient
import org.opensearch.common.Strings
import org.opensearch.common.settings.Settings
import org.opensearch.indexmanagement.indexstatemanagement.util.INDEX_HIDDEN
import org.opensearch.rest.RestStatus
import java.nio.file.Files
import java.nio.file.Path
Expand All @@ -39,6 +41,20 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() {
)
}

// Tests on lower resource machines are experiencing flaky failures due to attempting to force a job to
// start before the job scheduler has registered the index operations listener. Initializing the index
// preemptively seems to give the job scheduler time to listen to operations.
@Before
fun initializeManagedIndex() {
if (!indexExists(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX)) {
val request = Request("PUT", "/${IndexManagementPlugin.INDEX_MANAGEMENT_INDEX}")
var entity = "{\"settings\": " + Strings.toString(Settings.builder().put(INDEX_HIDDEN, true).build())
entity += ",\"mappings\" : ${IndexManagementIndices.indexManagementMappings}}"
request.setJsonEntity(entity)
client().performRequest(request)
}
}

protected val isDebuggingTest = DisableOnDebug(null).isDebugging
protected val isDebuggingRemoteCluster = System.getProperty("cluster.debug", "false")!!.toBoolean()
protected val isMultiNode = System.getProperty("cluster.number_of_nodes", "1").toInt() > 1
Expand Down

0 comments on commit 8408320

Please sign in to comment.