Skip to content

Commit

Permalink
rebased commit
Browse files Browse the repository at this point in the history
Signed-off-by: Sanjay Kumar <[email protected]>
  • Loading branch information
skumarp7 authored and ankitkala committed Jul 22, 2024
1 parent 434d31a commit 06e6bd3
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,50 @@ class UpdateAutoFollowPatternIT: MultiClusterRestTestCase() {
fun getIndexReplicationTasks(clusterName: String): List<TaskInfo> {
return getReplicationTaskList(clusterName, IndexReplicationExecutor.TASK_NAME + "*")
}
fun `test auto follow should fail on indexPattern validation failure`() {
val followerClient = getClientForCluster(FOLLOWER)
createConnectionBetweenClusters(FOLLOWER, LEADER, connectionAlias)
assertPatternValidation(followerClient, "testPattern,",
"Autofollow pattern: testPattern, must not contain the following characters")
assertPatternValidation(followerClient, "testPat?",
"Autofollow pattern: testPat? must not contain the following characters")
assertPatternValidation(followerClient, "test#",
"Autofollow pattern: test# must not contain '#' or ':'")
assertPatternValidation(followerClient, "test:",
"Autofollow pattern: test: must not contain '#' or ':'")
assertPatternValidation(followerClient, "_test",
"Autofollow pattern: _test must not start with '_' or '-'")
assertPatternValidation(followerClient, "-leader",
"Autofollow pattern: -leader must not start with '_' or '-'")
assertPatternValidation(followerClient, "",
"Autofollow pattern: must not be empty")

}
private fun assertPatternValidation(followerClient: RestHighLevelClient, pattern: String,
errorMsg: String) {
Assertions.assertThatThrownBy {
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, pattern)
}.isInstanceOf(ResponseException::class.java)
.hasMessageContaining(errorMsg)
}

fun `test auto follow should succeed on valid indexPatterns`() {
val followerClient = getClientForCluster(FOLLOWER)
createConnectionBetweenClusters(FOLLOWER, LEADER, connectionAlias)
assertValidPatternValidation(followerClient, "test-leader")
assertValidPatternValidation(followerClient, "test*")
assertValidPatternValidation(followerClient, "leader-*")
assertValidPatternValidation(followerClient, "leader_test")
assertValidPatternValidation(followerClient, "Leader_Test-*")
assertValidPatternValidation(followerClient, "Leader_*")

}

private fun assertValidPatternValidation(followerClient: RestHighLevelClient, pattern: String) {
Assertions.assertThatCode {
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, pattern)
}.doesNotThrowAnyException()
}

fun createDummyConnection(fromClusterName: String, connectionName: String="source") {
val fromCluster = getNamedCluster(fromClusterName)
Expand Down

0 comments on commit 06e6bd3

Please sign in to comment.