|
23 | 23 |
|
24 | 24 | public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
|
25 | 25 |
|
26 |
| - public void testIndexFollowing() throws Exception { |
| 26 | + public void testUniDirectionalIndexFollowing() throws Exception { |
27 | 27 | logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);
|
28 | 28 |
|
29 | 29 | if (clusterName == ClusterName.LEADER) {
|
@@ -231,6 +231,61 @@ public void testCannotFollowLeaderInUpgradedCluster() throws Exception {
|
231 | 231 | }
|
232 | 232 | }
|
233 | 233 |
|
| 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 | + |
234 | 289 | private static void createLeaderIndex(RestClient client, String indexName) throws IOException {
|
235 | 290 | Settings.Builder indexSettings = Settings.builder()
|
236 | 291 | .put("index.number_of_shards", 1)
|
@@ -306,9 +361,17 @@ private static void verifyTotalHitCount(final String index,
|
306 | 361 | }
|
307 | 362 |
|
308 | 363 | 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); |
310 | 365 | assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_close")));
|
311 | 366 | assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/unfollow")));
|
312 | 367 | }
|
313 | 368 |
|
| 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 | + |
314 | 377 | }
|
0 commit comments