diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 5e6ac8c3..ab00c65d 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -22,7 +22,7 @@ jobs: - name: Get tag id: tag uses: dawidd6/action-get-tag@v1 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ncipollo/release-action@v1 with: github_token: ${{ steps.github_app_token.outputs.token }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 125d13db..f429d0c1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -32,7 +32,7 @@ jobs: steps: - name: Checkout CCR - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Java ${{ matrix.java }} uses: actions/setup-java@v1 with: @@ -44,7 +44,7 @@ jobs: chown -R 1000:1000 `pwd` su `id -un 1000` -c 'whoami && java -version && ./gradlew --refresh-dependencies clean release -D"build.snapshot=true"' - name: Upload failed logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: logs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca44eebf..95e0b220 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: java-version: ${{ matrix.java }} # This step uses the checkout Github action: https://github.com/actions/checkout - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build and run Replication tests run: | ./gradlew --refresh-dependencies clean release -D"build.snapshot=true" -x test -x IntegTest diff --git a/.github/workflows/bwc.yml b/.github/workflows/bwc.yml index 59e082c7..4cce518e 100644 --- a/.github/workflows/bwc.yml +++ b/.github/workflows/bwc.yml @@ -21,14 +21,14 @@ jobs: java-version: 11 # This step uses the checkout Github action: https://github.com/actions/checkout - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build and run Replication tests run: | echo "Running backwards compatibility tests ..." ./gradlew --refresh-dependencies clean release -Dbuild.snapshot=true -x test -x IntegTest ./gradlew fullRestartClusterTask --stacktrace - name: Upload failed logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: logs diff --git a/.github/workflows/security-knn-tests.yml b/.github/workflows/security-knn-tests.yml index a6b3fd9d..1cc955cb 100644 --- a/.github/workflows/security-knn-tests.yml +++ b/.github/workflows/security-knn-tests.yml @@ -24,7 +24,7 @@ jobs: steps: # This step uses the checkout Github action: https://github.com/actions/checkout - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - id: plugin-availability-check name: "plugin check" run: | @@ -71,14 +71,14 @@ jobs: java-version: 17 # This step uses the checkout Github action: https://github.com/actions/checkout - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build and run Replication tests run: | chown -R 1000:1000 `pwd` ls -al src/test/resources/security/plugin su `id -un 1000` -c "whoami && java -version && ./gradlew --refresh-dependencies clean release -Dbuild.snapshot=true -Psecurity=true" - name: Upload failed logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: logs @@ -116,13 +116,13 @@ jobs: java-version: 17 # This step uses the checkout Github action: https://github.com/actions/checkout - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build and run Replication tests run: | chown -R 1000:1000 `pwd` su `id -un 1000` -c 'whoami && java -version && ./gradlew --refresh-dependencies clean release -Dbuild.snapshot=true -PnumNodes=1 -Dtests.class=org.opensearch.replication.BasicReplicationIT -Dtests.method="test knn index replication" -Pknn=true' - name: Upload failed logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: logs diff --git a/src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt b/src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt index 892470f5..f0fe55e2 100644 --- a/src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt +++ b/src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt @@ -20,6 +20,7 @@ import org.opensearch.action.support.master.AcknowledgedResponse import org.opensearch.client.Request import org.opensearch.client.RequestOptions import org.opensearch.client.Response +import org.opensearch.client.ResponseException import org.opensearch.client.RestHighLevelClient import org.opensearch.common.settings.Settings import org.opensearch.common.unit.TimeValue @@ -325,7 +326,8 @@ fun RestHighLevelClient.waitForReplicationStop(index: String, waitFor : TimeValu fun RestHighLevelClient.updateAutoFollowPattern(connection: String, patternName: String, pattern: String, settings: Settings = Settings.EMPTY, useRoles: UseRoles = UseRoles(), - requestOptions: RequestOptions = RequestOptions.DEFAULT) { + requestOptions: RequestOptions = RequestOptions.DEFAULT, + ignoreIfExists: Boolean = false) { val lowLevelRequest = Request("POST", REST_AUTO_FOLLOW_PATTERN) if (settings == Settings.EMPTY) { lowLevelRequest.setJsonEntity("""{ @@ -350,9 +352,14 @@ fun RestHighLevelClient.updateAutoFollowPattern(connection: String, patternName: }""") } lowLevelRequest.setOptions(requestOptions) - val lowLevelResponse = lowLevelClient.performRequest(lowLevelRequest) - val response = getAckResponse(lowLevelResponse) - assertThat(response.isAcknowledged).isTrue() + try { + val lowLevelResponse = lowLevelClient.performRequest(lowLevelRequest) + val response = getAckResponse(lowLevelResponse) + assertThat(response.isAcknowledged).isTrue() + } catch (e: ResponseException) { + // Skip if ignoreIfExists is true and exception contains resource_already_exists_exception + if ((ignoreIfExists == true && e.message?.contains("resource_already_exists_exception")!!) == false) throw e + } } fun RestHighLevelClient.AutoFollowStats() : Map<String, Any> { diff --git a/src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt b/src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt index 6782e56c..044ee246 100644 --- a/src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt +++ b/src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt @@ -523,7 +523,11 @@ class UpdateAutoFollowPatternIT: MultiClusterRestTestCase() { private fun assertValidPatternValidation(followerClient: RestHighLevelClient, pattern: String) { Assertions.assertThatCode { - followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, pattern) + try { + followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, pattern) + } finally { + followerClient.deleteAutoFollowPattern(connectionAlias, indexPatternName) + } }.doesNotThrowAnyException() }