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

[Backport 2.x] Handle exception for the updation of a replication rule #1415

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class TransportAutoFollowClusterManagerNodeAction @Inject constructor(transportS
} catch(e: ResourceAlreadyExistsException) {
// Log and bail as task is already running
log.warn("Task already started for '$clusterAlias:$patternName'", e)
throw OpenSearchException("Exisiting autofollow replication rule cannot be recreated/updated", e)
} catch (e: Exception) {
log.error("Failed to start auto follow task for cluster '$clusterAlias:$patternName'", e)
throw OpenSearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,32 @@ class UpdateAutoFollowPatternIT: MultiClusterRestTestCase() {
followerClient.deleteAutoFollowPattern(connectionAlias, indexPatternName)
}.doesNotThrowAnyException()

}
fun `test updation of auto follow pattern`() {
val followerClient = getClientForCluster(FOLLOWER)
createConnectionBetweenClusters(FOLLOWER, LEADER, connectionAlias)
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, indexPattern)
val indexPattern1 = "log*"
//Re-create the same replication rule
Assertions.assertThatThrownBy {
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, indexPattern)
}.isInstanceOf(ResponseException::class.java)
.hasMessageContaining("autofollow replication rule cannot be recreated/updated")

//Update the replication rule with different indexpattern
Assertions.assertThatThrownBy {
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, indexPattern1)
}.isInstanceOf(ResponseException::class.java)
.hasMessageContaining("autofollow replication rule cannot be recreated/updated")

//Create a new replication rule with same indexpattern but unique rule name
Assertions.assertThatCode {
followerClient.updateAutoFollowPattern(connectionAlias, "unique-rule", indexPattern1)
}.doesNotThrowAnyException()

followerClient.deleteAutoFollowPattern(connectionAlias, indexPatternName)
followerClient.deleteAutoFollowPattern(connectionAlias, "unique-rule")

}

fun `test removing autofollow pattern stop autofollow task`() {
Expand Down
Loading