Skip to content

Commit a1fcc62

Browse files
authored
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
1 parent cbdda71 commit a1fcc62

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

x-pack/qa/rolling-upgrade-multi-cluster/src/test/java/org/elasticsearch/upgrades/CcrRollingUpgradeIT.java

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
2424

25-
public void testIndexFollowing() throws Exception {
25+
public void testUniDirectionalIndexFollowing() throws Exception {
2626
logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);
2727

2828
if (clusterName == ClusterName.LEADER) {
@@ -230,6 +230,61 @@ public void testCannotFollowLeaderInUpgradedCluster() throws Exception {
230230
}
231231
}
232232

233+
public void testBiDirectionalIndexFollowing() throws Exception {
234+
logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);
235+
236+
if (clusterName == ClusterName.FOLLOWER) {
237+
switch (upgradeState) {
238+
case NONE:
239+
createLeaderIndex(leaderClient(), "leader_index5");
240+
index(leaderClient(), "leader_index5", 128);
241+
242+
followIndex(followerClient(), "leader", "leader_index5", "follower_index5");
243+
followIndex(leaderClient(), "follower", "follower_index5", "follower_index6");
244+
assertTotalHitCount("follower_index5", 128, followerClient());
245+
assertTotalHitCount("follower_index6", 128, leaderClient());
246+
247+
index(leaderClient(), "leader_index5", 128);
248+
pauseIndexFollowing(followerClient(), "follower_index5");
249+
pauseIndexFollowing(leaderClient(), "follower_index6");
250+
break;
251+
case ONE_THIRD:
252+
index(leaderClient(), "leader_index5", 128);
253+
break;
254+
case TWO_THIRD:
255+
index(leaderClient(), "leader_index5", 128);
256+
break;
257+
case ALL:
258+
index(leaderClient(), "leader_index5", 128);
259+
break;
260+
default:
261+
throw new AssertionError("unexpected upgrade_state [" + upgradeState + "]");
262+
}
263+
} else if (clusterName == ClusterName.LEADER) {
264+
switch (upgradeState) {
265+
case NONE:
266+
break;
267+
case ONE_THIRD:
268+
index(leaderClient(), "leader_index5", 128);
269+
break;
270+
case TWO_THIRD:
271+
index(leaderClient(), "leader_index5", 128);
272+
break;
273+
case ALL:
274+
resumeIndexFollowing(followerClient(), "follower_index5");
275+
resumeIndexFollowing(leaderClient(), "follower_index6");
276+
277+
assertTotalHitCount("follower_index5", 896, followerClient());
278+
assertTotalHitCount("follower_index6", 896, leaderClient());
279+
break;
280+
default:
281+
throw new AssertionError("unexpected upgrade_state [" + upgradeState + "]");
282+
}
283+
} else {
284+
throw new AssertionError("unexpected cluster_name [" + clusterName + "]");
285+
}
286+
}
287+
233288
private static void createLeaderIndex(RestClient client, String indexName) throws IOException {
234289
Settings.Builder indexSettings = Settings.builder()
235290
.put("index.number_of_shards", 1)
@@ -305,9 +360,17 @@ private static void verifyTotalHitCount(final String index,
305360
}
306361

307362
private static void stopIndexFollowing(RestClient client, String followerIndex) throws IOException {
308-
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/pause_follow")));
363+
pauseIndexFollowing(client, followerIndex);
309364
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_close")));
310365
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/unfollow")));
311366
}
312367

368+
private static void pauseIndexFollowing(RestClient client, String followerIndex) throws IOException {
369+
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/pause_follow")));
370+
}
371+
372+
private static void resumeIndexFollowing(RestClient client, String followerIndex) throws IOException {
373+
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/resume_follow")));
374+
}
375+
313376
}

0 commit comments

Comments
 (0)