|
70 | 70 | import org.elasticsearch.index.seqno.ReplicationTracker;
|
71 | 71 | import org.elasticsearch.index.seqno.RetentionLeaseActions;
|
72 | 72 | import org.elasticsearch.index.shard.ShardId;
|
| 73 | +import org.elasticsearch.indices.IndexClosedException; |
73 | 74 | import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
|
74 | 75 | import org.elasticsearch.plugins.Plugin;
|
75 | 76 | import org.elasticsearch.rest.RestStatus;
|
|
109 | 110 | import java.util.function.BooleanSupplier;
|
110 | 111 | import java.util.function.Consumer;
|
111 | 112 | import java.util.stream.Collectors;
|
| 113 | +import java.util.stream.IntStream; |
112 | 114 | import java.util.stream.Stream;
|
113 | 115 |
|
114 | 116 | import static java.util.Collections.singletonMap;
|
@@ -743,6 +745,47 @@ public void testDeleteLeaderIndex() throws Exception {
|
743 | 745 | ensureNoCcrTasks();
|
744 | 746 | }
|
745 | 747 |
|
| 748 | + public void testFollowClosedIndex() { |
| 749 | + final String leaderIndex = "test-index"; |
| 750 | + assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex) |
| 751 | + .setSettings(Settings.builder() |
| 752 | + .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) |
| 753 | + .build())); |
| 754 | + assertAcked(leaderClient().admin().indices().prepareClose(leaderIndex)); |
| 755 | + |
| 756 | + final String followerIndex = "follow-test-index"; |
| 757 | + expectThrows(IndexClosedException.class, |
| 758 | + () -> followerClient().execute(PutFollowAction.INSTANCE, putFollow(leaderIndex, followerIndex)).actionGet()); |
| 759 | + assertFalse(ESIntegTestCase.indexExists(followerIndex, followerClient())); |
| 760 | + } |
| 761 | + |
| 762 | + public void testResumeFollowOnClosedIndex() throws Exception { |
| 763 | + final String leaderIndex = "test-index"; |
| 764 | + assertAcked(leaderClient().admin().indices().prepareCreate(leaderIndex) |
| 765 | + .setSettings(Settings.builder() |
| 766 | + .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) |
| 767 | + .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) |
| 768 | + .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) |
| 769 | + .build())); |
| 770 | + ensureLeaderGreen(leaderIndex); |
| 771 | + |
| 772 | + final int nbDocs = randomIntBetween(10, 100); |
| 773 | + IntStream.of(nbDocs).forEach(i -> leaderClient().prepareIndex().setIndex(leaderIndex).setSource("field", i).get()); |
| 774 | + |
| 775 | + final String followerIndex = "follow-test-index"; |
| 776 | + PutFollowAction.Response response = |
| 777 | + followerClient().execute(PutFollowAction.INSTANCE, putFollow(leaderIndex, followerIndex)).actionGet(); |
| 778 | + assertTrue(response.isFollowIndexCreated()); |
| 779 | + assertTrue(response.isFollowIndexShardsAcked()); |
| 780 | + assertTrue(response.isIndexFollowingStarted()); |
| 781 | + |
| 782 | + pauseFollow(followerIndex); |
| 783 | + assertAcked(leaderClient().admin().indices().prepareClose(leaderIndex)); |
| 784 | + |
| 785 | + expectThrows(IndexClosedException.class, () -> |
| 786 | + followerClient().execute(ResumeFollowAction.INSTANCE, resumeFollow(followerIndex)).actionGet()); |
| 787 | + } |
| 788 | + |
746 | 789 | public void testDeleteFollowerIndex() throws Exception {
|
747 | 790 | assertAcked(leaderClient().admin().indices().prepareCreate("index1")
|
748 | 791 | .setSettings(Settings.builder()
|
|
0 commit comments