Skip to content

Commit

Permalink
Handle respone for deletion of non-existing autofollow replication ru…
Browse files Browse the repository at this point in the history
…le (#1371) (#1372)

Signed-off-by: Sanjay Kumar <[email protected]>
(cherry picked from commit d404742)

Co-authored-by: Sanjay Kumar <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and skumarp7 authored Apr 25, 2024
1 parent a501df9 commit 619f10d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class TransportAutoFollowClusterManagerNodeAction @Inject constructor(transportS
} catch(e: ResourceNotFoundException) {
// Log warn as the task is already removed
log.warn("Task already stopped for '$clusterAlias:$patternName'", e)
throw OpenSearchException("Autofollow replication rule $clusterAlias:$patternName does not exist")
} catch (e: Exception) {
log.error("Failed to stop 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 @@ -295,6 +295,22 @@ class UpdateAutoFollowPatternIT: MultiClusterRestTestCase() {
.hasMessageContaining(errorMsg)
}

fun `test deletion of auto follow pattern`() {
val followerClient = getClientForCluster(FOLLOWER)
createConnectionBetweenClusters(FOLLOWER, LEADER, connectionAlias)
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, indexPattern)
//Delete a replication rule which does not exist
Assertions.assertThatThrownBy {
followerClient.deleteAutoFollowPattern(connectionAlias, "dummy_conn")
}.isInstanceOf(ResponseException::class.java)
.hasMessageContaining("does not exist")
//Delete a replication rule which exists
Assertions.assertThatCode {
followerClient.deleteAutoFollowPattern(connectionAlias, indexPatternName)
}.doesNotThrowAnyException()

}

fun `test removing autofollow pattern stop autofollow task`() {
val followerClient = getClientForCluster(FOLLOWER)
val leaderClient = getClientForCluster(LEADER)
Expand Down

0 comments on commit 619f10d

Please sign in to comment.