diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java index a2803654228..9cc03dd7e37 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java @@ -217,11 +217,19 @@ public class ElasticsearchCluster implements TestClusterConfiguration { @Override public void start() { - String nodeNames = nodes.stream().map(ElasticsearchNode::getName).collect(Collectors.joining(",")); + final String nodeNames; + if (nodes.stream().map(ElasticsearchNode::getName).anyMatch( name -> name == null)) { + nodeNames = null; + } else { + nodeNames = nodes.stream().map(ElasticsearchNode::getName).collect(Collectors.joining(",")); + }; for (ElasticsearchNode node : nodes) { - if (Version.fromString(node.getVersion()).getMajor() >= 7) { - node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); - node.defaultConfig.put("discovery.seed_providers", "file"); + if (nodeNames != null) { + // Can only configure master nodes if we have node names defined + if (Version.fromString(node.getVersion()).getMajor() >= 7) { + node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + node.defaultConfig.put("discovery.seed_providers", "file"); + } } node.start(); } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java index f838d3fd2ac..1641ef3dac4 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java @@ -732,7 +732,10 @@ public class ElasticsearchNode implements TestClusterConfiguration { } private void createConfiguration() { - defaultConfig.put("node.name", nameCustomization.apply(safeName(name))); + String nodeName = nameCustomization.apply(safeName(name)); + if (nodeName != null) { + defaultConfig.put("node.name", nodeName); + } defaultConfig.put("path.repo", confPathRepo.toAbsolutePath().toString()); defaultConfig.put("path.data", confPathData.toAbsolutePath().toString()); defaultConfig.put("path.logs", confPathLogs.toAbsolutePath().toString()); diff --git a/qa/build.gradle b/qa/build.gradle index f1727f11515..9266a09b257 100644 --- a/qa/build.gradle +++ b/qa/build.gradle @@ -1,25 +1,20 @@ import org.elasticsearch.gradle.test.RestIntegTestTask +import org.elasticsearch.gradle.testclusters.TestClustersPlugin subprojects { Project subproj -> subproj.tasks.withType(RestIntegTestTask) { - subproj.extensions.configure("${it.name}Cluster") { cluster -> - cluster.distribution = System.getProperty('tests.distribution', 'oss') - if (cluster.distribution == 'default') { - /* - * Add Elastic's repositories so we can resolve older versions of the - * default distribution. Those aren't in maven central. - */ - repositories { - maven { - name "elastic" - url "https://artifacts.elastic.co/maven" - } - maven { - name "elastic-snapshots" - url "https://snapshots.elastic.co/maven" - } - } + if (subproj.extensions.findByName("${it.name}Cluster")) { + subproj.extensions.configure("${it.name}Cluster") { cluster -> + cluster.distribution = System.getProperty('tests.distribution', 'oss') + } + } + } + plugins.withType(TestClustersPlugin).whenPluginAdded { + afterEvaluate { + // We need to delay this so it's not overwritten in RestIntegTestTask + testClusters.all { + distribution = System.getProperty('tests.distribution', 'oss').toUpperCase() } } } diff --git a/qa/logging-config/build.gradle b/qa/logging-config/build.gradle index 544614ef269..438079b9942 100644 --- a/qa/logging-config/build.gradle +++ b/qa/logging-config/build.gradle @@ -17,22 +17,22 @@ * under the License. */ - +apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.standalone-test' -integTestCluster { +testClusters.integTest { /** * Provide a custom log4j configuration where layout is an old style pattern and confirm that Elasticsearch * can successfully startup. */ - extraConfigFile 'log4j2.properties', 'custom-log4j2.properties' + extraConfigFile 'log4j2.properties', file('custom-log4j2.properties') } -integTestRunner { +integTest.runner { nonInputProperties.systemProperty 'tests.logfile', - "${ -> integTest.nodes[0].homeDir}/logs/${ -> integTest.nodes[0].clusterName }_server.log" + "${ -> testClusters.integTest.singleNode().getServerLog().absolutePath.replaceAll(".json", ".log")}" } test { diff --git a/qa/logging-config/src/test/java/org/elasticsearch/qa/custom_logging/CustomLoggingConfigIT.java b/qa/logging-config/src/test/java/org/elasticsearch/qa/custom_logging/CustomLoggingConfigIT.java index 2e6b32d79fc..6ab9a00c1e9 100644 --- a/qa/logging-config/src/test/java/org/elasticsearch/qa/custom_logging/CustomLoggingConfigIT.java +++ b/qa/logging-config/src/test/java/org/elasticsearch/qa/custom_logging/CustomLoggingConfigIT.java @@ -40,7 +40,7 @@ import java.util.List; * The intention is to confirm that users can still run their Elasticsearch instances with previous configurations. */ public class CustomLoggingConfigIT extends ESRestTestCase { - private static final String NODE_STARTED = ".*node-0.*cluster.uuid.*node.id.*recovered.*cluster_state.*"; + private static final String NODE_STARTED = ".*integTest-0.*cluster.uuid.*node.id.*recovered.*cluster_state.*"; public void testSuccessfulStartupWithCustomConfig() throws Exception { assertBusy(() -> { diff --git a/qa/smoke-test-ingest-disabled/build.gradle b/qa/smoke-test-ingest-disabled/build.gradle index cf3ca9a713f..a0abc8b129d 100644 --- a/qa/smoke-test-ingest-disabled/build.gradle +++ b/qa/smoke-test-ingest-disabled/build.gradle @@ -17,6 +17,7 @@ * under the License. */ +apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' @@ -24,6 +25,6 @@ dependencies { testCompile project(path: ':modules:ingest-common', configuration: 'runtime') } -integTestCluster { +testClusters.integTest { setting 'node.ingest', 'false' } diff --git a/qa/smoke-test-multinode/build.gradle b/qa/smoke-test-multinode/build.gradle index cd64262fcdc..25964a871e0 100644 --- a/qa/smoke-test-multinode/build.gradle +++ b/qa/smoke-test-multinode/build.gradle @@ -17,6 +17,7 @@ * under the License. */ +apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' @@ -24,12 +25,18 @@ integTest { includePackaged = true } -integTestCluster { - numNodes = 2 +File repo = file("$buildDir/testclusters/repo") +testClusters.integTest { + numberOfNodes = 2 + setting 'path.repo', repo.absolutePath } -integTestRunner { - if ('default'.equals(integTestCluster.distribution)) { +integTest.runner { + doFirst { + project.delete(repo) + repo.mkdirs() + } + if ('default'.equalsIgnoreCase(System.getProperty('tests.distribution', 'oss'))) { systemProperty 'tests.rest.blacklist', [ 'cat.templates/10_basic/No templates', 'cat.templates/10_basic/Sort templates', diff --git a/qa/smoke-test-plugins/build.gradle b/qa/smoke-test-plugins/build.gradle index 602dfa2d6ea..bdd5e74184e 100644 --- a/qa/smoke-test-plugins/build.gradle +++ b/qa/smoke-test-plugins/build.gradle @@ -19,15 +19,18 @@ import org.elasticsearch.gradle.MavenFilteringHack +apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' -ext.pluginsCount = 0 -project(':plugins').getChildProjects().each { pluginName, pluginProject -> - integTestCluster { - plugin pluginProject.path +int pluginsCount = 0 + +testClusters.integTest { + project(':plugins').getChildProjects().each { pluginName, pluginProject -> + plugin file(pluginProject.tasks.bundlePlugin.archiveFile) + tasks.integTest.dependsOn pluginProject.tasks.bundlePlugin + pluginsCount += 1 } - pluginsCount += 1 } assert pluginsCount > 0 diff --git a/qa/unconfigured-node-name/build.gradle b/qa/unconfigured-node-name/build.gradle index 3b0faa10a7e..56805f37bea 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/build.gradle @@ -17,18 +17,15 @@ * under the License. */ +apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' -integTestCluster { - setting 'node.name', null - // Run with no discovery configuration at all, demonstrating that a node in its - // "out-of-the-box" configuration can automatically bootstrap a cluster - autoSetInitialMasterNodes = false - autoSetHostsProvider = false +testClusters.integTest { + nameCustomization = { null } } -integTestRunner { +integTest.runner { nonInputProperties.systemProperty 'tests.logfile', - "${ -> integTest.nodes[0].homeDir}/logs/${ -> integTest.nodes[0].clusterName }_server.json" + "${ -> testClusters.integTest.singleNode().getServerLog() }" } diff --git a/qa/wildfly/build.gradle b/qa/wildfly/build.gradle index 149ab1a3a5c..2fb586ed369 100644 --- a/qa/wildfly/build.gradle +++ b/qa/wildfly/build.gradle @@ -26,6 +26,7 @@ import java.util.stream.Stream */ apply plugin: 'war' +apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.rest-test' @@ -88,13 +89,14 @@ task deploy(type: Copy) { task writeElasticsearchProperties { onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) } - dependsOn 'integTestCluster#wait', deploy + useCluster testClusters.integTest + dependsOn deploy doLast { final File elasticsearchProperties = file("${wildflyInstall}/standalone/configuration/elasticsearch.properties") elasticsearchProperties.write( [ - "transport.uri=${-> integTest.getNodes().get(0).transportUri()}", - "cluster.name=${-> integTest.getNodes().get(0).clusterName}" + "transport.uri=${-> testClusters.integTest.getAllTransportPortURI().get(0)}", + "cluster.name=integTest" ].join("\n")) } }