Skip to content

Commit b31482e

Browse files
authored
Remove usage of max_local_storage_nodes in test infrastructure (#41652)
Moves the test infrastructure away from using node.max_local_storage_nodes, allowing us in a follow-up PR to deprecate this setting in 7.x and to remove it in 8.0. This also changes the behavior of InternalTestCluster so that starting up nodes will not automatically reuse data folders of previously stopped nodes. If this behavior is desired, it needs to be explicitly done by passing the data path from the stopped node to the new node that is started.
1 parent a28d405 commit b31482e

File tree

24 files changed

+270
-209
lines changed

24 files changed

+270
-209
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ class ClusterFormationTasks {
382382
// Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master
383383
'discovery.initial_state_timeout' : '0s'
384384
]
385-
esConfig['node.max_local_storage_nodes'] = node.config.numNodes
386385
esConfig['http.port'] = node.config.httpPort
387386
if (node.nodeVersion.onOrAfter('6.7.0')) {
388387
esConfig['transport.port'] = node.config.transportPort

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/IngestRestartIT.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ public void testScriptDisabled() throws Exception {
9191
checkPipelineExists.accept(pipelineIdWithoutScript);
9292

9393

94-
internalCluster().stopCurrentMasterNode();
95-
internalCluster().startNode(Settings.builder().put("script.allowed_types", "none"));
94+
internalCluster().restartNode(internalCluster().getMasterName(), new InternalTestCluster.RestartCallback() {
9695

96+
@Override
97+
public Settings onNodeStopped(String nodeName) {
98+
return Settings.builder().put("script.allowed_types", "none").build();
99+
}
100+
101+
});
102+
97103
checkPipelineExists.accept(pipelineIdWithoutScript);
98104
checkPipelineExists.accept(pipelineIdWithScript);
99105

server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ public void testUnassignedReplicaWithPriorCopy() throws Exception {
277277
nodes.remove(primaryNodeName);
278278

279279
logger.info("--> shutting down all nodes except the one that holds the primary");
280+
Settings node0DataPathSettings = internalCluster().dataPathSettings(nodes.get(0));
281+
Settings node1DataPathSettings = internalCluster().dataPathSettings(nodes.get(1));
280282
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodes.get(0)));
281283
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodes.get(1)));
282284
ensureStableCluster(1);
@@ -286,8 +288,8 @@ public void testUnassignedReplicaWithPriorCopy() throws Exception {
286288
Settings.builder().put("index.routing.allocation.include._name", primaryNodeName)).get();
287289

288290
logger.info("--> restarting the stopped nodes");
289-
internalCluster().startNode(Settings.builder().put("node.name", nodes.get(0)).build());
290-
internalCluster().startNode(Settings.builder().put("node.name", nodes.get(1)).build());
291+
internalCluster().startNode(Settings.builder().put("node.name", nodes.get(0)).put(node0DataPathSettings).build());
292+
internalCluster().startNode(Settings.builder().put("node.name", nodes.get(1)).put(node1DataPathSettings).build());
291293
ensureStableCluster(3);
292294

293295
boolean includeYesDecisions = randomBoolean();
@@ -1017,6 +1019,7 @@ public void testCannotAllocateStaleReplicaExplanation() throws Exception {
10171019
// start replica node first, so it's path will be used first when we start a node after
10181020
// stopping all of them at end of test.
10191021
final String replicaNode = internalCluster().startNode();
1022+
Settings replicaDataPathSettings = internalCluster().dataPathSettings(replicaNode);
10201023
final String primaryNode = internalCluster().startNode();
10211024

10221025
prepareIndex(IndexMetaData.State.OPEN, 1, 1,
@@ -1057,7 +1060,7 @@ public void testCannotAllocateStaleReplicaExplanation() throws Exception {
10571060
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(primaryNode));
10581061

10591062
logger.info("--> restart the node with the stale replica");
1060-
String restartedNode = internalCluster().startDataOnlyNode();
1063+
String restartedNode = internalCluster().startDataOnlyNode(replicaDataPathSettings);
10611064
ensureClusterSizeConsistency(); // wait for the master to finish processing join.
10621065

10631066
// wait until the system has fetched shard data and we know there is no valid shard copy

server/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java

-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.elasticsearch.common.collect.ImmutableOpenMap;
3737
import org.elasticsearch.common.settings.Settings;
3838
import org.elasticsearch.common.unit.TimeValue;
39-
import org.elasticsearch.env.NodeEnvironment;
4039
import org.elasticsearch.index.IndexService;
4140
import org.elasticsearch.index.shard.IndexShard;
4241
import org.elasticsearch.index.store.Store;
@@ -105,15 +104,6 @@ public void blockActions(String... actions) {
105104
}
106105
}
107106

108-
@Override
109-
protected Settings nodeSettings(int nodeOrdinal) {
110-
return Settings.builder()
111-
.put(super.nodeSettings(nodeOrdinal))
112-
// manual collection or upon cluster forming.
113-
.put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2)
114-
.build();
115-
}
116-
117107
@Override
118108
protected Collection<Class<? extends Plugin>> nodePlugins() {
119109
return Arrays.asList(TestPlugin.class, MockTransportService.TestPlugin.class);

server/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.elasticsearch.cluster.service.ClusterService;
3333
import org.elasticsearch.common.Priority;
3434
import org.elasticsearch.common.settings.Settings;
35+
import org.elasticsearch.common.util.set.Sets;
3536
import org.elasticsearch.index.query.QueryBuilders;
3637
import org.elasticsearch.plugins.Plugin;
3738
import org.elasticsearch.test.ESIntegTestCase;
@@ -43,10 +44,12 @@
4344
import org.elasticsearch.test.junit.annotations.TestLogging;
4445
import org.elasticsearch.test.transport.MockTransportService;
4546

47+
import java.util.ArrayList;
4648
import java.util.Arrays;
4749
import java.util.Collection;
4850
import java.util.Collections;
4951
import java.util.HashSet;
52+
import java.util.List;
5053
import java.util.Set;
5154
import java.util.concurrent.CountDownLatch;
5255
import java.util.concurrent.atomic.AtomicReference;
@@ -124,6 +127,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
124127
logger.info("--> add voting config exclusion for non-master node, to be sure it's not elected");
125128
client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(new String[]{otherNode})).get();
126129
logger.info("--> stop master node, no master block should appear");
130+
Settings masterDataPathSettings = internalCluster().dataPathSettings(masterNode);
127131
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(masterNode));
128132

129133
awaitBusy(() -> {
@@ -137,7 +141,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
137141
assertThat(state.nodes().getMasterNode(), equalTo(null));
138142

139143
logger.info("--> starting the previous master node again...");
140-
node2Name = internalCluster().startNode(settings);
144+
node2Name = internalCluster().startNode(Settings.builder().put(settings).put(masterDataPathSettings).build());
141145

142146
clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID)
143147
.setWaitForYellowStatus().setWaitForNodes("2").execute().actionGet();
@@ -169,6 +173,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
169173
logger.info("--> add voting config exclusion for master node, to be sure it's not elected");
170174
client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(new String[]{masterNode})).get();
171175
logger.info("--> stop non-master node, no master block should appear");
176+
Settings otherNodeDataPathSettings = internalCluster().dataPathSettings(otherNode);
172177
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(otherNode));
173178

174179
assertBusy(() -> {
@@ -177,7 +182,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
177182
});
178183

179184
logger.info("--> starting the previous master node again...");
180-
internalCluster().startNode(settings);
185+
internalCluster().startNode(Settings.builder().put(settings).put(otherNodeDataPathSettings).build());
181186

182187
ensureGreen();
183188
clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID)
@@ -251,6 +256,10 @@ public void testThreeNodesNoMasterBlock() throws Exception {
251256
assertHitCount(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(), 100);
252257
}
253258

259+
List<String> nonMasterNodes = new ArrayList<>(Sets.difference(Sets.newHashSet(internalCluster().getNodeNames()),
260+
Collections.singleton(internalCluster().getMasterName())));
261+
Settings nonMasterDataPathSettings1 = internalCluster().dataPathSettings(nonMasterNodes.get(0));
262+
Settings nonMasterDataPathSettings2 = internalCluster().dataPathSettings(nonMasterNodes.get(1));
254263
internalCluster().stopRandomNonMasterNode();
255264
internalCluster().stopRandomNonMasterNode();
256265

@@ -262,7 +271,7 @@ public void testThreeNodesNoMasterBlock() throws Exception {
262271
});
263272

264273
logger.info("--> start back the 2 nodes ");
265-
internalCluster().startNodes(2, settings);
274+
internalCluster().startNodes(nonMasterDataPathSettings1, nonMasterDataPathSettings2);
266275

267276
internalCluster().validateClusterFormed();
268277
ensureGreen();

server/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void testSimpleOnlyMasterNodeElection() throws IOException {
6565
.execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
6666

6767
logger.info("--> stop master node");
68+
Settings masterDataPathSettings = internalCluster().dataPathSettings(internalCluster().getMasterName());
6869
internalCluster().stopCurrentMasterNode();
6970

7071
try {
@@ -75,9 +76,10 @@ public void testSimpleOnlyMasterNodeElection() throws IOException {
7576
// all is well, no master elected
7677
}
7778

78-
logger.info("--> start master node");
79+
logger.info("--> start previous master node again");
7980
final String nextMasterEligibleNodeName = internalCluster()
80-
.startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
81+
.startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true)
82+
.put(masterDataPathSettings));
8183
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState()
8284
.execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName));
8385
assertThat(internalCluster().masterClient().admin().cluster().prepareState()

0 commit comments

Comments
 (0)