Skip to content

Commit

Permalink
Handle respone for deletion of non-existing autofollow replication rule
Browse files Browse the repository at this point in the history
Signed-off-by: Sanjay Kumar <[email protected]>
  • Loading branch information
skumarp7 committed Apr 22, 2024
1 parent 90fcb8b commit 64d03af
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 @@ -294,6 +294,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 64d03af

Please sign in to comment.