mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
Test bi-directional index following during a rolling upgrade. (#38962)
Follow index in follow cluster that follows an index in the leader cluster and another follow index in the leader index that follows that index in the follow cluster. During the upgrade index following is paused and after the upgrade index following is resumed and then verified index following works as expected. Relates to #38037
This commit is contained in:
parent
408a800f74
commit
03b2ec6ee6
@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
|
||||
|
||||
public void testIndexFollowing() throws Exception {
|
||||
public void testUniDirectionalIndexFollowing() throws Exception {
|
||||
logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);
|
||||
|
||||
if (clusterName == ClusterName.LEADER) {
|
||||
@ -231,6 +231,61 @@ public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testBiDirectionalIndexFollowing() throws Exception {
|
||||
logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);
|
||||
|
||||
if (clusterName == ClusterName.FOLLOWER) {
|
||||
switch (upgradeState) {
|
||||
case NONE:
|
||||
createLeaderIndex(leaderClient(), "leader_index5");
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
|
||||
followIndex(followerClient(), "leader", "leader_index5", "follower_index5");
|
||||
followIndex(leaderClient(), "follower", "follower_index5", "follower_index6");
|
||||
assertTotalHitCount("follower_index5", 128, followerClient());
|
||||
assertTotalHitCount("follower_index6", 128, leaderClient());
|
||||
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
pauseIndexFollowing(followerClient(), "follower_index5");
|
||||
pauseIndexFollowing(leaderClient(), "follower_index6");
|
||||
break;
|
||||
case ONE_THIRD:
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
break;
|
||||
case TWO_THIRD:
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
break;
|
||||
case ALL:
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("unexpected upgrade_state [" + upgradeState + "]");
|
||||
}
|
||||
} else if (clusterName == ClusterName.LEADER) {
|
||||
switch (upgradeState) {
|
||||
case NONE:
|
||||
break;
|
||||
case ONE_THIRD:
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
break;
|
||||
case TWO_THIRD:
|
||||
index(leaderClient(), "leader_index5", 128);
|
||||
break;
|
||||
case ALL:
|
||||
resumeIndexFollowing(followerClient(), "follower_index5");
|
||||
resumeIndexFollowing(leaderClient(), "follower_index6");
|
||||
|
||||
assertTotalHitCount("follower_index5", 896, followerClient());
|
||||
assertTotalHitCount("follower_index6", 896, leaderClient());
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("unexpected upgrade_state [" + upgradeState + "]");
|
||||
}
|
||||
} else {
|
||||
throw new AssertionError("unexpected cluster_name [" + clusterName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createLeaderIndex(RestClient client, String indexName) throws IOException {
|
||||
Settings.Builder indexSettings = Settings.builder()
|
||||
.put("index.number_of_shards", 1)
|
||||
@ -306,9 +361,17 @@ public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
|
||||
}
|
||||
|
||||
private static void stopIndexFollowing(RestClient client, String followerIndex) throws IOException {
|
||||
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/pause_follow")));
|
||||
pauseIndexFollowing(client, followerIndex);
|
||||
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_close")));
|
||||
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/unfollow")));
|
||||
}
|
||||
|
||||
private static void pauseIndexFollowing(RestClient client, String followerIndex) throws IOException {
|
||||
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/pause_follow")));
|
||||
}
|
||||
|
||||
private static void resumeIndexFollowing(RestClient client, String followerIndex) throws IOException {
|
||||
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/resume_follow")));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user