|
84 | 84 | import java.util.concurrent.atomic.AtomicBoolean;
|
85 | 85 | import java.util.function.Consumer;
|
86 | 86 | import java.util.function.Function;
|
| 87 | +import java.util.function.Predicate; |
87 | 88 | import java.util.stream.IntStream;
|
88 | 89 |
|
89 | 90 | import static java.util.Collections.singletonList;
|
@@ -557,11 +558,14 @@ public void testNoActiveCopy() throws Exception {
|
557 | 558 | }
|
558 | 559 | }
|
559 | 560 |
|
560 |
| - private void moveOrCloseShardsOnNodes(String nodeName) throws Exception { |
| 561 | + private void moveOrCloseShardsOnNodes(String nodeName, Predicate<String> indexName) throws Exception { |
561 | 562 | final IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodeName);
|
562 | 563 | final ClusterState clusterState = clusterService().state();
|
563 | 564 | for (IndexService indexService : indicesService) {
|
564 | 565 | for (IndexShard indexShard : indexService) {
|
| 566 | + if (indexName.test(indexShard.shardId().getIndexName()) == false) { |
| 567 | + continue; |
| 568 | + } |
565 | 569 | if (randomBoolean()) {
|
566 | 570 | closeShardNoCheck(indexShard, randomBoolean());
|
567 | 571 | } else if (randomBoolean()) {
|
@@ -603,13 +607,21 @@ private void moveOrCloseShardsOnNodes(String nodeName) throws Exception {
|
603 | 607 |
|
604 | 608 | public void testRelocation() throws Exception {
|
605 | 609 | populateTimeRangeIndices();
|
| 610 | + assertAcked( |
| 611 | + client().admin() |
| 612 | + .indices() |
| 613 | + .prepareUpdateSettings("log-index-*") |
| 614 | + .setSettings(Settings.builder().put("index.routing.rebalance.enable", "none").build()) |
| 615 | + .get() |
| 616 | + ); |
| 617 | + ensureGreen("log-index-*"); |
606 | 618 | try {
|
607 | 619 | final AtomicBoolean relocated = new AtomicBoolean();
|
608 | 620 | for (String node : internalCluster().getNodeNames()) {
|
609 | 621 | MockTransportService.getInstance(node)
|
610 | 622 | .addRequestHandlingBehavior(TransportFieldCapabilitiesAction.ACTION_NODE_NAME, (handler, request, channel, task) -> {
|
611 | 623 | if (relocated.compareAndSet(false, true)) {
|
612 |
| - moveOrCloseShardsOnNodes(node); |
| 624 | + moveOrCloseShardsOnNodes(node, indexName -> indexName.startsWith("log-index-")); |
613 | 625 | }
|
614 | 626 | handler.messageReceived(request, channel, task);
|
615 | 627 | });
|
|
0 commit comments