Răsfoiți Sursa

[ZEN2] Use Zen2 in REST Tests (#36300)

Armin Braun 6 ani în urmă
părinte
comite
e6d190613f

+ 13 - 1
buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

@@ -18,6 +18,7 @@
  */
 package org.elasticsearch.gradle.test
 
+import java.util.stream.Collectors
 import org.apache.tools.ant.DefaultLogger
 import org.apache.tools.ant.taskdefs.condition.Os
 import org.elasticsearch.gradle.BuildPlugin
@@ -92,7 +93,8 @@ class ClusterFormationTasks {
             throw new Exception("tests.distribution=integ-test-zip is not supported")
         }
         configureDistributionDependency(project, config.distribution, currentDistro, VersionProperties.elasticsearch)
-        if (config.numBwcNodes > 0) {
+        boolean hasBwcNodes = config.numBwcNodes > 0
+        if (hasBwcNodes) {
             if (config.bwcVersion == null) {
                 throw new IllegalArgumentException("Must specify bwcVersion when numBwcNodes > 0")
             }
@@ -134,6 +136,16 @@ class ClusterFormationTasks {
                         esConfig['discovery.zen.hosts_provider'] = 'file'
                     }
                     esConfig['discovery.zen.ping.unicast.hosts'] = []
+                    if (hasBwcNodes == false && esConfig['discovery.type'] == null) {
+                        esConfig['discovery.type'] = 'zen2'
+                        esConfig['cluster.initial_master_nodes'] = nodes.stream().map({ n ->
+                            if (n.config.settings['node.name'] == null) {
+                                return "node-" + n.nodeNum
+                            } else {
+                                return n.config.settings['node.name']
+                            }
+                        }).collect(Collectors.toList())
+                    }
                     esConfig
                 }
                 dependsOn = startDependencies

+ 1 - 1
docs/reference/modules/node.asciidoc

@@ -165,7 +165,7 @@ PUT _cluster/settings
 }
 ----------------------------
 // CONSOLE
-// TEST[catch:/cannot set discovery.zen.minimum_master_nodes to more than the current master nodes/]
+// TEST[skip:Test use Zen2 now so we can't test Zen1 behaviour here]
 
 TIP: An advantage of splitting the master and data roles between dedicated
 nodes is that you can have just three master-eligible nodes and set

+ 2 - 0
qa/rolling-upgrade/build.gradle

@@ -83,6 +83,8 @@ for (Version version : bwcVersions.wireCompatible) {
       dataDir = { nodeNumber -> oldClusterTest.nodes[stopNode].dataDir }
       setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
       setting 'node.name', "upgraded-node-${stopNode}"
+      // TODO: Move to Zen2 once we support rolling upgrade with Zen2
+      setting 'discovery.type', 'zen'
     }
   }
 

+ 2 - 0
qa/unconfigured-node-name/build.gradle

@@ -22,6 +22,8 @@ apply plugin: 'elasticsearch.rest-test'
 
 integTestCluster {
   setting 'node.name', null
+  // TODO: Run this using zen2
+  setting 'discovery.type', 'zen'
 }
 
 integTestRunner {

+ 4 - 2
server/src/main/java/org/elasticsearch/cluster/coordination/ClusterBootstrapService.java

@@ -72,7 +72,7 @@ public class ClusterBootstrapService {
         assert running == false;
         running = true;
 
-        if (initialMasterNodeCount > 0 && transportService.getLocalNode().isMasterNode()) {
+        if ((initialMasterNodeCount > 0 || initialMasterNodes.isEmpty() == false) && transportService.getLocalNode().isMasterNode()) {
             logger.debug("unsafely waiting for discovery of [{}] master-eligible nodes", initialMasterNodeCount);
 
             final ThreadContext threadContext = transportService.getThreadPool().getThreadContext();
@@ -80,7 +80,9 @@ public class ClusterBootstrapService {
                 threadContext.markAsSystemContext();
 
                 final GetDiscoveredNodesRequest request = new GetDiscoveredNodesRequest();
-                request.setWaitForNodes(initialMasterNodeCount);
+                if (initialMasterNodeCount > 0) {
+                    request.setWaitForNodes(initialMasterNodeCount);
+                }
                 request.setRequiredNodes(initialMasterNodes);
                 request.setTimeout(null);
                 logger.trace("sending {}", request);

+ 1 - 1
server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java

@@ -652,7 +652,7 @@ public class Coordinator extends AbstractLifecycleComponent implements Discovery
                 .lastCommittedConfiguration(votingConfiguration)
                 .build();
 
-            MetaData.Builder metaDataBuilder = MetaData.builder();
+            MetaData.Builder metaDataBuilder = MetaData.builder(currentState.metaData());
             // automatically generate a UID for the metadata if we need to
             metaDataBuilder.generateClusterUuidIfNeeded(); // TODO generate UUID in bootstrapping tool?
             metaDataBuilder.coordinationMetaData(coordinationMetaData);

+ 9 - 2
server/src/test/java/org/elasticsearch/cluster/coordination/ClusterBootstrapServiceTests.java

@@ -48,6 +48,7 @@ import java.util.stream.Stream;
 import static java.util.Collections.emptyMap;
 import static java.util.Collections.emptySet;
 import static java.util.Collections.singleton;
+import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING;
 import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODE_COUNT_SETTING;
 import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
 
@@ -76,8 +77,14 @@ public class ClusterBootstrapServiceTests extends ESTestCase {
         transportService = transport.createTransportService(Settings.EMPTY, deterministicTaskQueue.getThreadPool(),
             TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundTransportAddress -> localNode, null, emptySet());
 
-        clusterBootstrapService = new ClusterBootstrapService(Settings.builder().put(INITIAL_MASTER_NODE_COUNT_SETTING.getKey(), 3).build(),
-            transportService);
+        final Settings settings;
+        if (randomBoolean()) {
+            settings = Settings.builder().put(INITIAL_MASTER_NODE_COUNT_SETTING.getKey(), 3).build();
+        } else {
+            settings = Settings.builder()
+                .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()).build();
+        }
+        clusterBootstrapService = new ClusterBootstrapService(settings, transportService);
     }
 
     private DiscoveryNode newDiscoveryNode(String nodeName) {

+ 2 - 0
x-pack/qa/rolling-upgrade-basic/build.gradle

@@ -66,6 +66,8 @@ for (Version version : bwcVersions.wireCompatible) {
             setting 'xpack.watcher.enabled', 'false'
             setting 'xpack.license.self_generated.type', 'basic'
             setting 'node.name', "upgraded-node-${stopNode}"
+            // TODO: Move to Zen2 once we support rolling upgrade with Zen2
+            setting 'discovery.type', 'zen'
         }
     }
 

+ 2 - 0
x-pack/qa/rolling-upgrade/build.gradle

@@ -215,6 +215,8 @@ subprojects {
         if (version.before('6.0.0')) {
           keystoreSetting 'xpack.security.authc.token.passphrase', 'token passphrase'
         }
+        // TODO: Move to Zen2 once we support rolling upgrade with Zen2
+        setting 'discovery.type', 'zen'
       }
     }