From f8dbc76d826e91bfa041915d354d52c060d9b33f Mon Sep 17 00:00:00 2001 From: Sooraj Sinha Date: Thu, 29 Jul 2021 19:07:42 +0530 Subject: [PATCH] Integ test to verify that delete/index operation are blocked on follower 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 --- .../replication/integ/rest/StartReplicationIT.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt b/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt index a80a0eb9..d1af1f00 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt +++ b/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt @@ -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 @@ -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) }