Skip to content

Commit 6e6e63d

Browse files
authored
Zen2: Move all mixed-version REST tests to Zen2 (#36398)
Moves all remaining (rolling-upgrade and mixed-version) REST tests to use Zen2. To avoid adding extra configuration, it relies on Zen2 being set as the default discovery type. This required a few smaller changes in other tests. I've removed AzureMinimumMasterNodesTests which tests Zen1 functionality and dates from a time where host providers were not configurable and each cloud plugin had its own discovery.type, subclassing the ZenDiscovery class. I've also adapted a few tests which were unnecessarily adding addTestZenDiscovery = false for the same legacy reasons. Finally, this also moves the unconfigured-node-name REST test to Zen2, testing the auto-bootstrapping functionality in development mode when no discovery configuration is provided.
1 parent 0b1e7e9 commit 6e6e63d

File tree

17 files changed

+57
-108
lines changed

17 files changed

+57
-108
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ class ClusterConfiguration {
7676
}
7777
}
7878

79+
/**
80+
* Whether the initial_master_nodes setting should be automatically derived from the nodes
81+
* in the cluster. Only takes effect if all nodes in the cluster understand this setting
82+
* and the discovery type is not explicitly set.
83+
*/
84+
@Input
85+
boolean autoSetInitialMasterNodes = true
86+
87+
/**
88+
* Whether the file-based discovery provider should be automatically setup based on
89+
* the nodes in the cluster. Only takes effect if no other hosts provider is already
90+
* configured.
91+
*/
92+
@Input
93+
boolean autoSetHostsProvider = true
94+
7995
@Input
8096
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +
8197
" " + "-Xmx" + System.getProperty('tests.heap.size', '512m') +

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,15 @@ class ClusterFormationTasks {
131131
Object dependsOn
132132
if (node.nodeVersion.onOrAfter("6.5.0")) {
133133
writeConfigSetup = { Map esConfig ->
134-
// Don't force discovery provider if one is set by the test cluster specs already
135-
if (esConfig.containsKey('discovery.zen.hosts_provider') == false) {
136-
esConfig['discovery.zen.hosts_provider'] = 'file'
134+
if (config.getAutoSetHostsProvider()) {
135+
// Don't force discovery provider if one is set by the test cluster specs already
136+
if (esConfig.containsKey('discovery.zen.hosts_provider') == false) {
137+
esConfig['discovery.zen.hosts_provider'] = 'file'
138+
}
139+
esConfig['discovery.zen.ping.unicast.hosts'] = []
137140
}
138-
esConfig['discovery.zen.ping.unicast.hosts'] = []
139-
if (hasBwcNodes == false && esConfig['discovery.type'] == null) {
140-
esConfig['discovery.type'] = 'zen2'
141+
boolean supportsInitialMasterNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0")
142+
if (esConfig['discovery.type'] == null && config.getAutoSetInitialMasterNodes() && supportsInitialMasterNodes) {
141143
esConfig['cluster.initial_master_nodes'] = nodes.stream().map({ n ->
142144
if (n.config.settings['node.name'] == null) {
143145
return "node-" + n.nodeNum

plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
8484
return Collections.singletonList(TestPlugin.class);
8585
}
8686

87-
@Override
88-
protected boolean addTestZenDiscovery() {
89-
return false;
90-
}
91-
9287
/**
9388
* Register an existing node as a Azure node, exposing its address and details htrough
9489
*

plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureMinimumMasterNodesTests.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/AbstractAwsTestCase.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,4 @@ protected Settings nodeSettings(int nodeOrdinal) {
6969
protected Collection<Class<? extends Plugin>> nodePlugins() {
7070
return Arrays.asList(Ec2DiscoveryPlugin.class);
7171
}
72-
73-
@Override
74-
protected boolean addTestZenDiscovery() {
75-
return false;
76-
}
7772
}

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* starting.
3434
* This test requires AWS to run.
3535
*/
36-
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0, autoMinMasterNodes = false)
36+
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0)
3737
public class Ec2DiscoveryUpdateSettingsTests extends AbstractAwsTestCase {
3838
public void testMinimumMasterNodesStart() {
3939
Settings nodeSettings = Settings.builder()

plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ protected Settings nodeSettings(int nodeOrdinal) {
7373
.build();
7474
}
7575

76-
@Override
77-
protected boolean addTestZenDiscovery() {
78-
return false;
79-
}
80-
8176
public void testJoin() {
8277
// start master node
8378
final String masterNode = internalCluster().startMasterOnlyNode();

qa/rolling-upgrade/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ for (Version version : bwcVersions.wireCompatible) {
7878
clusterName = 'rolling-upgrade'
7979
otherUnicastHostAddresses = { getOtherUnicastHostAddresses() }
8080
minimumMasterNodes = { 2 }
81+
autoSetInitialMasterNodes = false
8182
/* Override the data directory so the new node always gets the node we
8283
* just stopped's data directory. */
8384
dataDir = { nodeNumber -> oldClusterTest.nodes[stopNode].dataDir }
8485
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
8586
setting 'node.name', "upgraded-node-${stopNode}"
86-
// TODO: Move to Zen2 once we support rolling upgrade with Zen2
87-
setting 'discovery.type', 'zen'
8887
}
8988
}
9089

qa/unconfigured-node-name/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ apply plugin: 'elasticsearch.rest-test'
2222

2323
integTestCluster {
2424
setting 'node.name', null
25-
// TODO: Run this using zen2, with no discovery configuration at all, demonstrating that the node forms a cluster on its own without help
26-
setting 'discovery.type', 'zen'
25+
// Run with no discovery configuration at all, demonstrating that a node in its
26+
// "out-of-the-box" configuration can automatically bootstrap a cluster
27+
autoSetInitialMasterNodes = false
28+
autoSetHostsProvider = false
2729
}
2830

2931
integTestRunner {

server/src/main/java/org/elasticsearch/cluster/coordination/ClusterBootstrapService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public void start() {
103103
transportService.getThreadPool().scheduleUnlessShuttingDown(unconfiguredBootstrapTimeout, Names.SAME, new Runnable() {
104104
@Override
105105
public void run() {
106+
// TODO: remove the following line once schedule method properly preserves thread context
107+
threadContext.markAsSystemContext();
106108
final GetDiscoveredNodesRequest request = new GetDiscoveredNodesRequest();
107109
logger.trace("sending {}", request);
108110
transportService.sendRequest(transportService.getLocalNode(), GetDiscoveredNodesAction.NAME, request,
@@ -212,6 +214,8 @@ public void handleException(TransportException exp) {
212214
transportService.getThreadPool().scheduleUnlessShuttingDown(TimeValue.timeValueSeconds(10), Names.SAME, new Runnable() {
213215
@Override
214216
public void run() {
217+
// TODO: remove the following line once schedule method properly preserves thread context
218+
transportService.getThreadPool().getThreadContext().markAsSystemContext();
215219
awaitBootstrap(bootstrapConfiguration);
216220
}
217221

0 commit comments

Comments
 (0)