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