|
30 | 30 | import java.util.HashMap;
|
31 | 31 | import java.util.Map;
|
32 | 32 |
|
| 33 | +import static java.util.Collections.emptyMap; |
33 | 34 | import static java.util.Collections.singletonMap;
|
34 | 35 | import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
35 | 36 | import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
|
@@ -904,4 +905,35 @@ public void testDisabledByAutoExpandReplicas() {
|
904 | 905 |
|
905 | 906 | assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED), empty());
|
906 | 907 | }
|
| 908 | + |
| 909 | + public void testNodesWithoutAttributeAreIgnored() { |
| 910 | + final Settings settings = Settings.builder() |
| 911 | + .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.getKey(), "zone") |
| 912 | + .build(); |
| 913 | + |
| 914 | + final AllocationService strategy = createAllocationService(settings); |
| 915 | + |
| 916 | + final Metadata metadata = Metadata.builder() |
| 917 | + .put(IndexMetadata.builder("test").settings(settings(Version.CURRENT) |
| 918 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 919 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2))) |
| 920 | + .build(); |
| 921 | + |
| 922 | + final ClusterState clusterState = applyStartedShardsUntilNoChange( |
| 923 | + ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(Settings.EMPTY)) |
| 924 | + .metadata(metadata) |
| 925 | + .routingTable(RoutingTable.builder() |
| 926 | + .addAsNew(metadata.index("test")) |
| 927 | + .build()) |
| 928 | + .nodes(DiscoveryNodes.builder() |
| 929 | + .add(newNode("A-0", singletonMap("zone", "a"))) |
| 930 | + .add(newNode("A-1", singletonMap("zone", "a"))) |
| 931 | + .add(newNode("B-0", singletonMap("zone", "b"))) |
| 932 | + .add(newNode("B-1", singletonMap("zone", "b"))) |
| 933 | + .add(newNode("X-0", emptyMap())) |
| 934 | + ).build(), strategy); |
| 935 | + |
| 936 | + assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED), empty()); |
| 937 | + } |
| 938 | + |
907 | 939 | }
|
0 commit comments