|
24 | 24 |
|
25 | 25 | public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
|
26 | 26 |
|
27 |
| - public void testIndexFollowing() throws Exception { |
| 27 | + public void testUniDirectionalIndexFollowing() throws Exception { |
28 | 28 | logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);
|
29 | 29 |
|
30 | 30 | if (clusterName == ClusterName.LEADER) {
|
@@ -234,6 +234,61 @@ public void testCannotFollowLeaderInUpgradedCluster() throws Exception {
|
234 | 234 | }
|
235 | 235 | }
|
236 | 236 |
|
| 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 | + |
237 | 292 | private static void createLeaderIndex(RestClient client, String indexName) throws IOException {
|
238 | 293 | Settings.Builder indexSettings = Settings.builder()
|
239 | 294 | .put("index.soft_deletes.enabled", true)
|
@@ -312,9 +367,17 @@ private static void verifyTotalHitCount(final String index,
|
312 | 367 | }
|
313 | 368 |
|
314 | 369 | 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); |
316 | 371 | assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_close")));
|
317 | 372 | assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/unfollow")));
|
318 | 373 | }
|
319 | 374 |
|
| 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 | + |
320 | 383 | }
|
0 commit comments