Skip to content

Commit

Permalink
backport 1405 to 2.x (opensearch-project#1415)
Browse files Browse the repository at this point in the history
Signed-off-by: Sanjay Kumar <[email protected]>
  • Loading branch information
skumarp7 authored Jul 26, 2024
1 parent 257f6b9 commit 74013de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit 74013de

Please sign in to comment.