Skip to content

Commit

Permalink
Retrieving default settings and validating status code in IT
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Bafna <[email protected]>
  • Loading branch information
gbbafna committed Aug 3, 2022
1 parent 85212b4 commit afb9fbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class TransportReplicateIndexAction @Inject constructor(transportService: Transp

private suspend fun getLeaderIndexSettings(leaderAlias: String, leaderIndex: String): Settings {
val remoteClient = client.getRemoteClusterClient(leaderAlias)
val getSettingsRequest = GetSettingsRequest().includeDefaults(false).indices(leaderIndex)
val getSettingsRequest = GetSettingsRequest().includeDefaults(true).indices(leaderIndex)
val settingsResponse = remoteClient.suspending(remoteClient.admin().indices()::getSettings,
injectSecurityContext = true)(getSettingsRequest)
return settingsResponse.indexToSettings.get(leaderIndex) ?: throw IndexNotFoundException("${leaderAlias}:${leaderIndex}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,11 +1181,12 @@ class StartReplicationIT: MultiClusterRestTestCase() {
.put("index.data_path", "/random-path/invalid-setting")
.build()

assertThatThrownBy {
try {
followerClient.startReplication(StartReplicationRequest("source", leaderIndexName, followerIndexName, settings = settings))
}.isInstanceOf(ResponseException::class.java).hasMessageContaining(
"Validation Failed: 1: custom path [/random-path/invalid-setting] is not a sub-path of path.shared_data"
)
} catch (e: ResponseException) {
Assert.assertEquals(400, e.response.statusLine.statusCode)
Assert.assertTrue(e.message!!.contains("Validation Failed: 1: custom path [/random-path/invalid-setting] is not a sub-path of path.shared_data"))
}
}

fun `test that replication is not started when all primary shards are not in active state`() {
Expand Down

0 comments on commit afb9fbb

Please sign in to comment.