Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to ignore updates on autofollow pattern #1449

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/workflows/bwc.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions .github/workflows/security-knn-tests.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ignoreIfExists is false then exception will not be thrown. Is that the expected behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, the check is slightly confusing. If ignoreIfExists is false, it will throw the exception

}
}

fun RestHighLevelClient.AutoFollowStats() : Map<String, Any> {
Original file line number Diff line number Diff line change
@@ -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()
}