Skip to content

Commit 826dd7b

Browse files
committed
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 351a64d commit 826dd7b

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
@@ -23,7 +23,7 @@
2323

2424
public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
2525

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

2929
if (clusterName == ClusterName.LEADER) {
@@ -231,6 +231,61 @@ public void testCannotFollowLeaderInUpgradedCluster() throws Exception {
231231
}
232232
}
233233

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

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

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

0 commit comments

Comments
 (0)