diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index ca7048235..c7426d9ff 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -9,7 +9,7 @@ jobs: build: strategy: matrix: - java: [13] + java: [14] # Job name name: Build Index Management with JDK ${{ matrix.java }} # This job runs on Linux diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 176f95da2..7f4217a60 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -17,10 +17,10 @@ jobs: - name: Checkout Branch uses: actions/checkout@v2 # This step uses the setup-java Github action: https://github.com/actions/setup-java - - name: Set Up JDK 13 + - name: Set Up JDK 14 uses: actions/setup-java@v1 with: - java-version: 13 + java-version: 14 - name: Build with Gradle run: ./gradlew build - name: Create Artifact Path diff --git a/README.md b/README.md index 237caf098..773149533 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Please see our [documentation](https://opendistro.github.io/for-elasticsearch-do 1. Check out this package from version control. 2. Launch Intellij IDEA, choose **Import Project**, and select the `settings.gradle` file in the root of this package. -3. To build from the command line, set `JAVA_HOME` to point to a JDK >= 13 before running `./gradlew`. +3. To build from the command line, set `JAVA_HOME` to point to a JDK >= 14 before running `./gradlew`. - Unix System 1. `export JAVA_HOME=jdk-install-dir`: Replace `jdk-install-dir` with the JAVA_HOME directory of your system. 2. `export PATH=$JAVA_HOME/bin:$PATH` diff --git a/build-tools/esplugin-coverage.gradle b/build-tools/esplugin-coverage.gradle index 71eb8d709..c00f02372 100644 --- a/build-tools/esplugin-coverage.gradle +++ b/build-tools/esplugin-coverage.gradle @@ -27,11 +27,10 @@ * break if there are multiple nodes in the integTestCluster. But for now... it sorta works. */ -apply plugin: 'jacoco' - // Get gradle to generate the required jvm agent arg for us using a dummy tasks of type Test. Unfortunately Elastic's // testing tasks don't derive from Test so the jacoco plugin can't do this automatically. def jacocoDir = "${buildDir}/jacoco" + task dummyTest(type: Test) { enabled = false workingDir = file("/") // Force absolute path to jacoco agent jar @@ -42,7 +41,6 @@ task dummyTest(type: Test) { } } - task dummyIntegTest(type: Test) { enabled = false workingDir = file("/") // Force absolute path to jacoco agent jar @@ -57,15 +55,6 @@ integTest.runner { systemProperty 'jacoco.dir', "${jacocoDir}" } -testClusters.integTest { - jvmArgs " ${dummyIntegTest.jacoco.getAsJvmArg()}" - systemProperty 'com.sun.management.jmxremote', "true" - systemProperty 'com.sun.management.jmxremote.authenticate', "false" - systemProperty 'com.sun.management.jmxremote.port', "7777" - systemProperty 'com.sun.management.jmxremote.ssl', "false" - systemProperty 'java.rmi.server.hostname', "127.0.0.1" -} - jacocoTestReport { dependsOn integTest, test executionData dummyTest.jacoco.destinationFile, dummyIntegTest.jacoco.destinationFile @@ -77,7 +66,17 @@ jacocoTestReport { } } -project.gradle.projectsEvaluated { - jacocoTestReport.dependsOn integTest.runner -} +allprojects{ + afterEvaluate { + jacocoTestReport.dependsOn integTest.runner + testClusters.integTest { + jvmArgs " ${dummyIntegTest.jacoco.getAsJvmArg()}" + systemProperty 'com.sun.management.jmxremote', "true" + systemProperty 'com.sun.management.jmxremote.authenticate', "false" + systemProperty 'com.sun.management.jmxremote.port', "7777" + systemProperty 'com.sun.management.jmxremote.ssl', "false" + systemProperty 'java.rmi.server.hostname', "127.0.0.1" + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 436123c1e..7a7d2e12e 100644 --- a/build.gradle +++ b/build.gradle @@ -15,8 +15,8 @@ buildscript { ext { - es_version = System.getProperty("es.version", "7.6.1") - kotlin_version = System.getProperty("kotlin.version", "1.3.61") + es_version = System.getProperty("es.version", "7.7.0") + kotlin_version = System.getProperty("kotlin.version", "1.3.72") } repositories { @@ -36,7 +36,7 @@ buildscript { } plugins { - id 'nebula.ospackage' version "8.2.0" + id 'nebula.ospackage' version "8.3.0" id "com.dorongold.task-tree" version "1.5" } @@ -79,12 +79,12 @@ configurations.testCompile { dependencies { compileOnly "org.elasticsearch:elasticsearch:${es_version}" - compileOnly "com.amazon.opendistroforelasticsearch:opendistro-job-scheduler-spi:1.6.0.0" + compileOnly "com.amazon.opendistroforelasticsearch:opendistro-job-scheduler-spi:1.8.0.0" compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" compile "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}" compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1' compile "org.jetbrains:annotations:13.0" - compile "com.amazon.opendistroforelasticsearch:notification:1.6.0.0" + compile "com.amazon.opendistroforelasticsearch:notification:1.8.0.0" testCompile "org.elasticsearch.test:framework:${es_version}" testCompile "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" @@ -129,6 +129,15 @@ thirdPartyAudit.enabled = false def es_tmp_dir = rootProject.file('build/private/es_tmp').absoluteFile es_tmp_dir.mkdirs() +afterEvaluate { + testClusters.integTest.nodes.each { node -> + def plugins = node.plugins + def firstPlugin = plugins.get(0) + plugins.remove(0) + plugins.add(firstPlugin) + } +} + test { systemProperty 'tests.security.manager', 'false' } diff --git a/gradle.properties b/gradle.properties index da4df4540..f2f9d1c8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,4 +13,4 @@ # permissions and limitations under the License. # -version = 1.7.0 +version = 1.8.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f3d88b1c2..62d4c0535 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8073ac71e..309d47144 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ -#Tue Mar 24 11:18:08 PDT 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip +#Tue May 19 22:58:14 PDT 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7d9..fbd7c5158 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 9109989e3..a9f778a7a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%* set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% diff --git a/release-notes/opendistro-elasticsearch-index-management-1.8.0.md b/release-notes/opendistro-elasticsearch-index-management-1.8.0.md new file mode 100644 index 000000000..8f29bb25a --- /dev/null +++ b/release-notes/opendistro-elasticsearch-index-management-1.8.0.md @@ -0,0 +1,8 @@ + +## Version 1.8.0.0 (2020-5-20) + +Compatible with Elasticsearch 7.7.0, Adds support for ODFE 1.8.0 + +### New Features +* Snapshot implementation [PR #135](https://github.com/opendistro-for-elasticsearch/index-management/pull/135) + diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndices.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndices.kt index cbf7a6209..eefa857b8 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndices.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndices.kt @@ -32,6 +32,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse import org.elasticsearch.client.Client import org.elasticsearch.client.IndicesAdminClient import org.elasticsearch.cluster.service.ClusterService +import org.elasticsearch.common.settings.Settings import org.elasticsearch.common.xcontent.XContentType @OpenForTesting @@ -46,6 +47,7 @@ class IndexStateManagementIndices( if (!indexStateManagementIndexExists()) { val indexRequest = CreateIndexRequest(INDEX_STATE_MANAGEMENT_INDEX) .mapping(_DOC, indexStateManagementMappings, XContentType.JSON) + .settings(Settings.builder().put("index.hidden", true).build()) client.create(indexRequest, object : ActionListener { override fun onFailure(e: Exception) { actionListener.onFailure(e) @@ -103,7 +105,9 @@ class IndexStateManagementIndices( } if (existsResponse.isExists) return true - val request = CreateIndexRequest(index).mapping(_DOC, indexStateManagementHistoryMappings, XContentType.JSON) + val request = CreateIndexRequest(index) + .mapping(_DOC, indexStateManagementHistoryMappings, XContentType.JSON) + .settings(Settings.builder().put("index.hidden", true).build()) if (alias != null) request.alias(Alias(alias)) return try { val createIndexResponse: CreateIndexResponse = client.suspendUntil { client.create(request, it) } diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementPlugin.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementPlugin.kt index 1312d4fb0..5fed6f9f2 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementPlugin.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementPlugin.kt @@ -118,14 +118,14 @@ internal class IndexStateManagementPlugin : JobSchedulerExtension, ActionPlugin, nodesInCluster: Supplier ): List { return listOf( - RestIndexPolicyAction(settings, restController, clusterService, indexStateManagementIndices), - RestGetPolicyAction(restController), - RestDeletePolicyAction(restController), - RestExplainAction(restController), - RestRetryFailedManagedIndexAction(restController), - RestAddPolicyAction(restController), - RestRemovePolicyAction(restController), - RestChangePolicyAction(restController, clusterService) + RestIndexPolicyAction(settings, clusterService, indexStateManagementIndices), + RestGetPolicyAction(), + RestDeletePolicyAction(), + RestExplainAction(), + RestRetryFailedManagedIndexAction(), + RestAddPolicyAction(), + RestRemovePolicyAction(), + RestChangePolicyAction(clusterService) ) } @@ -138,7 +138,8 @@ internal class IndexStateManagementPlugin : JobSchedulerExtension, ActionPlugin, xContentRegistry: NamedXContentRegistry, environment: Environment, nodeEnvironment: NodeEnvironment, - namedWriteableRegistry: NamedWriteableRegistry + namedWriteableRegistry: NamedWriteableRegistry, + indexNameExpressionResolver: IndexNameExpressionResolver ): Collection { val settings = environment.settings() this.clusterService = clusterService diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestAddPolicyAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestAddPolicyAction.kt index 4a30d7c7f..526f550d6 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestAddPolicyAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestAddPolicyAction.kt @@ -38,9 +38,9 @@ import org.elasticsearch.common.unit.TimeValue import org.elasticsearch.common.xcontent.XContentHelper import org.elasticsearch.index.Index import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest import org.elasticsearch.rest.RestRequest.Method.POST import org.elasticsearch.rest.RestResponse @@ -51,15 +51,17 @@ import java.io.IOException import java.time.Duration import java.time.Instant -class RestAddPolicyAction(controller: RestController) : BaseRestHandler() { - - init { - controller.registerHandler(POST, ADD_POLICY_BASE_URI, this) - controller.registerHandler(POST, "$ADD_POLICY_BASE_URI/{index}", this) - } +class RestAddPolicyAction : BaseRestHandler() { override fun getName(): String = "add_policy_action" + override fun routes(): List { + return listOf( + Route(POST, ADD_POLICY_BASE_URI), + Route(POST, "$ADD_POLICY_BASE_URI/{index}") + ) + } + @Throws(IOException::class) @Suppress("SpreadOperator") // There is no way around dealing with java vararg without spread operator. override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestChangePolicyAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestChangePolicyAction.kt index 9c8777077..709779d01 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestChangePolicyAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestChangePolicyAction.kt @@ -55,9 +55,9 @@ import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.index.query.IdsQueryBuilder import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest import org.elasticsearch.rest.RestRequest.Method.POST import org.elasticsearch.rest.RestResponse @@ -66,13 +66,15 @@ import org.elasticsearch.rest.action.RestResponseListener import org.elasticsearch.search.builder.SearchSourceBuilder import java.io.IOException -class RestChangePolicyAction(controller: RestController, val clusterService: ClusterService) : BaseRestHandler() { +class RestChangePolicyAction(val clusterService: ClusterService) : BaseRestHandler() { private val log = LogManager.getLogger(javaClass) - init { - controller.registerHandler(POST, CHANGE_POLICY_BASE_URI, this) - controller.registerHandler(POST, "$CHANGE_POLICY_BASE_URI/{index}", this) + override fun routes(): List { + return listOf( + Route(POST, CHANGE_POLICY_BASE_URI), + Route(POST, "$CHANGE_POLICY_BASE_URI/{index}") + ) } override fun getName(): String = "change_policy_action" diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestDeletePolicyAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestDeletePolicyAction.kt index b53a76900..6b06edd5f 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestDeletePolicyAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestDeletePolicyAction.kt @@ -22,16 +22,18 @@ import org.elasticsearch.action.delete.DeleteRequest import org.elasticsearch.action.support.WriteRequest.RefreshPolicy import org.elasticsearch.client.node.NodeClient import org.elasticsearch.rest.BaseRestHandler -import org.elasticsearch.rest.RestController +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.RestRequest import org.elasticsearch.rest.RestRequest.Method.DELETE import org.elasticsearch.rest.action.RestStatusToXContentListener import java.io.IOException -class RestDeletePolicyAction(controller: RestController) : BaseRestHandler() { +class RestDeletePolicyAction : BaseRestHandler() { - init { - controller.registerHandler(DELETE, "$POLICY_BASE_URI/{policyID}", this) + override fun routes(): List { + return listOf( + Route(DELETE, "$POLICY_BASE_URI/{policyID}") + ) } override fun getName(): String = "delete_policy_action" diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestExplainAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestExplainAction.kt index 0102f3479..4de91e23e 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestExplainAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestExplainAction.kt @@ -27,23 +27,26 @@ import org.elasticsearch.common.Strings import org.elasticsearch.common.xcontent.ToXContent import org.elasticsearch.common.xcontent.XContentBuilder import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest +import org.elasticsearch.rest.RestRequest.Method.GET import org.elasticsearch.rest.RestResponse import org.elasticsearch.rest.RestStatus import org.elasticsearch.rest.action.RestBuilderListener -class RestExplainAction(controller: RestController) : BaseRestHandler() { +class RestExplainAction : BaseRestHandler() { companion object { const val EXPLAIN_BASE_URI = "${IndexStateManagementPlugin.ISM_BASE_URI}/explain" } - init { - controller.registerHandler(RestRequest.Method.GET, EXPLAIN_BASE_URI, this) - controller.registerHandler(RestRequest.Method.GET, "$EXPLAIN_BASE_URI/{index}", this) + override fun routes(): List { + return listOf( + Route(GET, EXPLAIN_BASE_URI), + Route(GET, "$EXPLAIN_BASE_URI/{index}") + ) } override fun getName(): String { diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestGetPolicyAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestGetPolicyAction.kt index d2d2674c9..a37639437 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestGetPolicyAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestGetPolicyAction.kt @@ -31,22 +31,25 @@ import org.elasticsearch.common.xcontent.LoggingDeprecationHandler import org.elasticsearch.common.xcontent.XContentHelper import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest +import org.elasticsearch.rest.RestRequest.Method.GET +import org.elasticsearch.rest.RestRequest.Method.HEAD import org.elasticsearch.rest.RestResponse import org.elasticsearch.rest.RestStatus import org.elasticsearch.rest.action.RestActions import org.elasticsearch.rest.action.RestResponseListener import org.elasticsearch.search.fetch.subphase.FetchSourceContext -class RestGetPolicyAction(controller: RestController) : BaseRestHandler() { +class RestGetPolicyAction : BaseRestHandler() { - init { - // Get a specific policy - controller.registerHandler(RestRequest.Method.GET, "$POLICY_BASE_URI/{policyID}", this) - controller.registerHandler(RestRequest.Method.HEAD, "$POLICY_BASE_URI/{policyID}", this) + override fun routes(): List { + return listOf( + Route(GET, "$POLICY_BASE_URI/{policyID}"), + Route(HEAD, "$POLICY_BASE_URI/{policyID}") + ) } override fun getName(): String { @@ -61,7 +64,7 @@ class RestGetPolicyAction(controller: RestController) : BaseRestHandler() { val getRequest = GetRequest(INDEX_STATE_MANAGEMENT_INDEX, policyId) .version(RestActions.parseVersion(request)) - if (request.method() == RestRequest.Method.HEAD) { + if (request.method() == HEAD) { getRequest.fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE) } return RestChannelConsumer { channel -> client.get(getRequest, getPolicyResponse(channel)) } diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestIndexPolicyAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestIndexPolicyAction.kt index b5a69e58e..992c791ae 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestIndexPolicyAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestIndexPolicyAction.kt @@ -43,10 +43,10 @@ import org.elasticsearch.common.settings.Settings import org.elasticsearch.common.xcontent.ToXContent import org.elasticsearch.index.seqno.SequenceNumbers import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest import org.elasticsearch.rest.RestRequest.Method.PUT import org.elasticsearch.rest.RestResponse @@ -57,7 +57,6 @@ import java.time.Instant class RestIndexPolicyAction( settings: Settings, - controller: RestController, val clusterService: ClusterService, indexStateManagementIndices: IndexStateManagementIndices ) : BaseRestHandler() { @@ -68,8 +67,13 @@ class RestIndexPolicyAction( init { clusterService.clusterSettings.addSettingsUpdateConsumer(ALLOW_LIST) { allowList = it } - controller.registerHandler(PUT, POLICY_BASE_URI, this) - controller.registerHandler(PUT, "$POLICY_BASE_URI/{policyID}", this) + } + + override fun routes(): List { + return listOf( + Route(PUT, POLICY_BASE_URI), + Route(PUT, "$POLICY_BASE_URI/{policyID}") + ) } override fun getName(): String { diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRemovePolicyAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRemovePolicyAction.kt index ee99b7fd0..c171676c5 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRemovePolicyAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRemovePolicyAction.kt @@ -35,9 +35,9 @@ import org.elasticsearch.common.Strings import org.elasticsearch.common.settings.Settings import org.elasticsearch.index.Index import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest import org.elasticsearch.rest.RestRequest.Method.POST import org.elasticsearch.rest.RestResponse @@ -46,11 +46,13 @@ import org.elasticsearch.rest.action.RestActionListener import org.elasticsearch.rest.action.RestResponseListener import java.io.IOException -class RestRemovePolicyAction(controller: RestController) : BaseRestHandler() { +class RestRemovePolicyAction : BaseRestHandler() { - init { - controller.registerHandler(POST, REMOVE_POLICY_BASE_URI, this) - controller.registerHandler(POST, "$REMOVE_POLICY_BASE_URI/{index}", this) + override fun routes(): List { + return listOf( + Route(POST, REMOVE_POLICY_BASE_URI), + Route(POST, "$REMOVE_POLICY_BASE_URI/{index}") + ) } override fun getName(): String = "remove_policy_action" diff --git a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRetryFailedManagedIndexAction.kt b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRetryFailedManagedIndexAction.kt index 798b984e2..2424609da 100644 --- a/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRetryFailedManagedIndexAction.kt +++ b/src/main/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/resthandler/RestRetryFailedManagedIndexAction.kt @@ -43,19 +43,22 @@ import org.elasticsearch.common.Strings import org.elasticsearch.common.xcontent.XContentHelper import org.elasticsearch.index.Index import org.elasticsearch.rest.BaseRestHandler +import org.elasticsearch.rest.RestHandler.Route import org.elasticsearch.rest.BytesRestResponse import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestController import org.elasticsearch.rest.RestRequest import org.elasticsearch.rest.RestStatus +import org.elasticsearch.rest.RestRequest.Method.POST -class RestRetryFailedManagedIndexAction(controller: RestController) : BaseRestHandler() { +class RestRetryFailedManagedIndexAction : BaseRestHandler() { private val log = LogManager.getLogger(javaClass) - init { - controller.registerHandler(RestRequest.Method.POST, RETRY_BASE_URI, this) - controller.registerHandler(RestRequest.Method.POST, "$RETRY_BASE_URI/{index}", this) + override fun routes(): List { + return listOf( + Route(POST, RETRY_BASE_URI), + Route(POST, "$RETRY_BASE_URI/{index}") + ) } override fun getName(): String { diff --git a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndicesIT.kt b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndicesIT.kt index ac19f5834..56007c1d7 100644 --- a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndicesIT.kt +++ b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementIndicesIT.kt @@ -33,7 +33,7 @@ class IndexStateManagementIndicesIT : IndexStateManagementRestTestCase() { val mapping = indexStateManagementMappings.trimStart('{').trimEnd('}') .replace("\"schema_version\": 2", "\"schema_version\": 0") - createIndex(INDEX_STATE_MANAGEMENT_INDEX, Settings.EMPTY, mapping) + createIndex(INDEX_STATE_MANAGEMENT_INDEX, Settings.builder().put("index.hidden", true).build(), mapping) assertIndexExists(INDEX_STATE_MANAGEMENT_INDEX) verifyIndexSchemaVersion(INDEX_STATE_MANAGEMENT_INDEX, 0) client().makeRequest("DELETE", "*") diff --git a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementRestTestCase.kt b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementRestTestCase.kt index 68f5f30e9..355a10d47 100644 --- a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementRestTestCase.kt +++ b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/IndexStateManagementRestTestCase.kt @@ -620,18 +620,18 @@ abstract class IndexStateManagementRestTestCase : ESRestTestCase() { } /* - * We need to be able to dump the jacoco coverage before cluster is shut down. - * The new internal testing framework removed some of the gradle tasks we were listening to + * We need to be able to dump the jacoco coverage before the cluster shuts down. + * The new internal testing framework removed some gradle tasks we were listening to, * to choose a good time to do it. This will dump the executionData to file after each test. * TODO: This is also currently just overwriting integTest.exec with the updated execData without * resetting after writing each time. This can be improved to either write an exec file per test - * or by letting jacoco append to the file + * or by letting jacoco append to the file. * */ @JvmStatic @AfterClass fun dumpCoverage() { - // jacoco.dir is set in esplugin-coverage.gradle, if it doesn't exist we don't - // want to collect coverage so we can return early + // jacoco.dir set in esplugin-coverage.gradle, if it doesn't exist we don't + // want to collect coverage, so we can return early val jacocoBuildPath = System.getProperty("jacoco.dir") ?: return val serverUrl = "service:jmx:rmi:///jndi/rmi://127.0.0.1:7777/jmxrmi" JMXConnectorFactory.connect(JMXServiceURL(serverUrl)).use { connector -> diff --git a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/util/ManagedIndexUtilsTests.kt b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/util/ManagedIndexUtilsTests.kt index 0b253da55..375873927 100644 --- a/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/util/ManagedIndexUtilsTests.kt +++ b/src/test/kotlin/com/amazon/opendistroforelasticsearch/indexstatemanagement/util/ManagedIndexUtilsTests.kt @@ -185,8 +185,6 @@ class ManagedIndexUtilsTests : ESTestCase() { .evaluateConditions(indexAgeTimeValue = TimeValue.timeValueMillis(0), numDocs = 0, indexSize = ByteSizeValue(0))) assertTrue("No conditions should always pass", noConditionsConfig .evaluateConditions(indexAgeTimeValue = TimeValue.timeValueMillis(100), numDocs = 5, indexSize = ByteSizeValue(5))) - assertTrue("No conditions should always pass", noConditionsConfig - .evaluateConditions(indexAgeTimeValue = TimeValue.timeValueMillis(-6000), numDocs = 5, indexSize = ByteSizeValue(5))) assertTrue("No conditions should always pass", noConditionsConfig .evaluateConditions(indexAgeTimeValue = TimeValue.timeValueMillis(6000), numDocs = 5, indexSize = ByteSizeValue(5))) diff --git a/src/test/resources/job-scheduler/opendistro-job-scheduler-1.8.0.0.zip b/src/test/resources/job-scheduler/opendistro-job-scheduler-1.8.0.0.zip new file mode 100644 index 000000000..c7f8193fc Binary files /dev/null and b/src/test/resources/job-scheduler/opendistro-job-scheduler-1.8.0.0.zip differ diff --git a/src/test/resources/job-scheduler/opendistro-job-scheduler-1.6.0.0.zip b/src/test/resources/opendistro-job-scheduler-1.6.0.0.zip similarity index 100% rename from src/test/resources/job-scheduler/opendistro-job-scheduler-1.6.0.0.zip rename to src/test/resources/opendistro-job-scheduler-1.6.0.0.zip