Skip to content

Commit dab92ed

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 77865cc commit dab92ed

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
@@ -24,7 +24,7 @@
2424

2525
public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
2626

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

3030
if (clusterName == ClusterName.LEADER) {
@@ -234,6 +234,61 @@ public void testCannotFollowLeaderInUpgradedCluster() throws Exception {
234234
}
235235
}
236236

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

314369
private static void stopIndexFollowing(RestClient client, String followerIndex) throws IOException {
315-
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/pause_follow")));
370+
pauseIndexFollowing(client, followerIndex);
316371
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_close")));
317372
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/unfollow")));
318373
}
319374

375+
private static void pauseIndexFollowing(RestClient client, String followerIndex) throws IOException {
376+
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/pause_follow")));
377+
}
378+
379+
private static void resumeIndexFollowing(RestClient client, String followerIndex) throws IOException {
380+
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/resume_follow")));
381+
}
382+
320383
}

0 commit comments

Comments
 (0)