From 84a658cc9731c9511df0e8b635397b91fb120397 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Mon, 25 Nov 2024 10:32:51 -0500 Subject: [PATCH 01/20] Upgrade to actions/upload-artifact@v4 Signed-off-by: Craig Perkins --- .../workflows/multi-node-test-workflow.yml | 13 ++++++------- .github/workflows/security-test-workflow.yml | 13 ++++++------- .github/workflows/test-and-build-workflow.yml | 19 +++++++++---------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/.github/workflows/multi-node-test-workflow.yml b/.github/workflows/multi-node-test-workflow.yml index 40d9cc905..02a693ff1 100644 --- a/.github/workflows/multi-node-test-workflow.yml +++ b/.github/workflows/multi-node-test-workflow.yml @@ -7,8 +7,6 @@ on: push: branches: - "**" -env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: Get-CI-Image-Tag: @@ -35,25 +33,26 @@ jobs: # using the same image which is used by opensearch-build team to build the OpenSearch Distribution # this image tag is subject to change as more dependencies and updates will arrive over time image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} - # need to switch to root so that github actions can install runner binary on container without permission issues. - options: --user root + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} # This step uses the setup-java Github action: https://github.com/actions/setup-java - name: Set Up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin # Temurin is a distribution of adoptium java-version: 21 # index-management - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run integration tests with multi node config run: | chown -R 1000:1000 `pwd` su `id -un 1000` -c "./gradlew integTest -PnumNodes=3 ${{ env.TEST_FILTER }}" - name: Upload failed logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: logs diff --git a/.github/workflows/security-test-workflow.yml b/.github/workflows/security-test-workflow.yml index 8dc6eb19c..6b0363fc7 100644 --- a/.github/workflows/security-test-workflow.yml +++ b/.github/workflows/security-test-workflow.yml @@ -7,8 +7,6 @@ on: push: branches: - "**" -env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: Get-CI-Image-Tag: @@ -24,25 +22,26 @@ jobs: # using the same image which is used by opensearch-build team to build the OpenSearch Distribution # this image tag is subject to change as more dependencies and updates will arrive over time image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} - # need to switch to root so that github actions can install runner binary on container without permission issues. - options: --user root + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} # This step uses the setup-java Github action: https://github.com/actions/setup-java - name: Set Up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin # Temurin is a distribution of adoptium java-version: 21 # index-management - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run integration tests run: | chown -R 1000:1000 `pwd` su `id -un 1000` -c "./gradlew integTest -Dsecurity=true -Dhttps=true --tests '*IT'" - name: Upload failed logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: logs diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 5713aea5e..2ffadaaa0 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -6,8 +6,6 @@ on: push: branches: - "**" -env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: Get-CI-Image-Tag: @@ -36,19 +34,20 @@ jobs: # using the same image which is used by opensearch-build team to build the OpenSearch Distribution # this image tag is subject to change as more dependencies and updates will arrive over time image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} - # need to switch to root so that github actions can install runner binary on container without permission issues. - options: --user root + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} # This step uses the setup-java Github action: https://github.com/actions/setup-java - name: Set Up JDK ${{ matrix.java }} - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin # Temurin is a distribution of adoptium java-version: ${{ matrix.java }} # build index management - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 # This is a hack, but this step creates a link to the X: mounted drive, which makes the path # short enough to work on Windows - name: Build with Gradle @@ -66,13 +65,13 @@ jobs: mkdir -p index-management-artifacts cp ./build/distributions/*.zip index-management-artifacts - name: Uploads coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} # This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact - name: Upload Artifacts # v4 requires node.js 20 which is not supported - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: index-management-plugin-ubuntu-latest-${{ matrix.java }} path: index-management-artifacts @@ -106,13 +105,13 @@ jobs: steps: # This step uses the setup-java Github action: https://github.com/actions/setup-java - name: Set Up JDK ${{ matrix.java }} - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin # Temurin is a distribution of adoptium java-version: ${{ matrix.java }} # build index management - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 # This is a hack, but this step creates a link to the X: mounted drive, which makes the path # short enough to work on Windows - name: Shorten Path From ae9fa1b2f40a1aca3729fb5e5dcf7684f3e523b3 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 12:36:27 -0500 Subject: [PATCH 02/20] Make ActionRequests that extend UpdateRequest to extend more generic ActionRequest Signed-off-by: Craig Perkins --- .../action/stop/StopTransformRequest.kt | 16 +++++++++++----- .../action/stop/TransportStopTransformAction.kt | 9 +++++---- .../transform/action/RequestTests.kt | 5 +++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt index 7d3a3c2fc..ceee2618b 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt @@ -5,24 +5,30 @@ package org.opensearch.indexmanagement.transform.action.stop +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException import org.opensearch.action.ValidateActions.addValidationError -import org.opensearch.action.update.UpdateRequest import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StopTransformRequest : UpdateRequest { +class StopTransformRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { + if (this.id.isEmpty()) { validationException = addValidationError("id is missing", validationException) } return validationException diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/TransportStopTransformAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/TransportStopTransformAction.kt index 4e0e480cb..c2b5636d6 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/TransportStopTransformAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/TransportStopTransformAction.kt @@ -76,13 +76,13 @@ constructor( private val log = LogManager.getLogger(javaClass) override fun doExecute(task: Task, request: StopTransformRequest, actionListener: ActionListener) { - log.debug("Executing StopTransformAction on ${request.id()}") + log.debug("Executing StopTransformAction on ${request.id}") log.debug( "User and roles string from thread context: ${client.threadPool().threadContext.getTransient( ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, )}", ) - val getRequest = GetRequest(INDEX_MANAGEMENT_INDEX, request.id()) + val getRequest = GetRequest(INDEX_MANAGEMENT_INDEX, request.id) val user = buildUser(client.threadPool().threadContext) client.threadPool().threadContext.stashContext().use { client.get( @@ -212,7 +212,8 @@ constructor( private fun updateTransformJob(transform: Transform, request: StopTransformRequest, actionListener: ActionListener) { val now = Instant.now().toEpochMilli() - request.index(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX).setIfSeqNo(transform.seqNo).setIfPrimaryTerm(transform.primaryTerm) + val updateReq = UpdateRequest(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX, request.id) + updateReq.setIfSeqNo(transform.seqNo).setIfPrimaryTerm(transform.primaryTerm) .doc( mapOf( Transform.TRANSFORM_TYPE to @@ -223,7 +224,7 @@ constructor( ), ) client.update( - request, + updateReq, object : ActionListener { override fun onResponse(response: UpdateResponse) { actionListener.onResponse(AcknowledgedResponse(response.result == DocWriteResponse.Result.UPDATED)) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt index e2166ccf1..540fd6476 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt @@ -7,6 +7,7 @@ package org.opensearch.indexmanagement.transform.action import org.opensearch.action.DocWriteRequest import org.opensearch.action.support.WriteRequest +import org.opensearch.action.update.UpdateRequest import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.index.seqno.SequenceNumbers import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -161,11 +162,11 @@ class RequestTests : OpenSearchTestCase() { fun `test stop transform request`() { val id = "some_id" - val req = StopTransformRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val streamedReq = StopTransformRequest(buildStreamInputForTransforms(out)) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } } From b5d4043bd3b7ceb1317c78d84f04375b62906f65 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 12:49:18 -0500 Subject: [PATCH 03/20] Apply to StartTransformRequest Signed-off-by: Craig Perkins --- .../action/start/StartTransformRequest.kt | 16 +++++++++++----- .../start/TransportStartTransformAction.kt | 7 ++++--- .../transform/action/RequestTests.kt | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt index a6514c6df..4846c1283 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt @@ -5,24 +5,30 @@ package org.opensearch.indexmanagement.transform.action.start +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException import org.opensearch.action.ValidateActions.addValidationError -import org.opensearch.action.update.UpdateRequest import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StartTransformRequest : UpdateRequest { +class StartTransformRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { + if (this.id.isEmpty()) { validationException = addValidationError("id is missing", validationException) } return validationException diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt index b69187d89..3a2c21044 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/TransportStartTransformAction.kt @@ -68,7 +68,7 @@ constructor( ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, )}", ) - val getRequest = GetRequest(INDEX_MANAGEMENT_INDEX, request.id()) + val getRequest = GetRequest(INDEX_MANAGEMENT_INDEX, request.id) val user = buildUser(client.threadPool().threadContext) client.threadPool().threadContext.stashContext().use { client.get( @@ -117,7 +117,8 @@ constructor( actionListener: ActionListener, ) { val now = Instant.now().toEpochMilli() - request.index(INDEX_MANAGEMENT_INDEX).doc( + val updateReq = UpdateRequest(INDEX_MANAGEMENT_INDEX, request.id) + updateReq.doc( mapOf( Transform.TRANSFORM_TYPE to mapOf( @@ -127,7 +128,7 @@ constructor( ), ) client.update( - request, + updateReq, object : ActionListener { override fun onResponse(response: UpdateResponse) { if (response.result == DocWriteResponse.Result.UPDATED) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt index 540fd6476..1365aa631 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt @@ -152,12 +152,12 @@ class RequestTests : OpenSearchTestCase() { fun `test start transform request`() { val id = "some_id" - val req = StartTransformRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val streamedReq = StartTransformRequest(buildStreamInputForTransforms(out)) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } fun `test stop transform request`() { From b15acc6a47ce2951250346e74af4c20bc38cf2a0 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 12:55:26 -0500 Subject: [PATCH 04/20] Apply to rollup actions Signed-off-by: Craig Perkins --- .../rollup/action/start/StartRollupRequest.kt | 16 +++++++++++----- .../action/start/TransportStartRollupAction.kt | 8 +++++--- .../rollup/action/stop/StopRollupRequest.kt | 16 +++++++++++----- .../action/stop/TransportStopRollupAction.kt | 9 +++++---- .../rollup/action/RequestTests.kt | 9 +++++---- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt index 3493d5473..9f352f8b5 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt @@ -5,24 +5,30 @@ package org.opensearch.indexmanagement.rollup.action.start +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException import org.opensearch.action.ValidateActions.addValidationError -import org.opensearch.action.update.UpdateRequest import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StartRollupRequest : UpdateRequest { +class StartRollupRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { + if (this.id.isEmpty()) { validationException = addValidationError("id is missing", validationException) } return validationException diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/TransportStartRollupAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/TransportStartRollupAction.kt index 535c834b5..8689dc221 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/TransportStartRollupAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/TransportStartRollupAction.kt @@ -28,6 +28,7 @@ import org.opensearch.commons.authuser.User import org.opensearch.core.action.ActionListener import org.opensearch.core.rest.RestStatus import org.opensearch.core.xcontent.NamedXContentRegistry +import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.opensearchapi.parseWithType import org.opensearch.indexmanagement.rollup.model.Rollup @@ -70,7 +71,7 @@ constructor( ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, )}", ) - val getReq = GetRequest(INDEX_MANAGEMENT_INDEX, request.id()) + val getReq = GetRequest(INDEX_MANAGEMENT_INDEX, request.id) val user: User? = buildUser(client.threadPool().threadContext) client.threadPool().threadContext.stashContext().use { client.get( @@ -115,7 +116,8 @@ constructor( // TODO: Should create a transport action to update metadata private fun updateRollupJob(rollup: Rollup, request: StartRollupRequest, actionListener: ActionListener) { val now = Instant.now().toEpochMilli() - request.index(INDEX_MANAGEMENT_INDEX).doc( + val updateReq = UpdateRequest(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX, request.id) + updateReq.doc( mapOf( Rollup.ROLLUP_TYPE to mapOf( @@ -125,7 +127,7 @@ constructor( ), ) client.update( - request, + updateReq, object : ActionListener { override fun onResponse(response: UpdateResponse) { if (response.result == DocWriteResponse.Result.UPDATED) { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt index 1a03317a7..0b1658460 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt @@ -5,24 +5,30 @@ package org.opensearch.indexmanagement.rollup.action.stop +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException import org.opensearch.action.ValidateActions.addValidationError -import org.opensearch.action.update.UpdateRequest import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StopRollupRequest : UpdateRequest { +class StopRollupRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { + if (this.id.isEmpty()) { validationException = addValidationError("id is missing", validationException) } return validationException diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/TransportStopRollupAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/TransportStopRollupAction.kt index fdeead257..8aad70107 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/TransportStopRollupAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/TransportStopRollupAction.kt @@ -77,13 +77,13 @@ constructor( @Suppress("ReturnCount") override fun doExecute(task: Task, request: StopRollupRequest, actionListener: ActionListener) { - log.debug("Executing StopRollupAction on ${request.id()}") + log.debug("Executing StopRollupAction on ${request.id}") log.debug( "User and roles string from thread context: ${client.threadPool().threadContext.getTransient( ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, )}", ) - val getRequest = GetRequest(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX, request.id()) + val getRequest = GetRequest(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX, request.id) val user = buildUser(client.threadPool().threadContext) client.threadPool().threadContext.stashContext().use { client.get( @@ -214,7 +214,8 @@ constructor( private fun updateRollupJob(rollup: Rollup, request: StopRollupRequest, actionListener: ActionListener) { val now = Instant.now().toEpochMilli() - request.index(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX).setIfSeqNo(rollup.seqNo).setIfPrimaryTerm(rollup.primaryTerm) + val updateReq = UpdateRequest(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX, request.id) + updateReq.setIfSeqNo(rollup.seqNo).setIfPrimaryTerm(rollup.primaryTerm) .doc( mapOf( Rollup.ROLLUP_TYPE to @@ -226,7 +227,7 @@ constructor( ) .routing(rollup.id) client.update( - request, + updateReq, object : ActionListener { override fun onResponse(response: UpdateResponse) { actionListener.onResponse(AcknowledgedResponse(response.result == DocWriteResponse.Result.UPDATED)) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt index 3786a20f2..f77db904a 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt @@ -7,6 +7,7 @@ package org.opensearch.indexmanagement.rollup.action import org.opensearch.action.DocWriteRequest import org.opensearch.action.support.WriteRequest +import org.opensearch.action.update.UpdateRequest import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.index.seqno.SequenceNumbers @@ -134,21 +135,21 @@ class RequestTests : OpenSearchTestCase() { fun `test start rollup request`() { val id = "some_id" - val req = StartRollupRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) val streamedReq = StartRollupRequest(sin) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } fun `test stop rollup request`() { val id = "some_id" - val req = StopRollupRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) val streamedReq = StopRollupRequest(sin) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } } From 8a310d2ee2a77a9c800bbb30ad586e6be0228461 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 12:59:18 -0500 Subject: [PATCH 05/20] Update snapshot management requests Signed-off-by: Craig Perkins --- .../api/transport/start/StartSMRequest.kt | 20 ++++++++++++------- .../transport/start/TransportStartSMAction.kt | 12 ++++++----- .../api/transport/stop/StopSMRequest.kt | 20 ++++++++++++------- .../transport/stop/TransportStopSMAction.kt | 12 ++++++----- .../snapshotmanagement/action/RequestTests.kt | 9 +++++---- 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt index 23e00e16b..b64e876fa 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt @@ -5,25 +5,31 @@ package org.opensearch.indexmanagement.snapshotmanagement.api.transport.start +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException -import org.opensearch.action.ValidateActions -import org.opensearch.action.update.UpdateRequest +import org.opensearch.action.ValidateActions.addValidationError import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StartSMRequest : UpdateRequest { +class StartSMRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { - validationException = ValidateActions.addValidationError("id is missing", validationException) + if (this.id.isEmpty()) { + validationException = addValidationError("id is missing", validationException) } return validationException } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/TransportStartSMAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/TransportStartSMAction.kt index ac5e58ab5..6e81bb6b7 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/TransportStartSMAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/TransportStartSMAction.kt @@ -11,6 +11,7 @@ import org.opensearch.OpenSearchStatusException import org.opensearch.action.DocWriteResponse import org.opensearch.action.support.ActionFilters import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.update.UpdateRequest import org.opensearch.action.update.UpdateResponse import org.opensearch.client.Client import org.opensearch.cluster.service.ClusterService @@ -57,7 +58,7 @@ constructor( user: User?, threadContext: ThreadContext.StoredContext, ): AcknowledgedResponse { - val smPolicy = client.getSMPolicy(request.id()) + val smPolicy = client.getSMPolicy(request.id) // Check if the requested user has permission on the resource, throwing an exception if the user does not verifyUserHasPermissionForResource(user, smPolicy.user, filterByEnabled, "snapshot management policy", smPolicy.policyName) @@ -71,7 +72,8 @@ constructor( private suspend fun enableSMPolicy(updateRequest: StartSMRequest): Boolean { val now = Instant.now().toEpochMilli() - updateRequest.index(INDEX_MANAGEMENT_INDEX).doc( + val updateReq = UpdateRequest(INDEX_MANAGEMENT_INDEX, updateRequest.id) + updateReq.doc( mapOf( SMPolicy.SM_TYPE to mapOf( @@ -83,12 +85,12 @@ constructor( ) val updateResponse: UpdateResponse = try { - client.suspendUntil { update(updateRequest, it) } + client.suspendUntil { update(updateReq, it) } } catch (e: VersionConflictEngineException) { - log.error("VersionConflictEngineException while trying to enable snapshot management policy id [${updateRequest.id()}]: $e") + log.error("VersionConflictEngineException while trying to enable snapshot management policy id [${updateRequest.id}]: $e") throw OpenSearchStatusException(conflictExceptionMessage, RestStatus.INTERNAL_SERVER_ERROR) } catch (e: Exception) { - log.error("Failed trying to enable snapshot management policy id [${updateRequest.id()}]: $e") + log.error("Failed trying to enable snapshot management policy id [${updateRequest.id}]: $e") throw OpenSearchStatusException("Failed while trying to enable SM Policy", RestStatus.INTERNAL_SERVER_ERROR) } return updateResponse.result == DocWriteResponse.Result.UPDATED diff --git a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt index 4d70096b6..2d537b251 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt @@ -5,25 +5,31 @@ package org.opensearch.indexmanagement.snapshotmanagement.api.transport.stop +import org.opensearch.action.ActionRequest import org.opensearch.action.ActionRequestValidationException -import org.opensearch.action.ValidateActions -import org.opensearch.action.update.UpdateRequest +import org.opensearch.action.ValidateActions.addValidationError import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import java.io.IOException -class StopSMRequest : UpdateRequest { +class StopSMRequest : ActionRequest { + + val id: String + get() = field + @Throws(IOException::class) - constructor(sin: StreamInput) : super(sin) + constructor(sin: StreamInput) : super(sin) { + this.id = sin.readString() + } constructor(id: String) { - super.id(id) + this.id = id } override fun validate(): ActionRequestValidationException? { var validationException: ActionRequestValidationException? = null - if (super.id().isEmpty()) { - validationException = ValidateActions.addValidationError("id is missing", validationException) + if (this.id.isEmpty()) { + validationException = addValidationError("id is missing", validationException) } return validationException } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/TransportStopSMAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/TransportStopSMAction.kt index 4e4b0b7e6..6d45735d6 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/TransportStopSMAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/TransportStopSMAction.kt @@ -11,6 +11,7 @@ import org.opensearch.OpenSearchStatusException import org.opensearch.action.DocWriteResponse import org.opensearch.action.support.ActionFilters import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.update.UpdateRequest import org.opensearch.action.update.UpdateResponse import org.opensearch.client.Client import org.opensearch.cluster.service.ClusterService @@ -57,7 +58,7 @@ constructor( user: User?, threadContext: ThreadContext.StoredContext, ): AcknowledgedResponse { - val smPolicy = client.getSMPolicy(request.id()) + val smPolicy = client.getSMPolicy(request.id) // Check if the requested user has permission on the resource, throwing an exception if the user does not verifyUserHasPermissionForResource(user, smPolicy.user, filterByEnabled, "snapshot management policy", smPolicy.policyName) @@ -71,7 +72,8 @@ constructor( private suspend fun disableSMPolicy(updateRequest: StopSMRequest): Boolean { val now = Instant.now().toEpochMilli() - updateRequest.index(INDEX_MANAGEMENT_INDEX).doc( + val updateReq = UpdateRequest(INDEX_MANAGEMENT_INDEX, updateRequest.id) + updateReq.doc( mapOf( SMPolicy.SM_TYPE to mapOf( @@ -83,12 +85,12 @@ constructor( ) val updateResponse: UpdateResponse = try { - client.suspendUntil { update(updateRequest, it) } + client.suspendUntil { update(updateReq, it) } } catch (e: VersionConflictEngineException) { - log.error("VersionConflictEngineException while trying to disable snapshot management policy id [${updateRequest.id()}]: $e") + log.error("VersionConflictEngineException while trying to disable snapshot management policy id [${updateRequest.id}]: $e") throw OpenSearchStatusException(conflictExceptionMessage, RestStatus.INTERNAL_SERVER_ERROR) } catch (e: Exception) { - log.error("Failed trying to disable snapshot management policy id [${updateRequest.id()}]: $e") + log.error("Failed trying to disable snapshot management policy id [${updateRequest.id}]: $e") throw OpenSearchStatusException("Failed while trying to disable SM Policy", RestStatus.INTERNAL_SERVER_ERROR) } // TODO update metadata diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt index 440aca087..9117ac0d5 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt @@ -7,6 +7,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.action import org.opensearch.action.DocWriteRequest import org.opensearch.action.support.WriteRequest +import org.opensearch.action.update.UpdateRequest import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.index.seqno.SequenceNumbers @@ -82,22 +83,22 @@ class RequestTests : OpenSearchTestCase() { fun `test start sm policy request`() { val id = "some_id" - val req = StartSMRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) val streamedReq = StartSMRequest(sin) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } fun `test stop sm policy request`() { val id = "some_id" - val req = StopSMRequest(id).index(INDEX_MANAGEMENT_INDEX) + val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) val streamedReq = StopSMRequest(sin) - assertEquals(id, streamedReq.id()) + assertEquals(id, streamedReq.id) } fun `test explain sm policy request`() { From 7f38da045623d04b037aa4d5279afbde675bcf82 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 14:45:02 -0500 Subject: [PATCH 06/20] Fix tests Signed-off-by: Craig Perkins --- .../rollup/action/start/StartRollupRequest.kt | 1 + .../indexmanagement/rollup/action/stop/StopRollupRequest.kt | 1 + .../snapshotmanagement/api/transport/start/StartSMRequest.kt | 1 + .../snapshotmanagement/api/transport/stop/StopSMRequest.kt | 1 + .../transform/action/start/StartTransformRequest.kt | 1 + .../transform/action/stop/StopTransformRequest.kt | 1 + .../opensearch/indexmanagement/rollup/action/RequestTests.kt | 5 ++--- .../snapshotmanagement/action/RequestTests.kt | 5 ++--- .../indexmanagement/transform/action/RequestTests.kt | 5 ++--- 9 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt index 9f352f8b5..5d4e63b36 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/start/StartRollupRequest.kt @@ -37,5 +37,6 @@ class StartRollupRequest : ActionRequest { @Throws(IOException::class) override fun writeTo(out: StreamOutput) { super.writeTo(out) + out.writeString(id) } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt index 0b1658460..0b5d4b75d 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt @@ -37,5 +37,6 @@ class StopRollupRequest : ActionRequest { @Throws(IOException::class) override fun writeTo(out: StreamOutput) { super.writeTo(out) + out.writeString(id) } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt index b64e876fa..6b22dd99e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/start/StartSMRequest.kt @@ -37,5 +37,6 @@ class StartSMRequest : ActionRequest { @Throws(IOException::class) override fun writeTo(out: StreamOutput) { super.writeTo(out) + out.writeString(id) } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt index 2d537b251..1b7961e09 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/stop/StopSMRequest.kt @@ -37,5 +37,6 @@ class StopSMRequest : ActionRequest { @Throws(IOException::class) override fun writeTo(out: StreamOutput) { super.writeTo(out) + out.writeString(id) } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt index 4846c1283..b9335c55c 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/start/StartTransformRequest.kt @@ -37,5 +37,6 @@ class StartTransformRequest : ActionRequest { @Throws(IOException::class) override fun writeTo(out: StreamOutput) { super.writeTo(out) + out.writeString(id) } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt index ceee2618b..5174abda3 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/action/stop/StopTransformRequest.kt @@ -37,5 +37,6 @@ class StopTransformRequest : ActionRequest { @Throws(IOException::class) override fun writeTo(out: StreamOutput) { super.writeTo(out) + out.writeString(id) } } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt index f77db904a..4b880336a 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/action/RequestTests.kt @@ -7,7 +7,6 @@ package org.opensearch.indexmanagement.rollup.action import org.opensearch.action.DocWriteRequest import org.opensearch.action.support.WriteRequest -import org.opensearch.action.update.UpdateRequest import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.index.seqno.SequenceNumbers @@ -135,7 +134,7 @@ class RequestTests : OpenSearchTestCase() { fun `test start rollup request`() { val id = "some_id" - val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) + val req = StartRollupRequest(id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) @@ -145,7 +144,7 @@ class RequestTests : OpenSearchTestCase() { fun `test stop rollup request`() { val id = "some_id" - val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) + val req = StopRollupRequest(id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt index 9117ac0d5..dbf7016ea 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/action/RequestTests.kt @@ -7,7 +7,6 @@ package org.opensearch.indexmanagement.snapshotmanagement.action import org.opensearch.action.DocWriteRequest import org.opensearch.action.support.WriteRequest -import org.opensearch.action.update.UpdateRequest import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.index.seqno.SequenceNumbers @@ -83,7 +82,7 @@ class RequestTests : OpenSearchTestCase() { fun `test start sm policy request`() { val id = "some_id" - val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) + val req = StartSMRequest(id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) @@ -93,7 +92,7 @@ class RequestTests : OpenSearchTestCase() { fun `test stop sm policy request`() { val id = "some_id" - val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) + val req = StopSMRequest(id) val out = BytesStreamOutput().apply { req.writeTo(this) } val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt index 1365aa631..79456e54d 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/action/RequestTests.kt @@ -7,7 +7,6 @@ package org.opensearch.indexmanagement.transform.action import org.opensearch.action.DocWriteRequest import org.opensearch.action.support.WriteRequest -import org.opensearch.action.update.UpdateRequest import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.index.seqno.SequenceNumbers import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -152,7 +151,7 @@ class RequestTests : OpenSearchTestCase() { fun `test start transform request`() { val id = "some_id" - val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) + val req = StartTransformRequest(id) val out = BytesStreamOutput().apply { req.writeTo(this) } val streamedReq = StartTransformRequest(buildStreamInputForTransforms(out)) @@ -162,7 +161,7 @@ class RequestTests : OpenSearchTestCase() { fun `test stop transform request`() { val id = "some_id" - val req = UpdateRequest(INDEX_MANAGEMENT_INDEX, id) + val req = StopTransformRequest(id) val out = BytesStreamOutput().apply { req.writeTo(this) } val streamedReq = StopTransformRequest(buildStreamInputForTransforms(out)) From 36318d32bb2af4fe0aa856ad5aaaaca5adff0adc Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 15:16:21 -0500 Subject: [PATCH 07/20] Free up disk space on github runner Signed-off-by: Craig Perkins --- .github/workflows/test-and-build-workflow.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 2ffadaaa0..6f0ee8b9f 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -37,6 +37,10 @@ jobs: options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Run start commands run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} # This step uses the setup-java Github action: https://github.com/actions/setup-java From 1da64a83dbe4566942c3a2425b0deaa84927dff2 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 15:25:44 -0500 Subject: [PATCH 08/20] Remove sudo Signed-off-by: Craig Perkins --- .github/workflows/test-and-build-workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 6f0ee8b9f..f3a739009 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -39,8 +39,8 @@ jobs: steps: - name: Remove unnecessary files run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" + rm -rf /usr/share/dotnet + rm -rf "$AGENT_TOOLSDIRECTORY" - name: Run start commands run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} # This step uses the setup-java Github action: https://github.com/actions/setup-java From d5474078b6a254c24b22fe450675bbd98f09e0b2 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 16:05:17 -0500 Subject: [PATCH 09/20] Check runner space Signed-off-by: Craig Perkins --- .github/workflows/test-and-build-workflow.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index f3a739009..b69df2d06 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -52,6 +52,13 @@ jobs: # build index management - name: Checkout Branch uses: actions/checkout@v4 + - name: Check working space directory + run: du ${GITHUB_WORKSPACE} -h -d 1 + - name: Get more space + run: | + df . -h + sudo rm -rf ${GITHUB_WORKSPACE}/.git + df . -h # This is a hack, but this step creates a link to the X: mounted drive, which makes the path # short enough to work on Windows - name: Build with Gradle From 875b9110bfca814b4fd8e391feae8657155edaf4 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 16:35:49 -0500 Subject: [PATCH 10/20] Remove sudo Signed-off-by: Craig Perkins --- .github/workflows/test-and-build-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index b69df2d06..b759c262f 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -57,7 +57,7 @@ jobs: - name: Get more space run: | df . -h - sudo rm -rf ${GITHUB_WORKSPACE}/.git + rm -rf ${GITHUB_WORKSPACE}/.git df . -h # This is a hack, but this step creates a link to the X: mounted drive, which makes the path # short enough to work on Windows From dc11c5b1b809f3906b69363a44a3869b48d7fdf8 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 26 Nov 2024 17:06:12 -0500 Subject: [PATCH 11/20] Delete index in test Signed-off-by: Craig Perkins --- .github/workflows/test-and-build-workflow.yml | 11 ----------- .../resthandler/RestRemovePolicyActionIT.kt | 5 +++++ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index b759c262f..2ffadaaa0 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -37,10 +37,6 @@ jobs: options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: - - name: Remove unnecessary files - run: | - rm -rf /usr/share/dotnet - rm -rf "$AGENT_TOOLSDIRECTORY" - name: Run start commands run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} # This step uses the setup-java Github action: https://github.com/actions/setup-java @@ -52,13 +48,6 @@ jobs: # build index management - name: Checkout Branch uses: actions/checkout@v4 - - name: Check working space directory - run: du ${GITHUB_WORKSPACE} -h -d 1 - - name: Get more space - run: | - df . -h - rm -rf ${GITHUB_WORKSPACE}/.git - df . -h # This is a hack, but this step creates a link to the X: mounted drive, which makes the path # short enough to work on Windows - name: Build with Gradle diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt index 83ea5c99b..06041d365 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt @@ -15,6 +15,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.FAILURES import org.opensearch.indexmanagement.indexstatemanagement.util.UPDATED_INDICES import org.opensearch.indexmanagement.makeRequest import org.opensearch.indexmanagement.waitFor +import org.opensearch.rest.RestRequest.Method.DELETE import org.opensearch.rest.RestRequest.Method.POST class RestRemovePolicyActionIT : IndexStateManagementRestTestCase() { @@ -230,5 +231,9 @@ class RestRemovePolicyActionIT : IndexStateManagementRestTestCase() { // otherwise, test cleanup cannot delete this index updateIndexSetting(index1, IndexMetadata.SETTING_READ_ONLY, "false") + adminClient().makeRequest( + DELETE.toString(), + "/$index1", + ) } } From 86cf60161a2c548f5fa065c95ab1dae6c4ac8c30 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 08:47:46 -0500 Subject: [PATCH 12/20] Skip generic Signed-off-by: Craig Perkins --- .../opensearch/indexmanagement/IndexManagementRestTestCase.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt index a55809379..fbfa91fde 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt @@ -369,6 +369,7 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() { val active = (jsonObject["active"] as String).toInt() val queue = (jsonObject["queue"] as String).toInt() val name = jsonObject["name"] + if (name == "generic") continue val trueActive = if (name == "management") active - 1 else active if (trueActive > 0 || queue > 0) { fail("Still active threadpools in cluster: $jsonObject") From 7dd60d1c93cda10920e603e35d5888ac9972f6a5 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 09:21:03 -0500 Subject: [PATCH 13/20] Clear AfterClass Signed-off-by: Craig Perkins --- .../resthandler/RestRemovePolicyActionIT.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt index 06041d365..b9a3084f2 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt @@ -5,6 +5,7 @@ package org.opensearch.indexmanagement.indexstatemanagement.resthandler +import org.junit.AfterClass import org.opensearch.client.ResponseException import org.opensearch.cluster.metadata.IndexMetadata import org.opensearch.core.rest.RestStatus @@ -19,6 +20,13 @@ import org.opensearch.rest.RestRequest.Method.DELETE import org.opensearch.rest.RestRequest.Method.POST class RestRemovePolicyActionIT : IndexStateManagementRestTestCase() { + companion object { + @AfterClass + @JvmStatic fun clearIndicesAfterClass() { + wipeAllIndices() + } + } + fun `test missing indices`() { try { client().makeRequest(POST.toString(), RestRemovePolicyAction.REMOVE_POLICY_BASE_URI) From 7c824704dd3d06ad5e917a12859fa49647d7b46f Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 10:32:32 -0500 Subject: [PATCH 14/20] Permissive warnings handler Signed-off-by: Craig Perkins --- .../resthandler/RestChangePolicyActionIT.kt | 5 +++++ .../rollup/resthandler/RestStartRollupActionIT.kt | 5 +++++ .../rollup/resthandler/RestStopRollupActionIT.kt | 5 +++++ .../resthandler/RestDeleteSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestExplainSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestGetSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestIndexSnapshotManagementIT.kt | 5 +++++ .../resthandler/RestStartSnapshotManagementIT.kt | 9 +++++++-- .../resthandler/RestStopSnapshotManagementIT.kt | 5 +++++ .../transform/resthandler/RestDeleteTransformActionIT.kt | 5 +++++ .../resthandler/RestExplainTransformActionIT.kt | 5 +++++ 11 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt index ee2621bca..5d12c032b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt @@ -7,7 +7,9 @@ package org.opensearch.indexmanagement.indexstatemanagement.resthandler import org.junit.Before import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -92,6 +94,9 @@ class RestChangePolicyActionIT : IndexStateManagementRestTestCase() { fun `test nonexistent ism config index`() { if (indexExists(INDEX_MANAGEMENT_INDEX)) { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) } try { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt index e165a5b71..02eea1a64 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.rollup.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices @@ -203,6 +205,9 @@ class RestStartRollupActionIT : RollupRestAPITestCase() { fun `test start rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt index 4789e1f50..ecc4f94b7 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.rollup.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices @@ -259,6 +261,9 @@ class RestStopRollupActionIT : RollupRestAPITestCase() { fun `test stop rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt index 13ecd4a71..07081bd65 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -40,6 +42,9 @@ class RestDeleteSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test deleting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("DELETE", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_policy") fail("expected 404 ResponseException") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt index ce64e240f..bf5da3c56 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -143,6 +145,9 @@ class RestExplainSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test explain sm policy when config index doesn't exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) explainSMPolicy(randomAlphaOfLength(10)) fail("expected response exception") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt index ee9eba36c..f8e400b7e 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt @@ -8,7 +8,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.apache.hc.core5.http.HttpHeaders import org.apache.hc.core5.http.message.BasicHeader import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -51,6 +53,9 @@ class RestGetSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test getting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) getSMPolicy(randomAlphaOfLength(20)) fail("expected response exception") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt index f40467f81..0183300f3 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -132,6 +134,9 @@ class RestIndexSnapshotManagementIT : SnapshotManagementRestTestCase() { @Suppress("UNCHECKED_CAST") fun `test mappings after sm policy creation`() { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) createSMPolicy(randomSMPolicy()) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt index 8f8d0c67c..ac9ed0fd5 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -61,8 +63,11 @@ class RestStartSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test starting a snapshot management policy with no config index fails`() { try { - val request = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - adminClient().performRequest(request) + val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() + adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_start") fail("expected response exception") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt index fa308e552..ef281e9ec 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -62,6 +64,9 @@ class RestStopSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test stopping a snapshot management policy with no config index fails`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_stop") fail("expected response exception") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt index bc58daa3e..e7ec92eb6 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt @@ -6,7 +6,9 @@ package org.opensearch.indexmanagement.transform.resthandler import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI @@ -79,6 +81,9 @@ class RestDeleteTransformActionIT : TransformRestTestCase() { try { if (indexExists(INDEX_MANAGEMENT_INDEX)) { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) } val res = client().makeRequest("DELETE", "$TRANSFORM_BASE_URI/foobarbaz") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt index b9af789d7..b301eb915 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt @@ -7,7 +7,9 @@ package org.opensearch.indexmanagement.transform.resthandler import org.junit.Assert import org.opensearch.client.Request +import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException +import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI @@ -162,6 +164,9 @@ class RestExplainTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test explain transform when config doesnt exist`() { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + val options = RequestOptions.DEFAULT.toBuilder() + options.setWarningsHandler(WarningsHandler.PERMISSIVE) + deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val responseExplicit = client().makeRequest("GET", "$TRANSFORM_BASE_URI/no_config_some_transform/_explain") val expectedResponse = mapOf("no_config_some_transform" to "Failed to search transform metadata") From 15ad7089e0a694d3c1207af96f79287782a59aab Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 10:59:16 -0500 Subject: [PATCH 15/20] Move into waitFor Signed-off-by: Craig Perkins --- .../resthandler/RestRemovePolicyActionIT.kt | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt index b9a3084f2..7f96ff679 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt @@ -5,7 +5,6 @@ package org.opensearch.indexmanagement.indexstatemanagement.resthandler -import org.junit.AfterClass import org.opensearch.client.ResponseException import org.opensearch.cluster.metadata.IndexMetadata import org.opensearch.core.rest.RestStatus @@ -16,17 +15,9 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.FAILURES import org.opensearch.indexmanagement.indexstatemanagement.util.UPDATED_INDICES import org.opensearch.indexmanagement.makeRequest import org.opensearch.indexmanagement.waitFor -import org.opensearch.rest.RestRequest.Method.DELETE import org.opensearch.rest.RestRequest.Method.POST class RestRemovePolicyActionIT : IndexStateManagementRestTestCase() { - companion object { - @AfterClass - @JvmStatic fun clearIndicesAfterClass() { - wipeAllIndices() - } - } - fun `test missing indices`() { try { client().makeRequest(POST.toString(), RestRemovePolicyAction.REMOVE_POLICY_BASE_URI) @@ -235,13 +226,9 @@ class RestRemovePolicyActionIT : IndexStateManagementRestTestCase() { assertEquals("auto manage setting not false after removing policy for index $index4", false, getIndexAutoManageSetting(index3)) assertEquals("read only setting changed after removing policy for index $index4", null, getIndexReadOnlySetting(index3)) assertEquals("read only allow delete setting changed after removing policy for index $index4", null, getIndexReadOnlyAllowDeleteSetting(index3)) - } - // otherwise, test cleanup cannot delete this index - updateIndexSetting(index1, IndexMetadata.SETTING_READ_ONLY, "false") - adminClient().makeRequest( - DELETE.toString(), - "/$index1", - ) + // otherwise, test cleanup cannot delete this index + updateIndexSetting(index1, IndexMetadata.SETTING_READ_ONLY, "false") + } } } From 94d808bd6b808c034451f61605f1efa228deb608 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 11:00:06 -0500 Subject: [PATCH 16/20] Remove match to generic Signed-off-by: Craig Perkins --- .../opensearch/indexmanagement/IndexManagementRestTestCase.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt index fbfa91fde..a55809379 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementRestTestCase.kt @@ -369,7 +369,6 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() { val active = (jsonObject["active"] as String).toInt() val queue = (jsonObject["queue"] as String).toInt() val name = jsonObject["name"] - if (name == "generic") continue val trueActive = if (name == "management") active - 1 else active if (trueActive > 0 || queue > 0) { fail("Still active threadpools in cluster: $jsonObject") From c663da7524958a8c836166071a91b29e970e7c7d Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 17:04:41 -0500 Subject: [PATCH 17/20] Revert "Permissive warnings handler" This reverts commit 7c824704dd3d06ad5e917a12859fa49647d7b46f. Signed-off-by: Craig Perkins --- .../resthandler/RestChangePolicyActionIT.kt | 5 ----- .../rollup/resthandler/RestStartRollupActionIT.kt | 5 ----- .../rollup/resthandler/RestStopRollupActionIT.kt | 5 ----- .../resthandler/RestDeleteSnapshotManagementIT.kt | 5 ----- .../resthandler/RestExplainSnapshotManagementIT.kt | 5 ----- .../resthandler/RestGetSnapshotManagementIT.kt | 5 ----- .../resthandler/RestIndexSnapshotManagementIT.kt | 5 ----- .../resthandler/RestStartSnapshotManagementIT.kt | 9 ++------- .../resthandler/RestStopSnapshotManagementIT.kt | 5 ----- .../transform/resthandler/RestDeleteTransformActionIT.kt | 5 ----- .../resthandler/RestExplainTransformActionIT.kt | 5 ----- 11 files changed, 2 insertions(+), 57 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt index 5d12c032b..ee2621bca 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestChangePolicyActionIT.kt @@ -7,9 +7,7 @@ package org.opensearch.indexmanagement.indexstatemanagement.resthandler import org.junit.Before import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -94,9 +92,6 @@ class RestChangePolicyActionIT : IndexStateManagementRestTestCase() { fun `test nonexistent ism config index`() { if (indexExists(INDEX_MANAGEMENT_INDEX)) { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) } try { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt index 02eea1a64..e165a5b71 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStartRollupActionIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.rollup.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices @@ -205,9 +203,6 @@ class RestStartRollupActionIT : RollupRestAPITestCase() { fun `test start rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt index ecc4f94b7..4789e1f50 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestStopRollupActionIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.rollup.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.common.settings.Settings import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementIndices @@ -261,9 +259,6 @@ class RestStopRollupActionIT : RollupRestAPITestCase() { fun `test stop rollup when multiple shards configured for IM config index`() { // setup ism-config index with multiple primary shards val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val mapping = IndexManagementIndices.indexManagementMappings.trim().trimStart('{').trimEnd('}') val settings = diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt index 07081bd65..13ecd4a71 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestDeleteSnapshotManagementIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -42,9 +40,6 @@ class RestDeleteSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test deleting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("DELETE", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_policy") fail("expected 404 ResponseException") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt index bf5da3c56..ce64e240f 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestExplainSnapshotManagementIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -145,9 +143,6 @@ class RestExplainSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test explain sm policy when config index doesn't exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) explainSMPolicy(randomAlphaOfLength(10)) fail("expected response exception") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt index f8e400b7e..ee9eba36c 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestGetSnapshotManagementIT.kt @@ -8,9 +8,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.apache.hc.core5.http.HttpHeaders import org.apache.hc.core5.http.message.BasicHeader import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -53,9 +51,6 @@ class RestGetSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test getting a snapshot management policy that doesn't exist and config index doesnt exist`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) getSMPolicy(randomAlphaOfLength(20)) fail("expected response exception") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt index 0183300f3..f40467f81 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestIndexSnapshotManagementIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.common.xcontent.XContentType import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -134,9 +132,6 @@ class RestIndexSnapshotManagementIT : SnapshotManagementRestTestCase() { @Suppress("UNCHECKED_CAST") fun `test mappings after sm policy creation`() { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) createSMPolicy(randomSMPolicy()) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt index ac9ed0fd5..8f8d0c67c 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStartSnapshotManagementIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -63,11 +61,8 @@ class RestStartSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test starting a snapshot management policy with no config index fails`() { try { - val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() - adminClient().performRequest(deleteISMIndexRequest) + val request = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") + adminClient().performRequest(request) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_start") fail("expected response exception") } catch (e: ResponseException) { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt index ef281e9ec..fa308e552 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/snapshotmanagement/resthandler/RestStopSnapshotManagementIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.snapshotmanagement.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX @@ -64,9 +62,6 @@ class RestStopSnapshotManagementIT : SnapshotManagementRestTestCase() { fun `test stopping a snapshot management policy with no config index fails`() { try { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) client().makeRequest("POST", "${IndexManagementPlugin.SM_POLICIES_URI}/nonexistent_foo/_stop") fail("expected response exception") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt index e7ec92eb6..bc58daa3e 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestDeleteTransformActionIT.kt @@ -6,9 +6,7 @@ package org.opensearch.indexmanagement.transform.resthandler import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI @@ -81,9 +79,6 @@ class RestDeleteTransformActionIT : TransformRestTestCase() { try { if (indexExists(INDEX_MANAGEMENT_INDEX)) { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) } val res = client().makeRequest("DELETE", "$TRANSFORM_BASE_URI/foobarbaz") diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt index b301eb915..b9af789d7 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt @@ -7,9 +7,7 @@ package org.opensearch.indexmanagement.transform.resthandler import org.junit.Assert import org.opensearch.client.Request -import org.opensearch.client.RequestOptions import org.opensearch.client.ResponseException -import org.opensearch.client.WarningsHandler import org.opensearch.core.rest.RestStatus import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.TRANSFORM_BASE_URI @@ -164,9 +162,6 @@ class RestExplainTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test explain transform when config doesnt exist`() { val deleteISMIndexRequest = Request("DELETE", "/$INDEX_MANAGEMENT_INDEX") - val options = RequestOptions.DEFAULT.toBuilder() - options.setWarningsHandler(WarningsHandler.PERMISSIVE) - deleteISMIndexRequest.options = options.build() adminClient().performRequest(deleteISMIndexRequest) val responseExplicit = client().makeRequest("GET", "$TRANSFORM_BASE_URI/no_config_some_transform/_explain") val expectedResponse = mapOf("no_config_some_transform" to "Failed to search transform metadata") From bed778898149d7358ae23af8fe7ed646f51eff28 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 27 Nov 2024 17:11:28 -0500 Subject: [PATCH 18/20] Move back out of waitFor Signed-off-by: Craig Perkins --- .../resthandler/RestRemovePolicyActionIT.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt index 7f96ff679..83ea5c99b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestRemovePolicyActionIT.kt @@ -226,9 +226,9 @@ class RestRemovePolicyActionIT : IndexStateManagementRestTestCase() { assertEquals("auto manage setting not false after removing policy for index $index4", false, getIndexAutoManageSetting(index3)) assertEquals("read only setting changed after removing policy for index $index4", null, getIndexReadOnlySetting(index3)) assertEquals("read only allow delete setting changed after removing policy for index $index4", null, getIndexReadOnlyAllowDeleteSetting(index3)) - - // otherwise, test cleanup cannot delete this index - updateIndexSetting(index1, IndexMetadata.SETTING_READ_ONLY, "false") } + + // otherwise, test cleanup cannot delete this index + updateIndexSetting(index1, IndexMetadata.SETTING_READ_ONLY, "false") } } From 295530fee5be1e946e861471c5b794cc1800e9a0 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 6 Dec 2024 15:41:55 -0500 Subject: [PATCH 19/20] Fix issue with readonly indices after bugfix in core (https://github.com/opensearch-project/OpenSearch/pull/16568) Signed-off-by: Craig Perkins --- .../TransportRemovePolicyAction.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/TransportRemovePolicyAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/TransportRemovePolicyAction.kt index dcefa694e..55150225e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/TransportRemovePolicyAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/TransportRemovePolicyAction.kt @@ -268,8 +268,13 @@ constructor( updateSettingReqsList.add( UpdateSettingsRequest().indices(*readOnlyIndices.map { indices[it] }.toTypedArray()) .settings( - Settings.builder().put(ManagedIndexSettings.AUTO_MANAGE.key, false) - .put(INDEX_READ_ONLY_SETTING.key, true), + Settings.builder().put(INDEX_READ_ONLY_SETTING.key, false), + ), + ) + updateSettingReqsList.add( + UpdateSettingsRequest().indices(*readOnlyIndices.map { indices[it] }.toTypedArray()) + .settings( + Settings.builder().put(ManagedIndexSettings.AUTO_MANAGE.key, false).put(INDEX_READ_ONLY_SETTING.key, true), ), ) } @@ -277,8 +282,13 @@ constructor( updateSettingReqsList.add( UpdateSettingsRequest().indices(*readOnlyAllowDeleteIndices.map { indices[it] }.toTypedArray()) .settings( - Settings.builder().put(ManagedIndexSettings.AUTO_MANAGE.key, false) - .put(INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.key, true), + Settings.builder().put(INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.key, false), + ), + ) + updateSettingReqsList.add( + UpdateSettingsRequest().indices(*readOnlyAllowDeleteIndices.map { indices[it] }.toTypedArray()) + .settings( + Settings.builder().put(ManagedIndexSettings.AUTO_MANAGE.key, false).put(INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.key, true), ), ) } From e8d2df9ba2759ed8364d496c8fece139e8fce2a5 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 12 Dec 2024 09:35:29 -0500 Subject: [PATCH 20/20] Overwrite true Signed-off-by: Craig Perkins --- .github/workflows/test-and-build-workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 2ffadaaa0..32870eefa 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -60,6 +60,7 @@ jobs: with: name: logs-${{ matrix.java }}-${{ matrix.feature }} path: build/testclusters/integTest-*/logs/* + overwrite: 'true' - name: Create Artifact Path run: | mkdir -p index-management-artifacts