|
21 | 21 | import org.elasticsearch.Version;
|
22 | 22 | import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequest;
|
23 | 23 | import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
24 |
| -import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; |
25 | 24 | import org.elasticsearch.action.support.ActiveShardCount;
|
26 | 25 | import org.elasticsearch.action.support.replication.ClusterStateCreationUtils;
|
27 | 26 | import org.elasticsearch.cluster.ClusterState;
|
|
33 | 32 | import org.elasticsearch.common.settings.Settings;
|
34 | 33 | import org.elasticsearch.indices.cluster.ClusterStateChanges;
|
35 | 34 | import org.elasticsearch.test.ESTestCase;
|
36 |
| -import org.elasticsearch.test.VersionUtils; |
37 | 35 | import org.elasticsearch.threadpool.TestThreadPool;
|
38 | 36 | import org.elasticsearch.threadpool.ThreadPool;
|
39 | 37 |
|
|
48 | 46 |
|
49 | 47 | import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS;
|
50 | 48 | import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
51 |
| -import static org.hamcrest.Matchers.equalTo; |
52 | 49 | import static org.hamcrest.Matchers.everyItem;
|
53 | 50 | import static org.hamcrest.Matchers.isIn;
|
54 | 51 |
|
@@ -107,15 +104,12 @@ public void testInvalidValues() {
|
107 | 104 |
|
108 | 105 | private static final AtomicInteger nodeIdGenerator = new AtomicInteger();
|
109 | 106 |
|
110 |
| - protected DiscoveryNode createNode(Version version, DiscoveryNodeRole... mustHaveRoles) { |
| 107 | + protected DiscoveryNode createNode(DiscoveryNodeRole... mustHaveRoles) { |
111 | 108 | Set<DiscoveryNodeRole> roles = new HashSet<>(randomSubsetOf(DiscoveryNodeRole.BUILT_IN_ROLES));
|
112 | 109 | Collections.addAll(roles, mustHaveRoles);
|
113 | 110 | final String id = String.format(Locale.ROOT, "node_%03d", nodeIdGenerator.incrementAndGet());
|
114 |
| - return new DiscoveryNode(id, id, buildNewFakeTransportAddress(), Collections.emptyMap(), roles, version); |
115 |
| - } |
116 |
| - |
117 |
| - protected DiscoveryNode createNode(DiscoveryNodeRole... mustHaveRoles) { |
118 |
| - return createNode(Version.CURRENT, mustHaveRoles); |
| 111 | + return new DiscoveryNode(id, id, buildNewFakeTransportAddress(), Collections.emptyMap(), roles, |
| 112 | + Version.CURRENT); |
119 | 113 | }
|
120 | 114 |
|
121 | 115 | /**
|
@@ -206,56 +200,4 @@ public void testAutoExpandWhenNodeLeavesAndPossiblyRejoins() throws InterruptedE
|
206 | 200 | terminate(threadPool);
|
207 | 201 | }
|
208 | 202 | }
|
209 |
| - |
210 |
| - public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { |
211 |
| - final ThreadPool threadPool = new TestThreadPool(getClass().getName()); |
212 |
| - final ClusterStateChanges cluster = new ClusterStateChanges(xContentRegistry(), threadPool); |
213 |
| - |
214 |
| - try { |
215 |
| - List<DiscoveryNode> allNodes = new ArrayList<>(); |
216 |
| - DiscoveryNode oldNode = createNode(VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_1), |
217 |
| - DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local node is the master |
218 |
| - allNodes.add(oldNode); |
219 |
| - ClusterState state = ClusterStateCreationUtils.state(oldNode, oldNode, allNodes.toArray(new DiscoveryNode[0])); |
220 |
| - |
221 |
| - CreateIndexRequest request = new CreateIndexRequest("index", |
222 |
| - Settings.builder() |
223 |
| - .put(SETTING_NUMBER_OF_SHARDS, 1) |
224 |
| - .put(SETTING_AUTO_EXPAND_REPLICAS, "0-all").build()) |
225 |
| - .waitForActiveShards(ActiveShardCount.NONE); |
226 |
| - state = cluster.createIndex(state, request); |
227 |
| - assertTrue(state.metaData().hasIndex("index")); |
228 |
| - while (state.routingTable().index("index").shard(0).allShardsStarted() == false) { |
229 |
| - logger.info(state); |
230 |
| - state = cluster.applyStartedShards(state, |
231 |
| - state.routingTable().index("index").shard(0).shardsWithState(ShardRoutingState.INITIALIZING)); |
232 |
| - state = cluster.reroute(state, new ClusterRerouteRequest()); |
233 |
| - } |
234 |
| - |
235 |
| - DiscoveryNode newNode = createNode(Version.V_7_6_0, |
236 |
| - DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local node is the master |
237 |
| - |
238 |
| - state = cluster.addNodes(state, Collections.singletonList(newNode)); |
239 |
| - |
240 |
| - // use allocation filtering |
241 |
| - state = cluster.updateSettings(state, new UpdateSettingsRequest("index").settings(Settings.builder() |
242 |
| - .put(IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._name", oldNode.getName()).build())); |
243 |
| - |
244 |
| - while (state.routingTable().index("index").shard(0).allShardsStarted() == false) { |
245 |
| - logger.info(state); |
246 |
| - state = cluster.applyStartedShards(state, |
247 |
| - state.routingTable().index("index").shard(0).shardsWithState(ShardRoutingState.INITIALIZING)); |
248 |
| - state = cluster.reroute(state, new ClusterRerouteRequest()); |
249 |
| - } |
250 |
| - |
251 |
| - // check that presence of old node means that auto-expansion does not take allocation filtering into account |
252 |
| - assertThat(state.routingTable().index("index").shard(0).size(), equalTo(2)); |
253 |
| - |
254 |
| - // remove old node and check that auto-expansion takes allocation filtering into account |
255 |
| - state = cluster.removeNodes(state, Collections.singletonList(oldNode)); |
256 |
| - assertThat(state.routingTable().index("index").shard(0).size(), equalTo(1)); |
257 |
| - } finally { |
258 |
| - terminate(threadPool); |
259 |
| - } |
260 |
| - } |
261 | 203 | }
|
0 commit comments