Skip to content

Commit

Permalink
Integ test to verify that delete/index operation are blocked on follower
Browse files Browse the repository at this point in the history
Adding integ test to verify that cluster block exception is thrown
when trying to delete follower index or indexing documents
after starting replication

Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Jul 30, 2021
1 parent 9e5491b commit f8dbc76
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.elasticsearch.action.index.IndexRequest
import org.elasticsearch.client.Request
import org.elasticsearch.client.RequestOptions
import org.elasticsearch.client.ResponseException
import org.elasticsearch.client.indices.CloseIndexRequest
import org.elasticsearch.client.indices.CreateIndexRequest
import org.elasticsearch.client.indices.GetIndexRequest
import org.elasticsearch.client.indices.GetMappingsRequest
Expand Down Expand Up @@ -709,9 +710,19 @@ class StartReplicationIT: MultiClusterRestTestCase() {
.withFailMessage("Cant find replication block afer starting replication")
.isTrue()
}
// Delete index
assertThatThrownBy {
followerClient.indices().delete(DeleteIndexRequest(followerIndexName), RequestOptions.DEFAULT)
}.isInstanceOf(ElasticsearchStatusException::class.java).hasMessageContaining("cluster_block_exception")
// Close index
assertThatThrownBy {
followerClient.indices().close(CloseIndexRequest(followerIndexName), RequestOptions.DEFAULT)
}.isInstanceOf(ElasticsearchStatusException::class.java).hasMessageContaining("cluster_block_exception")
// Index document
assertThatThrownBy {
val sourceMap = mapOf("name" to randomAlphaOfLength(5))
followerClient.index(IndexRequest(followerIndexName).id("1").source(sourceMap), RequestOptions.DEFAULT)
}.isInstanceOf(ElasticsearchStatusException::class.java).hasMessageContaining("cluster_block_exception")
} finally {
followerClient.stopReplication(followerIndexName)
}
Expand Down

0 comments on commit f8dbc76

Please sign in to comment.