diff --git a/BUILDING.md b/BUILDING.md index 0d2534c0bf07..c41c31f72cb5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -78,6 +78,23 @@ The major difference between these two syntaxes is, that the configuration block By actually doing less in the gradle configuration time as only creating tasks that are requested as part of the build and by only running the configurations for those requested tasks, using the task avoidance api contributes a major part in keeping our build fast. +#### Registering test clusters + +When using the elasticsearch test cluster plugin we want to use (similar to the task avoidance API) a Gradle API to create domain objects lazy or only if required by the build. +Therefore we register test cluster by using the following syntax: + + def someClusterProvider = testClusters.register('someCluster') { ... } + +This registers a potential testCluster named `somecluster` and provides a provider instance, but doesn't create it yet nor configures it. This makes the gradle configuration phase more efficient by +doing less. + +To wire this registered cluster into a `TestClusterAware` task (e.g. `RestIntegTest`) you can resolve the actual cluster from the provider instance: + + tasks.register('someClusterTest', RestIntegTestTask) { + useCluster someClusterProvider + nonInputProperties.systemProperty 'tests.leader_host', "${-> someClusterProvider.get().getAllHttpSocketURI().get(0)}" + } + #### Adding additional integration tests Additional integration tests for a certain elasticsearch modules that are specific to certain cluster configuration can be declared in a separate so called `qa` subproject of your module. diff --git a/build-tools-internal/src/main/groovy/elasticsearch.run.gradle b/build-tools-internal/src/main/groovy/elasticsearch.run.gradle index ceb01909ebd3..1d9b437789cb 100644 --- a/build-tools-internal/src/main/groovy/elasticsearch.run.gradle +++ b/build-tools-internal/src/main/groovy/elasticsearch.run.gradle @@ -13,8 +13,7 @@ import org.elasticsearch.gradle.testclusters.RunTask // precompiled script plugins (see https://github.com/gradle/gradle/issues/17004) // apply plugin: 'elasticsearch.internal-testclusters' -testClusters { - runTask { +testClusters.register("runTask") { testDistribution = providers.systemProperty('run.distribution').orElse('default').forUseAtConfigurationTime().get() if (providers.systemProperty('run.distribution').orElse('default').forUseAtConfigurationTime().get() == 'default') { String licenseType = providers.systemProperty("run.license_type").orElse("basic").forUseAtConfigurationTime().get() @@ -30,11 +29,10 @@ testClusters { keystore 'bootstrap.password', 'password' user username: 'elastic-admin', password: 'elastic-password', role: 'superuser' } - } } tasks.register("run", RunTask) { - useCluster testClusters.runTask; + useCluster testClusters.named("runTask") description = 'Runs elasticsearch in the foreground' group = 'Verification' diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/plugin/PluginBuildPlugin.java b/build-tools/src/main/java/org/elasticsearch/gradle/plugin/PluginBuildPlugin.java index 3bd9860f2d0f..f872f7c58d9b 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/plugin/PluginBuildPlugin.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/plugin/PluginBuildPlugin.java @@ -77,7 +77,7 @@ public class PluginBuildPlugin implements Plugin { // Auto add dependent modules to the test cluster if (project1.findProject(":modules:" + pluginName) != null) { NamedDomainObjectContainer testClusters = testClusters(project, "testClusters"); - testClusters.all(elasticsearchCluster -> elasticsearchCluster.module(":modules:" + pluginName)); + testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.module(":modules:" + pluginName)); } }); final var extension1 = project1.getExtensions().getByType(PluginPropertiesExtension.class); @@ -120,17 +120,17 @@ public class PluginBuildPlugin implements Plugin { // allow running ES with this plugin in the foreground of a build var testClusters = testClusters(project, TestClustersPlugin.EXTENSION_NAME); - final var runCluster = testClusters.create("runTask", cluster -> { + var runCluster = testClusters.register("runtTask", c -> { if (GradleUtils.isModuleProject(project.getPath())) { - cluster.module(bundleTask.flatMap((Transformer, Zip>) zip -> zip.getArchiveFile())); + c.module(bundleTask.flatMap((Transformer, Zip>) zip -> zip.getArchiveFile())); } else { - cluster.plugin(bundleTask.flatMap((Transformer, Zip>) zip -> zip.getArchiveFile())); + c.plugin(bundleTask.flatMap((Transformer, Zip>) zip -> zip.getArchiveFile())); } }); - project.getTasks().register("run", RunTask.class, runTask -> { - runTask.useCluster(runCluster); - runTask.dependsOn(project.getTasks().named(BUNDLE_PLUGIN_TASK_NAME)); + project.getTasks().register("run", RunTask.class, r -> { + r.useCluster(runCluster.get()); + r.dependsOn(project.getTasks().named(BUNDLE_PLUGIN_TASK_NAME)); }); } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/test/JavaRestTestPlugin.java b/build-tools/src/main/java/org/elasticsearch/gradle/test/JavaRestTestPlugin.java index 67628cd1b892..505c3b6ce04f 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/test/JavaRestTestPlugin.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/test/JavaRestTestPlugin.java @@ -48,15 +48,16 @@ public class JavaRestTestPlugin implements Plugin { NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project .getExtensions() .getByName(TestClustersPlugin.EXTENSION_NAME); - var cluster = testClusters.maybeCreate(JAVA_REST_TEST); + var clusterProvider = testClusters.register(JAVA_REST_TEST); // Register test task TaskProvider javaRestTestTask = project.getTasks() .register(JAVA_REST_TEST, StandaloneRestIntegTestTask.class, task -> { - task.useCluster(cluster); + task.useCluster(clusterProvider); task.setTestClassesDirs(testSourceSet.getOutput().getClassesDirs()); task.setClasspath(testSourceSet.getRuntimeClasspath()); + var cluster = clusterProvider.get(); var nonInputProperties = new SystemPropertyCommandLineArgumentProvider(); nonInputProperties.systemProperty("tests.rest.cluster", () -> String.join(",", cluster.getAllHttpSocketURI())); nonInputProperties.systemProperty("tests.cluster", () -> String.join(",", cluster.getAllTransportPortURI())); @@ -67,7 +68,7 @@ public class JavaRestTestPlugin implements Plugin { // Register plugin bundle with test cluster project.getPlugins().withType(PluginBuildPlugin.class, p -> { TaskProvider bundle = project.getTasks().withType(Zip.class).named(BUNDLE_PLUGIN_TASK_NAME); - cluster.plugin(bundle.flatMap(Zip::getArchiveFile)); + clusterProvider.configure( c-> c.plugin(bundle.flatMap(Zip::getArchiveFile))); javaRestTestTask.configure(t -> t.dependsOn(bundle)); }); diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/test/SystemPropertyCommandLineArgumentProvider.java b/build-tools/src/main/java/org/elasticsearch/gradle/test/SystemPropertyCommandLineArgumentProvider.java index e5f4e7254d61..069e51330f0d 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/test/SystemPropertyCommandLineArgumentProvider.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/test/SystemPropertyCommandLineArgumentProvider.java @@ -7,6 +7,7 @@ */ package org.elasticsearch.gradle.test; +import org.gradle.api.provider.Provider; import org.gradle.api.tasks.Input; import org.gradle.process.CommandLineArgumentProvider; @@ -18,6 +19,10 @@ import java.util.stream.Collectors; public class SystemPropertyCommandLineArgumentProvider implements CommandLineArgumentProvider { private final Map systemProperties = new LinkedHashMap<>(); + public void systemProperty(String key, Provider value) { + systemProperties.put(key, (Supplier) () -> String.valueOf(value.get())); + } + public void systemProperty(String key, Supplier value) { systemProperties.put(key, value); } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/test/YamlRestTestPlugin.java b/build-tools/src/main/java/org/elasticsearch/gradle/test/YamlRestTestPlugin.java index 2a021ecf537d..15878ebb57d8 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/test/YamlRestTestPlugin.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/test/YamlRestTestPlugin.java @@ -16,6 +16,7 @@ import org.elasticsearch.gradle.testclusters.TestClustersPlugin; import org.elasticsearch.gradle.transform.UnzipTransform; import org.gradle.api.Action; import org.gradle.api.NamedDomainObjectContainer; +import org.gradle.api.NamedDomainObjectProvider; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.Task; @@ -81,11 +82,11 @@ public class YamlRestTestPlugin implements Plugin { testSourceSet.getOutput().dir(copyRestTestSpecs.map(Task::getOutputs)); Configuration yamlRestTestImplementation = configurations.getByName(testSourceSet.getImplementationConfigurationName()); setupDefaultDependencies(project.getDependencies(), restTestSpecs, yamlRestTestImplementation); - var cluster = testClusters.maybeCreate(YAML_REST_TEST); + var cluster = testClusters.register(YAML_REST_TEST); TaskProvider yamlRestTestTask = setupTestTask(project, testSourceSet, cluster); project.getPlugins().withType(PluginBuildPlugin.class, p -> { TaskProvider bundle = project.getTasks().withType(Zip.class).named(BUNDLE_PLUGIN_TASK_NAME); - cluster.plugin(bundle.flatMap(Zip::getArchiveFile)); + cluster.configure(c -> c.plugin(bundle.flatMap(Zip::getArchiveFile))); yamlRestTestTask.configure(t -> t.dependsOn(bundle)); }); @@ -109,15 +110,16 @@ public class YamlRestTestPlugin implements Plugin { } private TaskProvider setupTestTask( - Project project, - SourceSet testSourceSet, - ElasticsearchCluster cluster + Project project, + SourceSet testSourceSet, + NamedDomainObjectProvider clusterProvider ) { return project.getTasks().register(YAML_REST_TEST, StandaloneRestIntegTestTask.class, task -> { - task.useCluster(cluster); + task.useCluster(clusterProvider.get()); task.setTestClassesDirs(testSourceSet.getOutput().getClassesDirs()); task.setClasspath(testSourceSet.getRuntimeClasspath()); + var cluster = clusterProvider.get(); var nonInputProperties = new SystemPropertyCommandLineArgumentProvider(); nonInputProperties.systemProperty("tests.rest.cluster", () -> String.join(",", cluster.getAllHttpSocketURI())); nonInputProperties.systemProperty("tests.cluster", () -> String.join(",", cluster.getAllTransportPortURI())); diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java index 5c94a842706c..9d4447e9254a 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java @@ -10,6 +10,7 @@ package org.elasticsearch.gradle.testclusters; import org.gradle.api.Action; import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; +import org.gradle.api.provider.Provider; import org.gradle.api.tasks.Nested; import java.util.Collection; @@ -31,5 +32,9 @@ public interface TestClustersAware extends Task { getClusters().add(cluster); } + default void useCluster(Provider cluster) { + useCluster(cluster.get()); + } + default void beforeStart() {} } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java index 1e1ef8f17f15..2149abe09fec 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java @@ -121,7 +121,7 @@ public class TestClustersPlugin implements Plugin { ); }); project.getExtensions().add(EXTENSION_NAME, container); - container.all(cluster -> cluster.systemProperty("ingest.geoip.downloader.enabled.default", "false")); + container.configureEach(cluster -> cluster.systemProperty("ingest.geoip.downloader.enabled.default", "false")); return container; } diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle index e4d24e220b29..37f51aa9dbbb 100644 --- a/client/rest-high-level/build.gradle +++ b/client/rest-high-level/build.gradle @@ -93,7 +93,7 @@ tasks.named("check").configure { dependsOn(asyncIntegTest) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' systemProperty 'es.scripting.update.ctx_in_params', 'false' setting 'reindex.remote.whitelist', '[ "[::1]:*", "127.0.0.1:*" ]' diff --git a/distribution/archives/integ-test-zip/build.gradle b/distribution/archives/integ-test-zip/build.gradle index 41815f24d65b..f83aaf74fc2a 100644 --- a/distribution/archives/integ-test-zip/build.gradle +++ b/distribution/archives/integ-test-zip/build.gradle @@ -44,8 +44,7 @@ tasks.named("integTest").configure { * when running against an external cluster. */ if (project.providers.systemProperty("tests.rest.cluster").forUseAtConfigurationTime().isPresent()) { - nonInputProperties.systemProperty 'tests.logfile', - "${-> testClusters.integTest.singleNode().getServerLog()}" + nonInputProperties.systemProperty 'tests.logfile', testClusters.named('integTest').map(c -> c.singleNode().serverLog) } else { systemProperty 'tests.logfile', '--external--' } diff --git a/modules/ingest-common/build.gradle b/modules/ingest-common/build.gradle index fe668993da4e..cba6774f464e 100644 --- a/modules/ingest-common/build.gradle +++ b/modules/ingest-common/build.gradle @@ -29,7 +29,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { // Needed in order to test ingest pipeline templating: // (this is because the integTest node is not using default distribution, but only the minimal number of required modules) module ':modules:lang-mustache' diff --git a/modules/ingest-geoip/qa/file-based-update/build.gradle b/modules/ingest-geoip/qa/file-based-update/build.gradle index 507715e703b2..963a3860d0ea 100644 --- a/modules/ingest-geoip/qa/file-based-update/build.gradle +++ b/modules/ingest-geoip/qa/file-based-update/build.gradle @@ -9,7 +9,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'resource.reload.interval.high', '100ms' setting 'xpack.security.enabled', 'true' @@ -18,7 +18,7 @@ testClusters.all { tasks.named("integTest").configure { systemProperty 'tests.security.manager', 'false' // Allows the test the add databases to config directory. - nonInputProperties.systemProperty 'tests.config.dir', "${-> testClusters.integTest.singleNode().getConfigDir()}" + nonInputProperties.systemProperty 'tests.config.dir', testClusters.named("integTest").map(c -> c.singleNode().getConfigDir()) } tasks.named("forbiddenPatterns").configure { diff --git a/modules/ingest-user-agent/build.gradle b/modules/ingest-user-agent/build.gradle index e84ad0e5d441..bdf7fae42d84 100644 --- a/modules/ingest-user-agent/build.gradle +++ b/modules/ingest-user-agent/build.gradle @@ -19,7 +19,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { extraConfigFile 'ingest-user-agent/test-regexes.yml', file('src/test/test-regexes.yml') } diff --git a/modules/kibana/build.gradle b/modules/kibana/build.gradle index 896dfb10ce5a..f30f155b02d6 100644 --- a/modules/kibana/build.gradle +++ b/modules/kibana/build.gradle @@ -16,7 +16,7 @@ dependencies { api project(path: ':modules:reindex') } -testClusters.all { +testClusters.configureEach { module ':modules:reindex' } diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index 395daf771dfc..6cfe759377d5 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -16,7 +16,7 @@ esplugin { classname 'org.elasticsearch.painless.PainlessPlugin' } -testClusters.all { +testClusters.configureEach { module ':modules:mapper-extras' systemProperty 'es.scripting.update.ctx_in_params', 'false' // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0 @@ -109,41 +109,37 @@ dependencies { } } -testClusters { - generateContextCluster { - testDistribution = 'DEFAULT' - } +def generateContextCluster = testClusters.register("generateContextCluster") { + testDistribution = 'DEFAULT' } tasks.register("generateContextDoc", DefaultTestClustersTask) { dependsOn sourceSets.doc.runtimeClasspath - useCluster testClusters.generateContextCluster + useCluster generateContextCluster doFirst { project.javaexec { mainClass = 'org.elasticsearch.painless.ContextDocGenerator' classpath = sourceSets.doc.runtimeClasspath - systemProperty "cluster.uri", "${-> testClusters.generateContextCluster.singleNode().getAllHttpSocketURI().get(0)}" + systemProperty "cluster.uri", "${-> generateContextCluster.get().singleNode().getAllHttpSocketURI().get(0)}" }.assertNormalExitValue() } } /********************************************** * Context JSON Generation * **********************************************/ -testClusters { - generateContextApiSpecCluster { +def generateContextApiSpecCluster = testClusters.register("generateContextApiSpecCluster") { testDistribution = 'DEFAULT' - } } tasks.register("generateContextApiSpec", DefaultTestClustersTask) { dependsOn sourceSets.doc.runtimeClasspath - useCluster testClusters.generateContextApiSpecCluster + useCluster generateContextApiSpecCluster doFirst { project.javaexec { mainClass = 'org.elasticsearch.painless.ContextApiSpecGenerator' classpath = sourceSets.doc.runtimeClasspath - systemProperty "cluster.uri", "${-> testClusters.generateContextApiSpecCluster.singleNode().getAllHttpSocketURI().get(0)}" - systemProperty "jdksrc", providers.systemProperty("jdksrc").forUseAtConfigurationTime().getOrNull() + systemProperty "cluster.uri", "${-> generateContextApiSpecCluster.get().singleNode().getAllHttpSocketURI().get(0)}" + systemProperty "jdksrc", providers.systemProperty("jdksrc").getOrNull() systemProperty "packageSources", providers.systemProperty("packageSources").forUseAtConfigurationTime().getOrNull() }.assertNormalExitValue() } diff --git a/modules/rank-eval/build.gradle b/modules/rank-eval/build.gradle index a0a51095c9c8..5ac9922a1e07 100644 --- a/modules/rank-eval/build.gradle +++ b/modules/rank-eval/build.gradle @@ -20,7 +20,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { // Modules who's integration is explicitly tested in integration tests module ':modules:lang-mustache' } diff --git a/modules/reindex/build.gradle b/modules/reindex/build.gradle index c13053f0bc9f..ee9945b6b250 100644 --- a/modules/reindex/build.gradle +++ b/modules/reindex/build.gradle @@ -24,7 +24,7 @@ esplugin { classname 'org.elasticsearch.reindex.ReindexPlugin' } -testClusters.all { +testClusters.configureEach { // Modules who's integration is explicitly tested in integration tests module ':modules:parent-join' module ':modules:lang-painless' @@ -151,7 +151,7 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) { /* Use a closure on the string to delay evaluation until right before we * run the integration tests so that we can be sure that the file is * ready. */ - nonInputProperties.systemProperty "es${version}.port", "${-> fixture.get().addressAndPort}" + nonInputProperties.systemProperty "es${version}.port", fixture.map(f->f.addressAndPort) } } } diff --git a/modules/repository-url/build.gradle b/modules/repository-url/build.gradle index a19cae51e898..4b2d3f3528e0 100644 --- a/modules/repository-url/build.gradle +++ b/modules/repository-url/build.gradle @@ -54,7 +54,7 @@ def fixtureAddress = { fixtureName -> File repositoryDir = fixture.fsRepositoryDir as File -testClusters.all { +testClusters.configureEach { // repositoryDir is used by a FS repository to create snapshots setting 'path.repo', "${repositoryDir.absolutePath}", PropertyNormalization.IGNORE_VALUE // repositoryDir is used by two URL repositories to restore snapshots diff --git a/plugins/examples/custom-settings/build.gradle b/plugins/examples/custom-settings/build.gradle index b9c9e37598cc..b38c0e538c9e 100644 --- a/plugins/examples/custom-settings/build.gradle +++ b/plugins/examples/custom-settings/build.gradle @@ -16,7 +16,7 @@ esplugin { noticeFile rootProject.file('NOTICE.txt') } -testClusters.all { +testClusters.configureEach { // Adds a setting in the Elasticsearch keystore before running the integration tests keystore 'custom.secured', 'password' } diff --git a/plugins/examples/custom-suggester/build.gradle b/plugins/examples/custom-suggester/build.gradle index b2be253fb7e4..a48c24889741 100644 --- a/plugins/examples/custom-suggester/build.gradle +++ b/plugins/examples/custom-suggester/build.gradle @@ -16,6 +16,6 @@ esplugin { noticeFile rootProject.file('NOTICE.txt') } -testClusters.all { +testClusters.configureEach { numberOfNodes = 2 } diff --git a/plugins/examples/painless-whitelist/build.gradle b/plugins/examples/painless-whitelist/build.gradle index 8e41e8b6bd83..35f3639fb75e 100644 --- a/plugins/examples/painless-whitelist/build.gradle +++ b/plugins/examples/painless-whitelist/build.gradle @@ -21,7 +21,7 @@ dependencies { compileOnly "org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${elasticsearchVersion}" } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' } diff --git a/qa/build.gradle b/qa/build.gradle index 256861e65840..f67c40244047 100644 --- a/qa/build.gradle +++ b/qa/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.testclusters.TestClustersPlugin subprojects { Project subproj -> plugins.withType(TestClustersPlugin).whenPluginAdded { - testClusters.all { + testClusters.configureEach { testDistribution = 'DEFAULT' } } diff --git a/qa/ccs-rolling-upgrade-remote-cluster/build.gradle b/qa/ccs-rolling-upgrade-remote-cluster/build.gradle index 4a880eb402d0..2f1b21275da2 100644 --- a/qa/ccs-rolling-upgrade-remote-cluster/build.gradle +++ b/qa/ccs-rolling-upgrade-remote-cluster/build.gradle @@ -20,8 +20,8 @@ dependencies { } for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { - String baseName = "v${bwcVersion}" - String bwcVersionStr = "${bwcVersion}" + String bwcVersionStr = bwcVersion.toString() + String baseName = "v" + bwcVersionStr /** * We execute tests 3 times. @@ -30,30 +30,29 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { * - Only node-0 and node-2 of the remote cluster can accept remote connections. This can creates a test * scenario where a query request and fetch request are sent via **proxy nodes** that have different version. */ - testClusters { - "${baseName}-local" { - numberOfNodes = 2 - versions = [bwcVersionStr, project.version] - setting 'cluster.remote.node.attr', 'gateway' - setting 'xpack.security.enabled', 'false' - } - "${baseName}-remote" { - numberOfNodes = 3 - versions = [bwcVersionStr, project.version] - firstNode.setting 'node.attr.gateway', 'true' - lastNode.setting 'node.attr.gateway', 'true' - setting 'xpack.security.enabled', 'false' - } + def localCluster = testClusters.register("${baseName}-local") { + numberOfNodes = 2 + versions = [bwcVersionStr, project.version] + setting 'cluster.remote.node.attr', 'gateway' + setting 'xpack.security.enabled', 'false' + } + def remoteCluster = testClusters.register("${baseName}-remote") { + numberOfNodes = 3 + versions = [bwcVersionStr, project.version] + firstNode.setting 'node.attr.gateway', 'true' + lastNode.setting 'node.attr.gateway', 'true' + setting 'xpack.security.enabled', 'false' } + tasks.withType(StandaloneRestIntegTestTask).matching { it.name.startsWith("${baseName}#") }.configureEach { - useCluster testClusters."${baseName}-local" - useCluster testClusters."${baseName}-remote" + useCluster localCluster + useCluster remoteCluster systemProperty 'tests.upgrade_from_version', bwcVersionStr.replace('-SNAPSHOT', '') doFirst { - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}-local".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.rest.remote_cluster', "${-> testClusters."${baseName}-remote".allHttpSocketURI.join(",")}") + nonInputProperties.systemProperty('tests.rest.cluster', localCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.rest.remote_cluster', remoteCluster.map(c -> c.allHttpSocketURI.join(","))) } } @@ -61,22 +60,22 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { dependsOn "processTestResources" mustRunAfter("precommit") doFirst { - testClusters."${baseName}-local".nextNodeToNextVersion() - testClusters."${baseName}-remote".nextNodeToNextVersion() + localCluster.get().nextNodeToNextVersion() + remoteCluster.get().nextNodeToNextVersion() } } tasks.register("${baseName}#twoThirdUpgraded", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oneThirdUpgraded" doFirst { - testClusters."${baseName}-remote".nextNodeToNextVersion() + remoteCluster.get().nextNodeToNextVersion() } } tasks.register("${baseName}#fullUpgraded", StandaloneRestIntegTestTask) { dependsOn "${baseName}#twoThirdUpgraded" doFirst { - testClusters."${baseName}-remote".nextNodeToNextVersion() + remoteCluster.get().nextNodeToNextVersion() } } diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 8456ebf5cd48..bad6b16111f0 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -17,21 +17,20 @@ apply plugin: 'elasticsearch.internal-test-artifact' apply plugin: 'elasticsearch.bwc-test' for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { - String baseName = "v${bwcVersion}" + def bwcVersionString = bwcVersion.toString(); + String baseName = "v" + bwcVersionString - testClusters { - "${baseName}" { - versions = [bwcVersion.toString(), project.version] + def baseCluster = testClusters.register(baseName) { + versions = [bwcVersionString, project.version] numberOfNodes = 2 // some tests rely on the translog not being flushed setting 'indices.memory.shard_inactive_time', '60m' setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" setting 'xpack.security.enabled', 'false' - } } tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") doFirst { delete("${buildDir}/cluster/shared/repo/${baseName}") @@ -41,20 +40,20 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { } tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster dependsOn "${baseName}#oldClusterTest" doFirst { - testClusters."${baseName}".goToNextVersion() + baseCluster.get().goToNextVersion() } systemProperty 'tests.is_old_cluster', 'false' } - String oldVersion = bwcVersion.toString().minus("-SNAPSHOT") + String oldVersion = bwcVersionString.minus("-SNAPSHOT") tasks.matching { it.name.startsWith(baseName) && it.name.endsWith("ClusterTest") }.configureEach { it.systemProperty 'tests.old_cluster_version', oldVersion it.systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}" - it.nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + it.nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + it.nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register(bwcTaskName(bwcVersion)) { diff --git a/qa/mixed-cluster/build.gradle b/qa/mixed-cluster/build.gradle index a1a1189e7785..5ff6943f6f0a 100644 --- a/qa/mixed-cluster/build.gradle +++ b/qa/mixed-cluster/build.gradle @@ -28,42 +28,39 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { continue; } - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersionString /* This project runs the core REST tests against a 4 node cluster where two of the nodes has a different minor. */ - testClusters { - "${baseName}" { - versions = [bwcVersion.toString(), project.version] - numberOfNodes = 4 - - setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" - setting 'xpack.security.enabled', 'false' - } + def baseCluster = testClusters.register(baseName) { + versions = [bwcVersionString, project.version] + numberOfNodes = 4 + setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" + setting 'xpack.security.enabled', 'false' } tasks.register("${baseName}#mixedClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") doFirst { delete("${buildDir}/cluster/shared/repo/${baseName}") // Getting the endpoints causes a wait for the cluster - println "Test cluster endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" + println "Test cluster endpoints are: ${-> baseCluster.get().allHttpSocketURI.join(",")}" println "Upgrading one node to create a mixed cluster" if (BuildParams.isSnapshotBuild() == false) { - testClusters."${baseName}".nodes."${baseName}-0".systemProperty 'es.index_mode_feature_flag_registered', 'true' + baseCluster.get().nodes."${baseName}-0".systemProperty 'es.index_mode_feature_flag_registered', 'true' } - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() // Getting the endpoints causes a wait for the cluster - println "Upgrade complete, endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" + println "Upgrade complete, endpoints are: ${-> baseCluster.get().allHttpSocketURI.join(",")}" println "Upgrading another node to create a mixed cluster" if (BuildParams.isSnapshotBuild() == false) { - testClusters."${baseName}".nodes."${baseName}-1".systemProperty 'es.index_mode_feature_flag_registered', 'true' + baseCluster.get().nodes."${baseName}-1".systemProperty 'es.index_mode_feature_flag_registered', 'true' } - testClusters."${baseName}".nextNodeToNextVersion() - - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + baseCluster.get().nextNodeToNextVersion() + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}" onlyIf { project.bwc_tests_enabled } diff --git a/qa/multi-cluster-search/build.gradle b/qa/multi-cluster-search/build.gradle index 817a9a41e42e..481f2b803555 100644 --- a/qa/multi-cluster-search/build.gradle +++ b/qa/multi-cluster-search/build.gradle @@ -21,16 +21,14 @@ tasks.register('remote-cluster', RestIntegTestTask) { systemProperty 'tests.rest.suite', 'remote_cluster' } -testClusters { - 'remote-cluster' { - numberOfNodes = 2 - setting 'node.roles', '[data,ingest,master]' - setting 'xpack.security.enabled', 'false' - } +testClusters.matching{ it.name == 'remote-cluster' }.configureEach { + numberOfNodes = 2 + setting 'node.roles', '[data,ingest,master]' + setting 'xpack.security.enabled', 'false' } tasks.register("mixedClusterTest", RestIntegTestTask) { - useCluster testClusters.'remote-cluster' + useCluster testClusters.named('remote-cluster') dependsOn 'remote-cluster' systemProperty 'tests.rest.suite', 'multi_cluster' } diff --git a/qa/repository-multi-version/build.gradle b/qa/repository-multi-version/build.gradle index e947453a1e57..ca2b6cdf83e0 100644 --- a/qa/repository-multi-version/build.gradle +++ b/qa/repository-multi-version/build.gradle @@ -34,13 +34,11 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { } } - testClusters { - "${oldClusterName}" clusterSettings(bwcVersion.toString()) - "${newClusterName}" clusterSettings(project.version) - } + testClusters.register(oldClusterName, clusterSettings(bwcVersion.toString())) + testClusters.register(newClusterName, clusterSettings(project.version)) tasks.register("${baseName}#Step1OldClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${oldClusterName}" + useCluster testClusters.named(oldClusterName) mustRunAfter("precommit") doFirst { delete("${buildDir}/cluster/shared/repo/${baseName}") @@ -49,19 +47,19 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { } tasks.register("${baseName}#Step2NewClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${newClusterName}" + useCluster testClusters.named(newClusterName) dependsOn "${baseName}#Step1OldClusterTest" systemProperty 'tests.rest.suite', 'step2' } tasks.register("${baseName}#Step3OldClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${oldClusterName}" + useCluster testClusters.named(oldClusterName) dependsOn "${baseName}#Step2NewClusterTest" systemProperty 'tests.rest.suite', 'step3' } tasks.register("${baseName}#Step4NewClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${newClusterName}" + useCluster testClusters.named(newClusterName) dependsOn "${baseName}#Step3OldClusterTest" systemProperty 'tests.rest.suite', 'step4' } @@ -70,8 +68,8 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { it.systemProperty 'tests.old_cluster_version', bwcVersion.toString().minus("-SNAPSHOT") it.systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}" def clusterName = it.name.contains("Step2") || it.name.contains("Step4") ? "${newClusterName}" : "${oldClusterName}" - it.nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${clusterName}".allHttpSocketURI.join(",")}") - it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${clusterName}".getName()}") + it.nonInputProperties.systemProperty('tests.rest.cluster', testClusters.named(clusterName).map(c -> c.allHttpSocketURI.join(","))) + it.nonInputProperties.systemProperty('tests.clustername', clusterName) } tasks.register(bwcTaskName(bwcVersion)) { diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index 4a7f9d904d71..9fd784bcec74 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -29,70 +29,70 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { *
  • run tests with systemProperty 'tests.rest.suite', 'upgraded_cluster' * */ - String baseName = "v${bwcVersion}" - testClusters { - "${baseName}" { - versions = [bwcVersion.toString(), project.version] - numberOfNodes = 3 + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersionString - setting 'repositories.url.allowed_urls', 'http://snapshot.test*' - setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" - setting 'xpack.security.enabled', 'false' - } + def baseCluster = testClusters.register(baseName) { + versions = [bwcVersionString, project.version] + numberOfNodes = 3 + + setting 'repositories.url.allowed_urls', 'http://snapshot.test*' + setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" + setting 'xpack.security.enabled', 'false' } String oldVersion = bwcVersion.toString() tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) { dependsOn "processTestResources" - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") doFirst { delete("${buildDir}/cluster/shared/repo/${baseName}") } systemProperty 'tests.rest.suite', 'old_cluster' systemProperty 'tests.upgrade_from_version', oldVersion - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register("${baseName}#oneThirdUpgradedTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oldClusterTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } systemProperty 'tests.rest.suite', 'mixed_cluster' systemProperty 'tests.upgrade_from_version', oldVersion systemProperty 'tests.first_round', 'true' - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register("${baseName}#twoThirdsUpgradedTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oneThirdUpgradedTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } systemProperty 'tests.rest.suite', 'mixed_cluster' systemProperty 'tests.upgrade_from_version', oldVersion systemProperty 'tests.first_round', 'false' - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#twoThirdsUpgradedTest" doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - useCluster testClusters."${baseName}" + useCluster testClusters.named(baseName) systemProperty 'tests.rest.suite', 'upgraded_cluster' systemProperty 'tests.upgrade_from_version', oldVersion - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register(bwcTaskName(bwcVersion)) { diff --git a/qa/smoke-test-http/build.gradle b/qa/smoke-test-http/build.gradle index b0acfcb0f9a4..75c2ca3a09d0 100644 --- a/qa/smoke-test-http/build.gradle +++ b/qa/smoke-test-http/build.gradle @@ -17,6 +17,6 @@ dependencies { testImplementation project(':plugins:transport-nio') // for http } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/qa/smoke-test-ingest-disabled/build.gradle b/qa/smoke-test-ingest-disabled/build.gradle index 280bcf233c05..95658bdd9841 100644 --- a/qa/smoke-test-ingest-disabled/build.gradle +++ b/qa/smoke-test-ingest-disabled/build.gradle @@ -15,7 +15,7 @@ dependencies { testImplementation project(':modules:ingest-common') } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/qa/smoke-test-ingest-with-all-dependencies/build.gradle b/qa/smoke-test-ingest-with-all-dependencies/build.gradle index df213274e34e..1654b1377866 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/build.gradle +++ b/qa/smoke-test-ingest-with-all-dependencies/build.gradle @@ -19,7 +19,7 @@ dependencies { testImplementation project(':modules:reindex') } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/qa/smoke-test-multinode/build.gradle b/qa/smoke-test-multinode/build.gradle index ae2ac38cb21e..197d7c1bb31b 100644 --- a/qa/smoke-test-multinode/build.gradle +++ b/qa/smoke-test-multinode/build.gradle @@ -25,7 +25,7 @@ testClusters.matching { it.name == "integTest" }.configureEach { setting 'path.repo', repo.absolutePath } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' if (BuildParams.isSnapshotBuild() == false) { systemProperty 'es.index_mode_feature_flag_registered', 'true' diff --git a/qa/system-indices/build.gradle b/qa/system-indices/build.gradle index 1e082cf5e2af..94ee6455eddd 100644 --- a/qa/system-indices/build.gradle +++ b/qa/system-indices/build.gradle @@ -22,7 +22,7 @@ tasks.named("javaRestTest").configure { dependsOn "buildZip" } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.security.autoconfiguration.enabled', 'false' diff --git a/qa/unconfigured-node-name/build.gradle b/qa/unconfigured-node-name/build.gradle index 256c7d981610..b467657f05f8 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/build.gradle @@ -10,7 +10,7 @@ apply plugin: 'elasticsearch.internal-testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/qa/verify-version-constants/build.gradle b/qa/verify-version-constants/build.gradle index d551ecc39a1e..4fc67424a8cc 100644 --- a/qa/verify-version-constants/build.gradle +++ b/qa/verify-version-constants/build.gradle @@ -16,20 +16,19 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.bwc-test' for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v${bwcVersionString}" - testClusters { - "${baseName}" { - version = bwcVersion.toString() + def baseCluster = testClusters.register(baseName) { + version = bwcVersionString setting 'xpack.security.enabled', 'true' user username: 'admin', password: 'admin-password', role: 'superuser' - } } tasks.register("${baseName}#integTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + useCluster baseCluster + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', "${->baseCluster.get().getName()}") } tasks.register(bwcTaskName(bwcVersion)) { @@ -60,5 +59,5 @@ tasks.register("verifyDocsLuceneVersion") { } tasks.named("check").configure { - dependsOn verifyDocsLuceneVersion + dependsOn "verifyDocsLuceneVersion" } diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 1ede5d2c8741..93eb63e2ab75 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -33,7 +33,7 @@ artifacts { restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test")) } -testClusters.all { +testClusters.configureEach { module ':modules:mapper-extras' if (BuildParams.isSnapshotBuild() == false) { systemProperty 'es.index_mode_feature_flag_registered', 'true' diff --git a/test/external-modules/die-with-dignity/build.gradle b/test/external-modules/die-with-dignity/build.gradle index a203d6e8fd94..dc79a6f0275e 100644 --- a/test/external-modules/die-with-dignity/build.gradle +++ b/test/external-modules/die-with-dignity/build.gradle @@ -16,7 +16,7 @@ tasks.named("javaRestTest").configure { it.onlyIf { BuildParams.isSnapshotBuild() } systemProperty 'tests.security.manager', 'false' systemProperty 'tests.system_call_filter', 'false' - nonInputProperties.systemProperty 'log', "${-> testClusters.javaRestTest.singleNode().getServerLog()}" + nonInputProperties.systemProperty 'log', testClusters.named("javaRestTest").map(c -> c.singleNode().getServerLog()) systemProperty 'runtime.java.home', BuildParams.runtimeJavaHome } diff --git a/x-pack/plugin/async-search/qa/rest/build.gradle b/x-pack/plugin/async-search/qa/rest/build.gradle index 545925f34ef5..809e8046120e 100644 --- a/x-pack/plugin/async-search/qa/rest/build.gradle +++ b/x-pack/plugin/async-search/qa/rest/build.gradle @@ -16,7 +16,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' } diff --git a/x-pack/plugin/async-search/qa/security/build.gradle b/x-pack/plugin/async-search/qa/security/build.gradle index d0184395b08d..e814b9c95581 100644 --- a/x-pack/plugin/async-search/qa/security/build.gradle +++ b/x-pack/plugin/async-search/qa/security/build.gradle @@ -6,7 +6,7 @@ dependencies { javaRestTestImplementation project(':test:framework') } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 2 setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/autoscaling/qa/rest/build.gradle b/x-pack/plugin/autoscaling/qa/rest/build.gradle index 22bd3b6f0395..bfdd8ac4401b 100644 --- a/x-pack/plugin/autoscaling/qa/rest/build.gradle +++ b/x-pack/plugin/autoscaling/qa/rest/build.gradle @@ -13,7 +13,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index be3dab3d0d7c..ada3688e85aa 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -207,7 +207,7 @@ tasks.named("yamlRestTestV7CompatTest").configure { dependsOn "copyExtraResources" } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' // this is important since we use the reindex module in ML setting 'xpack.ml.enabled', 'true' setting 'xpack.security.enabled', 'true' diff --git a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle index af0d94ec2408..b1ccdd3dacf6 100644 --- a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle +++ b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle @@ -10,23 +10,20 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } +def leaderCluster = testClusters.register("leader-cluster") { + testDistribution = 'DEFAULT' + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' +} -testClusters { - "leader-cluster" { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - } - - "follow-cluster" { - testDistribution = 'DEFAULT' - setting 'xpack.monitoring.collection.enabled', 'true' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - setting 'cluster.remote.leader_cluster.seeds', { "\"${testClusters."leader-cluster".getAllTransportPortURI().join(",")}\"" - } +def followCluster = testClusters.register("follow-cluster") { + testDistribution = 'DEFAULT' + setting 'xpack.monitoring.collection.enabled', 'true' + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' + setting 'cluster.remote.leader_cluster.seeds', { "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" } } @@ -53,11 +50,11 @@ tasks.register("writeJavaPolicy") { tasks.register("follow-cluster", RestIntegTestTask) { dependsOn 'writeJavaPolicy', "leader-cluster" - useCluster testClusters."leader-cluster" + useCluster leaderCluster systemProperty 'java.security.policy', "file://${policyFile}" systemProperty 'tests.target_cluster', 'follow' - nonInputProperties.systemProperty 'tests.leader_host', "${-> testClusters."leader-cluster".getAllHttpSocketURI().get(0)}" - nonInputProperties.systemProperty 'log', "${-> testClusters."follow-cluster".getFirstNode().getServerLog()}" + nonInputProperties.systemProperty 'tests.leader_host', leaderCluster.map(c -> c.allHttpSocketURI.get(0)) + nonInputProperties.systemProperty 'log', followCluster.map(c -> c.getFirstNode().getServerLog()) } tasks.named("check").configure { dependsOn "follow-cluster" } diff --git a/x-pack/plugin/ccr/qa/multi-cluster/build.gradle b/x-pack/plugin/ccr/qa/multi-cluster/build.gradle index 716cb44460d1..835e66386ec1 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/build.gradle +++ b/x-pack/plugin/ccr/qa/multi-cluster/build.gradle @@ -9,22 +9,21 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } -testClusters { - 'leader-cluster' { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - setting 'path.repo', "${buildDir}/cluster/shared/repo/leader-cluster" - } - 'middle-cluster' { +def leaderCluster = testClusters.register('leader-cluster') { + testDistribution = 'DEFAULT' + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' + setting 'path.repo', "${buildDir}/cluster/shared/repo/leader-cluster" +} + +def middleCluster = testClusters.register('middle-cluster') { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.security.enabled', 'true' user username: 'admin', password: 'admin-password', role: 'superuser' setting 'cluster.remote.leader_cluster.seeds', - { "\"${testClusters.named('leader-cluster').get().getAllTransportPortURI().join(",")}\"" } - } + { "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" } } tasks.register("leader-cluster", RestIntegTestTask) { @@ -35,36 +34,33 @@ tasks.register("leader-cluster", RestIntegTestTask) { tasks.register("middle-cluster", RestIntegTestTask) { dependsOn "leader-cluster" - useCluster testClusters."leader-cluster" + useCluster testClusters.named("leader-cluster") systemProperty 'tests.target_cluster', 'middle' systemProperty 'tests.leader_cluster_repository_path', "${buildDir}/cluster/shared/repo/leader-cluster" - nonInputProperties.systemProperty 'tests.leader_host', - "${-> testClusters.named('leader-cluster').get().getAllHttpSocketURI().get(0)}" + nonInputProperties.systemProperty 'tests.leader_host',leaderCluster.map(c -> c.allHttpSocketURI.get(0)) } tasks.register('follow-cluster', RestIntegTestTask) { dependsOn "leader-cluster", "middle-cluster" - useCluster testClusters."leader-cluster" - useCluster testClusters."middle-cluster" + useCluster leaderCluster + useCluster middleCluster systemProperty 'tests.target_cluster', 'follow' systemProperty 'tests.leader_cluster_repository_path', "${buildDir}/cluster/shared/repo/leader-cluster" - nonInputProperties.systemProperty 'tests.leader_host', - "${-> testClusters.named('leader-cluster').get().getAllHttpSocketURI().get(0)}" - nonInputProperties.systemProperty 'tests.middle_host', - "${-> testClusters.named('middle-cluster').get().getAllHttpSocketURI().get(0)}" + nonInputProperties.systemProperty 'tests.leader_host', leaderCluster.map(c -> c.allHttpSocketURI.get(0)) + nonInputProperties.systemProperty 'tests.middle_host', middleCluster.map(c -> c.allHttpSocketURI.get(0)) } -testClusters.matching { it.name == "follow-cluster" }.configureEach { +testClusters.matching {it.name == "follow-cluster" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.monitoring.collection.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.security.enabled', 'true' user username: 'admin', password: 'admin-password', role: 'superuser' setting 'cluster.remote.leader_cluster.seeds', - { "\"${testClusters.named('leader-cluster').get().getAllTransportPortURI().join(",")}\"" } + { "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" } setting 'cluster.remote.middle_cluster.seeds', - { "\"${testClusters.named('middle-cluster').get().getAllTransportPortURI().join(",")}\"" } + { "\"${middleCluster.get().getAllTransportPortURI().join(",")}\"" } } -tasks.named("check").configure { dependsOn "follow-cluster" } \ No newline at end of file +tasks.named("check").configure { dependsOn "follow-cluster" } diff --git a/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle b/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle index 2507291eff59..67465bc782ad 100644 --- a/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle +++ b/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle @@ -9,21 +9,19 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa:') } -testClusters { - 'leader-cluster' { - testDistribution = 'DEFAULT' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - } +def leaderCluster = testClusters.register('leader-cluster') { + testDistribution = 'DEFAULT' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' +} - 'follow-cluster' { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - setting 'cluster.remote.leader_cluster.seeds', - { "\"${testClusters.'leader-cluster'.getAllTransportPortURI().join(",")}\"" } - } +def followerCluster = testClusters.register('follow-cluster') { + testDistribution = 'DEFAULT' + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' + setting 'cluster.remote.leader_cluster.seeds', + { "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" } } tasks.register('leader-cluster', RestIntegTestTask) { @@ -33,10 +31,9 @@ tasks.register('leader-cluster', RestIntegTestTask) { tasks.register('follow-cluster', RestIntegTestTask) { dependsOn 'leader-cluster' - useCluster testClusters.'leader-cluster' + useCluster leaderCluster systemProperty 'tests.target_cluster', 'follow' - nonInputProperties.systemProperty 'tests.leader_host', - { "${testClusters.'follow-cluster'.getAllHttpSocketURI().get(0)}" } + nonInputProperties.systemProperty 'tests.leader_host', followerCluster.map(c -> c.allHttpSocketURI.get(0)) } tasks.named("check").configure { dependsOn "follow-cluster" } \ No newline at end of file diff --git a/x-pack/plugin/ccr/qa/rest/build.gradle b/x-pack/plugin/ccr/qa/rest/build.gradle index bb9d390229de..98814f04d6c5 100644 --- a/x-pack/plugin/ccr/qa/rest/build.gradle +++ b/x-pack/plugin/ccr/qa/rest/build.gradle @@ -11,7 +11,7 @@ dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' // Disable assertions in FollowingEngineAssertions, otherwise an AssertionError is thrown before // indexing a document directly in a follower index. In a rest test we like to test the exception diff --git a/x-pack/plugin/ccr/qa/restart/build.gradle b/x-pack/plugin/ccr/qa/restart/build.gradle index 742f135b82c2..d354cd911f2f 100644 --- a/x-pack/plugin/ccr/qa/restart/build.gradle +++ b/x-pack/plugin/ccr/qa/restart/build.gradle @@ -8,26 +8,25 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } -testClusters { - 'leader-cluster' { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - } - - 'follow-cluster' { - testDistribution = 'DEFAULT' - setting 'xpack.monitoring.collection.enabled', 'true' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - setting 'cluster.remote.leader_cluster.seeds', - { "\"${testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}\"" } - nameCustomization = { 'follow' } - } +def leaderCluster = testClusters.register('leader-cluster') { + testDistribution = 'DEFAULT' + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' } +def followCluster = testClusters.register('follow-cluster') { + testDistribution = 'DEFAULT' + setting 'xpack.monitoring.collection.enabled', 'true' + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + user username: 'admin', password: 'admin-password', role: 'superuser' + setting 'cluster.remote.leader_cluster.seeds', + { "\"${leaderCluster.get().getAllTransportPortURI().get(0)}\"" } + nameCustomization = { 'follow' } +} + + tasks.register('leader-cluster', RestIntegTestTask) { mustRunAfter("precommit") systemProperty 'tests.target_cluster', 'leader' @@ -35,23 +34,23 @@ tasks.register('leader-cluster', RestIntegTestTask) { tasks.register('follow-cluster', RestIntegTestTask) { dependsOn 'leader-cluster' - useCluster testClusters.'leader-cluster' + useCluster leaderCluster systemProperty 'tests.target_cluster', 'follow' nonInputProperties.systemProperty 'tests.leader_host', - "${-> testClusters.'leader-cluster'.getAllHttpSocketURI().get(0)}" + "${-> leaderCluster.get().getAllHttpSocketURI().get(0)}" } tasks.register("followClusterRestartTest", StandaloneRestIntegTestTask) { dependsOn 'follow-cluster' - useCluster testClusters.'leader-cluster' - useCluster testClusters.'follow-cluster' + useCluster leaderCluster + useCluster followCluster systemProperty 'tests.rest.load_packaged', 'false' systemProperty 'tests.target_cluster', 'follow-restart' doFirst { - testClusters.'follow-cluster'.restart() - nonInputProperties.systemProperty 'tests.leader_host', "${-> testClusters.'leader-cluster'.getAllHttpSocketURI().get(0)}" - nonInputProperties.systemProperty 'tests.rest.cluster', "${-> testClusters.'follow-cluster'.getAllHttpSocketURI().join(",")}" + followCluster.get().restart() + nonInputProperties.systemProperty 'tests.leader_host', leaderCluster.map(c-> c.getAllHttpSocketURI().get(0)) + nonInputProperties.systemProperty 'tests.rest.cluster', followCluster.map(c -> c.getAllHttpSocketURI().join(",")) } } diff --git a/x-pack/plugin/ccr/qa/security/build.gradle b/x-pack/plugin/ccr/qa/security/build.gradle index 97590d059594..e7e6d4abfdf3 100644 --- a/x-pack/plugin/ccr/qa/security/build.gradle +++ b/x-pack/plugin/ccr/qa/security/build.gradle @@ -18,20 +18,19 @@ tasks.register("resolve") { } } -testClusters { - 'leader-cluster' { +def leadCluster = testClusters.register('leader-cluster') { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.security.enabled', 'true' extraConfigFile 'roles.yml', file('leader-roles.yml') user username: "test_admin", role: "superuser" user username: "test_ccr", role: "ccruser" - } +} - 'follow-cluster' { +def followCluster = testClusters.register('follow-cluster') { testDistribution = 'DEFAULT' setting 'cluster.remote.leader_cluster.seeds', { - "\"${testClusters.'leader-cluster'.getAllTransportPortURI().join(",")}\"" + "\"${leadCluster.get().getAllTransportPortURI().join(",")}\"" } setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.security.enabled', 'true' @@ -39,7 +38,6 @@ testClusters { extraConfigFile 'roles.yml', file('follower-roles.yml') user username: "test_admin", role: "superuser" user username: "test_ccr", role: "ccruser" - } } tasks.register('leader-cluster', RestIntegTestTask) { @@ -49,9 +47,9 @@ tasks.register('leader-cluster', RestIntegTestTask) { tasks.register('follow-cluster', RestIntegTestTask) { dependsOn 'leader-cluster' - useCluster testClusters.'leader-cluster' + useCluster leadCluster systemProperty 'tests.target_cluster', 'follow' - nonInputProperties.systemProperty 'tests.leader_host', "${-> testClusters.'leader-cluster'.getAllHttpSocketURI().get(0)}" + nonInputProperties.systemProperty 'tests.leader_host', leadCluster.map(c-> c.getAllHttpSocketURI().get(0)) } -tasks.named("check").configure { dependsOn('follow-cluster') } \ No newline at end of file +tasks.named("check").configure { dependsOn('follow-cluster') } diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index 7504cae334aa..d3b31246cc2b 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -129,7 +129,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'default' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/data-streams/qa/rest/build.gradle b/x-pack/plugin/data-streams/qa/rest/build.gradle index a8d2a202ca3d..eaf3de592341 100644 --- a/x-pack/plugin/data-streams/qa/rest/build.gradle +++ b/x-pack/plugin/data-streams/qa/rest/build.gradle @@ -14,7 +14,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' // Data streams is basic, but a few tests test data streams in combination with paid features setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/deprecation/qa/rest/build.gradle b/x-pack/plugin/deprecation/qa/rest/build.gradle index d38c41e7c27d..8904da0e5cdd 100644 --- a/x-pack/plugin/deprecation/qa/rest/build.gradle +++ b/x-pack/plugin/deprecation/qa/rest/build.gradle @@ -24,7 +24,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/enrich/qa/common/build.gradle b/x-pack/plugin/enrich/qa/common/build.gradle index d4f5f678196d..76e250ed8a13 100644 --- a/x-pack/plugin/enrich/qa/common/build.gradle +++ b/x-pack/plugin/enrich/qa/common/build.gradle @@ -5,7 +5,7 @@ dependencies { api project(':test:framework') } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.security.enabled', 'false' diff --git a/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle b/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle index fcfe3422b3ad..b2ddbc8aebf4 100644 --- a/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle +++ b/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle @@ -7,7 +7,7 @@ dependencies { javaRestTestImplementation project(path: xpackModule('enrich:qa:common')) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' extraConfigFile 'roles.yml', file('roles.yml') user username: "test_admin", password: "x-pack-test-password", role: "superuser" diff --git a/x-pack/plugin/enrich/qa/rest-with-security/build.gradle b/x-pack/plugin/enrich/qa/rest-with-security/build.gradle index e00d3e47d622..a016c47de614 100644 --- a/x-pack/plugin/enrich/qa/rest-with-security/build.gradle +++ b/x-pack/plugin/enrich/qa/rest-with-security/build.gradle @@ -11,7 +11,7 @@ if (BuildParams.inFipsJvm){ tasks.named("javaRestTest").configure{enabled = false } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' extraConfigFile 'roles.yml', file('roles.yml') user username: "test_admin", password: "x-pack-test-password", role: "superuser" diff --git a/x-pack/plugin/enrich/qa/rest/build.gradle b/x-pack/plugin/enrich/qa/rest/build.gradle index 721b5628407b..2253e358b499 100644 --- a/x-pack/plugin/enrich/qa/rest/build.gradle +++ b/x-pack/plugin/enrich/qa/rest/build.gradle @@ -23,7 +23,7 @@ if (BuildParams.inFipsJvm){ tasks.named("yamlRestTest").configure{enabled = false } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.monitoring.collection.enabled', 'true' diff --git a/x-pack/plugin/eql/qa/correctness/build.gradle b/x-pack/plugin/eql/qa/correctness/build.gradle index d33429eee7cc..23fd035abf6e 100644 --- a/x-pack/plugin/eql/qa/correctness/build.gradle +++ b/x-pack/plugin/eql/qa/correctness/build.gradle @@ -26,10 +26,10 @@ Boolean preserveData = providers.systemProperty('eql.test.preserve.data') if (BuildParams.inFipsJvm){ // This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC - tasks.named("javaRestTest").configure{enabled = false } + tasks.named("javaRestTest").configure{ enabled = false } } -testClusters { - all { + +testClusters.configureEach { plugin ':plugins:repository-gcs' if (serviceAccountFile) { keystore 'gcs.client.eql_test.credentials_file', serviceAccountFile @@ -42,10 +42,10 @@ testClusters { jvmArgs '-Xms4g', '-Xmx4g' setting 'xpack.security.enabled', 'true' user username: 'admin', password: 'admin-password', role: 'superuser' - } - runTask { - jvmArgs '-Xms8g', '-Xmx8g' - } +} + +tasks.withType(RunTask).configureEach { + jvmArgs '-Xms8g', '-Xmx8g' } tasks.named('javaRestTest').configure { @@ -57,6 +57,6 @@ tasks.named('javaRestTest').configure { } tasks.register("runEqlCorrectnessNode", RunTask) { - useCluster testClusters.runTask + useCluster testClusters.named('runTask') description = 'Runs elasticsearch in the foreground with gcs plugin and keystore credentials' } diff --git a/x-pack/plugin/eql/qa/mixed-node/build.gradle b/x-pack/plugin/eql/qa/mixed-node/build.gradle index af3f4a13dd22..bbd25aab06e7 100644 --- a/x-pack/plugin/eql/qa/mixed-node/build.gradle +++ b/x-pack/plugin/eql/qa/mixed-node/build.gradle @@ -22,11 +22,11 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.on continue; } - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersion - testClusters { - "${baseName}" { - versions = [bwcVersion.toString(), project.version] + def cluster = testClusters.register(baseName) { + versions = [bwcVersionString, project.version] numberOfNodes = 3 testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' @@ -36,21 +36,20 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.on setting 'xpack.license.self_generated.type', 'trial' // for debugging purposes // setting 'logger.org.elasticsearch.xpack.eql.plugin.TransportEqlSearchAction', 'TRACE' - } } tasks.register("${baseName}#mixedClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster cluster mustRunAfter("precommit") doFirst { // Getting the endpoints causes a wait for the cluster println "Endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" println "Upgrading one node to create a mixed cluster" - testClusters."${baseName}".nextNodeToNextVersion() + cluster.get().nextNodeToNextVersion() - println "Upgrade complete, endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + println "Upgrade complete, endpoints are: ${-> testClusters.named(baseName).get().allHttpSocketURI.join(",")}" + nonInputProperties.systemProperty('tests.rest.cluster', cluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } onlyIf { project.bwc_tests_enabled } } diff --git a/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle b/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle index 10fabdd9f49c..24d05f2668d6 100644 --- a/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle +++ b/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle @@ -8,36 +8,34 @@ dependencies { testImplementation project(path: xpackModule('eql:qa:common')) } -testClusters { - 'remote-cluster' { - testDistribution = 'DEFAULT' - numberOfNodes = 2 - setting 'node.roles', '[data,ingest,master]' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.security.enabled', 'true' - setting 'xpack.security.autoconfiguration.enabled', 'false' +def remoteClusterReg = testClusters.register('remote-cluster') { + testDistribution = 'DEFAULT' + numberOfNodes = 2 + setting 'node.roles', '[data,ingest,master]' + setting 'xpack.ml.enabled', 'false' + setting 'xpack.watcher.enabled', 'false' + setting 'xpack.security.enabled', 'true' + setting 'xpack.security.autoconfiguration.enabled', 'false' - user username: "test_user", password: "x-pack-test-password" + user username: "test_user", password: "x-pack-test-password" +} + +def integTestClusterReg = testClusters.register('integTest') { + testDistribution = 'DEFAULT' + setting 'xpack.ml.enabled', 'false' + setting 'xpack.watcher.enabled', 'false' + setting 'cluster.remote.my_remote_cluster.seeds', { + remoteClusterReg.get().getAllTransportPortURI().collect { "\"$it\"" }.toString() } + setting 'cluster.remote.connections_per_cluster', "1" + setting 'xpack.security.enabled', 'true' + setting 'xpack.security.autoconfiguration.enabled', 'false' - 'integTest' { - testDistribution = 'DEFAULT' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.watcher.enabled', 'false' - setting 'cluster.remote.my_remote_cluster.seeds', { - testClusters.'remote-cluster'.getAllTransportPortURI().collect { "\"$it\"" }.toString() - } - setting 'cluster.remote.connections_per_cluster', "1" - setting 'xpack.security.enabled', 'true' - setting 'xpack.security.autoconfiguration.enabled', 'false' - - user username: "test_user", password: "x-pack-test-password" - } + user username: "test_user", password: "x-pack-test-password" } tasks.register("startRemoteCluster", DefaultTestClustersTask.class) { - useCluster testClusters.'remote-cluster' + useCluster remoteClusterReg doLast { "Starting remote cluster before integ tests and integTest cluster is started" } @@ -45,9 +43,9 @@ tasks.register("startRemoteCluster", DefaultTestClustersTask.class) { tasks.named("integTest").configure { dependsOn 'startRemoteCluster' - useCluster testClusters.'remote-cluster' + useCluster remoteClusterReg doFirst { - nonInputProperties.systemProperty 'tests.rest.cluster.remote.host', "${-> testClusters.'remote-cluster'.getAllHttpSocketURI().get(0)}" + nonInputProperties.systemProperty 'tests.rest.cluster.remote.host', remoteClusterReg.map(c->c.getAllHttpSocketURI().get(0)) nonInputProperties.systemProperty 'tests.rest.cluster.remote.user', "test_user" nonInputProperties.systemProperty 'tests.rest.cluster.remote.password', "x-pack-test-password" } diff --git a/x-pack/plugin/eql/qa/rest/build.gradle b/x-pack/plugin/eql/qa/rest/build.gradle index ad64650b29a3..36b108f60040 100644 --- a/x-pack/plugin/eql/qa/rest/build.gradle +++ b/x-pack/plugin/eql/qa/rest/build.gradle @@ -19,7 +19,7 @@ if (BuildParams.inFipsJvm){ tasks.named("javaRestTest").configure{enabled = false } tasks.named("yamlRestTest").configure{enabled = false } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.monitoring.collection.enabled', 'true' diff --git a/x-pack/plugin/eql/qa/security/build.gradle b/x-pack/plugin/eql/qa/security/build.gradle index bb60b1422af4..d13c3570ee61 100644 --- a/x-pack/plugin/eql/qa/security/build.gradle +++ b/x-pack/plugin/eql/qa/security/build.gradle @@ -11,7 +11,7 @@ if (BuildParams.inFipsJvm){ tasks.named("javaRestTest").configure{enabled = false } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.monitoring.collection.enabled', 'true' diff --git a/x-pack/plugin/fleet/build.gradle b/x-pack/plugin/fleet/build.gradle index 432cfbce0eac..69cfbf084c28 100644 --- a/x-pack/plugin/fleet/build.gradle +++ b/x-pack/plugin/fleet/build.gradle @@ -23,7 +23,7 @@ dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.security.autoconfiguration.enabled', 'false' diff --git a/x-pack/plugin/fleet/qa/rest/build.gradle b/x-pack/plugin/fleet/qa/rest/build.gradle index a5e8c02f22be..8a9736c710b3 100644 --- a/x-pack/plugin/fleet/qa/rest/build.gradle +++ b/x-pack/plugin/fleet/qa/rest/build.gradle @@ -12,7 +12,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' } diff --git a/x-pack/plugin/graph/qa/with-security/build.gradle b/x-pack/plugin/graph/qa/with-security/build.gradle index 065ac82c8efb..cbe0c7740675 100644 --- a/x-pack/plugin/graph/qa/with-security/build.gradle +++ b/x-pack/plugin/graph/qa/with-security/build.gradle @@ -14,7 +14,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle b/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle index d69b0f9c5282..2640317e0ba1 100644 --- a/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle +++ b/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle @@ -7,7 +7,7 @@ dependencies { javaRestTestImplementation project(path: xpackModule('identity-provider')) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/ilm/qa/multi-cluster/build.gradle b/x-pack/plugin/ilm/qa/multi-cluster/build.gradle index f41c6e438336..73f26e6920e1 100644 --- a/x-pack/plugin/ilm/qa/multi-cluster/build.gradle +++ b/x-pack/plugin/ilm/qa/multi-cluster/build.gradle @@ -32,7 +32,7 @@ testClusters.matching { it.name == 'leader-cluster' }.configureEach { tasks.register('follow-cluster', RestIntegTestTask) { dependsOn tasks.findByName('leader-cluster') - useCluster testClusters.'leader-cluster' + useCluster testClusters.named('leader-cluster') systemProperty 'tests.target_cluster', 'follow' nonInputProperties.systemProperty 'tests.leader_host', "${-> testClusters."leader-cluster".getAllHttpSocketURI().get(0)}" diff --git a/x-pack/plugin/ilm/qa/multi-node/build.gradle b/x-pack/plugin/ilm/qa/multi-node/build.gradle index f42f51c30238..03fd419c2169 100644 --- a/x-pack/plugin/ilm/qa/multi-node/build.gradle +++ b/x-pack/plugin/ilm/qa/multi-node/build.gradle @@ -15,7 +15,7 @@ tasks.named("javaRestTest").configure { systemProperty 'es.rollup_v2_feature_flag_enabled', 'true' } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 4 diff --git a/x-pack/plugin/ilm/qa/with-security/build.gradle b/x-pack/plugin/ilm/qa/with-security/build.gradle index de42227495fb..29ec940ce600 100644 --- a/x-pack/plugin/ilm/qa/with-security/build.gradle +++ b/x-pack/plugin/ilm/qa/with-security/build.gradle @@ -5,7 +5,7 @@ dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.watcher.enabled', 'false' setting 'xpack.watcher.enabled', 'false' diff --git a/x-pack/plugin/logstash/build.gradle b/x-pack/plugin/logstash/build.gradle index cc693da2baa6..1ac4fb75be1c 100644 --- a/x-pack/plugin/logstash/build.gradle +++ b/x-pack/plugin/logstash/build.gradle @@ -17,7 +17,7 @@ dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' user username: 'x_pack_rest_user', password: 'x-pack-test-password', role: 'superuser' diff --git a/x-pack/plugin/ml/qa/basic-multi-node/build.gradle b/x-pack/plugin/ml/qa/basic-multi-node/build.gradle index 161179a72e1c..2234f5e43d51 100644 --- a/x-pack/plugin/ml/qa/basic-multi-node/build.gradle +++ b/x-pack/plugin/ml/qa/basic-multi-node/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.internal-java-rest-test' -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 3 setting 'xpack.security.enabled', 'false' diff --git a/x-pack/plugin/ml/qa/disabled/build.gradle b/x-pack/plugin/ml/qa/disabled/build.gradle index 7b10a37168ff..b0690460115d 100644 --- a/x-pack/plugin/ml/qa/disabled/build.gradle +++ b/x-pack/plugin/ml/qa/disabled/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'elasticsearch.internal-java-rest-test' // testImplementation project(path: xpackModule('ml')) //} -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.ml.enabled', 'false' diff --git a/x-pack/plugin/ml/qa/ml-with-security/build.gradle b/x-pack/plugin/ml/qa/ml-with-security/build.gradle index 0207b69ee997..9c53ed96f372 100644 --- a/x-pack/plugin/ml/qa/ml-with-security/build.gradle +++ b/x-pack/plugin/ml/qa/ml-with-security/build.gradle @@ -229,7 +229,7 @@ tasks.named("yamlRestTest").configure { ].join(',') } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' extraConfigFile 'roles.yml', file('roles.yml') user username: "x_pack_rest_user", password: "x-pack-test-password" diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle index b410a57ba376..73c288d3e0a5 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle @@ -28,7 +28,7 @@ tasks.named("javaRestTest").configure { dependsOn "copyKeyCerts" } -testClusters.all { +testClusters.configureEach { numberOfNodes = 3 testDistribution = 'DEFAULT' diff --git a/x-pack/plugin/ml/qa/single-node-tests/build.gradle b/x-pack/plugin/ml/qa/single-node-tests/build.gradle index e47693cdd262..2e7bbbbad298 100644 --- a/x-pack/plugin/ml/qa/single-node-tests/build.gradle +++ b/x-pack/plugin/ml/qa/single-node-tests/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.internal-java-rest-test' -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/repositories-metering-api/build.gradle b/x-pack/plugin/repositories-metering-api/build.gradle index 68431fd7096c..d258391662e3 100644 --- a/x-pack/plugin/repositories-metering-api/build.gradle +++ b/x-pack/plugin/repositories-metering-api/build.gradle @@ -14,7 +14,7 @@ dependencies { testImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle b/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle index 7f2d5947d0f3..66ccc9e2f03b 100644 --- a/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle @@ -48,7 +48,7 @@ if (useFixture) { testFixtures.useFixture(fixture.path, 'azure-fixture-repositories-metering') } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle b/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle index f1acbb023a54..5cb7fb308bf7 100644 --- a/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle @@ -50,7 +50,7 @@ if (!gcsServiceAccount && !gcsBucket && !gcsBasePath) { serviceAccountFile = new File(gcsServiceAccount) } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/x-pack/plugin/rollup/qa/rest/build.gradle b/x-pack/plugin/rollup/qa/rest/build.gradle index 9ab08ad5af84..4d5c23feb9d2 100644 --- a/x-pack/plugin/rollup/qa/rest/build.gradle +++ b/x-pack/plugin/rollup/qa/rest/build.gradle @@ -19,7 +19,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'basic' systemProperty 'es.rollup_v2_feature_flag_enabled', 'true' diff --git a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle index fd6894b0093a..e7a1ebd756c4 100644 --- a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle @@ -18,7 +18,7 @@ tasks.withType(Test).configureEach { systemProperty 'tests.path.repo', repoDir } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'path.repo', repoDir.absolutePath setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/security/qa/basic-enable-security/build.gradle b/x-pack/plugin/security/qa/basic-enable-security/build.gradle index c4cf97fd9ff2..cc35fbb7e523 100644 --- a/x-pack/plugin/security/qa/basic-enable-security/build.gradle +++ b/x-pack/plugin/security/qa/basic-enable-security/build.gradle @@ -25,21 +25,19 @@ if (BuildParams.inFipsJvm){ tasks.named("javaRestTest").configure{enabled = false } } -testClusters { - javaRestTest { +def cluster = testClusters.register("javaRestTest") { testDistribution = 'DEFAULT' numberOfNodes = 2 setting 'xpack.ml.enabled', 'false' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.security.enabled', 'false' - } } tasks.register("javaRestTestWithSecurityEnabled", StandaloneRestIntegTestTask) { mustRunAfter("javaRestTest") description = "Run tests against a cluster that has security enabled" dependsOn "javaRestTest" - useCluster testClusters.javaRestTest + useCluster cluster systemProperty 'tests.has_security', 'true' testClassesDirs = sourceSets.javaRestTest.output.classesDirs classpath = sourceSets.javaRestTest.runtimeClasspath @@ -47,7 +45,7 @@ tasks.register("javaRestTestWithSecurityEnabled", StandaloneRestIntegTestTask) { BuildParams.inFipsJvm == false } doFirst { - testClusters.javaRestTest { + cluster.configure { // TODO Rene: revisit if using dedicated new cluster definitions would be more efficient. // Reconfigure cluster to enable security setting 'xpack.security.enabled', 'true' @@ -68,8 +66,7 @@ tasks.register("javaRestTestWithSecurityEnabled", StandaloneRestIntegTestTask) { restart() } - nonInputProperties.systemProperty 'tests.rest.cluster', "${-> testClusters.javaRestTest.getAllHttpSocketURI().join(",")}" + nonInputProperties.systemProperty 'tests.rest.cluster', cluster.map(c->c.getAllHttpSocketURI().join(",")) } } tasks.named("check").configure { dependsOn("javaRestTestWithSecurityEnabled") } - diff --git a/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle b/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle index 062ca2d8d41a..f023e2ca2194 100644 --- a/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle +++ b/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle @@ -23,7 +23,7 @@ tasks.named("javaRestTest").configure { systemProperty 'tests.path.repo', repoDir } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 3 diff --git a/x-pack/plugin/security/qa/security-basic/build.gradle b/x-pack/plugin/security/qa/security-basic/build.gradle index 87ac8820ba0b..932e3fcedd96 100644 --- a/x-pack/plugin/security/qa/security-basic/build.gradle +++ b/x-pack/plugin/security/qa/security-basic/build.gradle @@ -13,7 +13,7 @@ if (BuildParams.inFipsJvm){ tasks.named("javaRestTest").configure{enabled = false } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 2 diff --git a/x-pack/plugin/security/qa/security-disabled/build.gradle b/x-pack/plugin/security/qa/security-disabled/build.gradle index 673a9ecd76f3..e1d850c4adb9 100644 --- a/x-pack/plugin/security/qa/security-disabled/build.gradle +++ b/x-pack/plugin/security/qa/security-disabled/build.gradle @@ -14,7 +14,7 @@ dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 2 diff --git a/x-pack/plugin/shutdown/build.gradle b/x-pack/plugin/shutdown/build.gradle index 4af5434ecf62..bcc2cb55a921 100644 --- a/x-pack/plugin/shutdown/build.gradle +++ b/x-pack/plugin/shutdown/build.gradle @@ -18,7 +18,7 @@ dependencies { addQaCheckDependencies() -testClusters.all { +testClusters.configureEach { testDistribution = 'default' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/shutdown/qa/multi-node/build.gradle b/x-pack/plugin/shutdown/qa/multi-node/build.gradle index 0f725b6a0b65..262bd12a7e4f 100644 --- a/x-pack/plugin/shutdown/qa/multi-node/build.gradle +++ b/x-pack/plugin/shutdown/qa/multi-node/build.gradle @@ -7,7 +7,7 @@ dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 4 } diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle index f07607f6736f..264bd9f0ef6c 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle @@ -48,7 +48,7 @@ if (useFixture) { testFixtures.useFixture(fixture.path, 'azure-fixture-repository-test-kit') } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } diff --git a/x-pack/plugin/spatial/build.gradle b/x-pack/plugin/spatial/build.gradle index 64b103d583ca..64457e820052 100644 --- a/x-pack/plugin/spatial/build.gradle +++ b/x-pack/plugin/spatial/build.gradle @@ -26,7 +26,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { setting 'xpack.license.self_generated.type', 'trial' testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' diff --git a/x-pack/plugin/sql/qa/jdbc/build.gradle b/x-pack/plugin/sql/qa/jdbc/build.gradle index 755621b7c4df..52562ff18ad9 100644 --- a/x-pack/plugin/sql/qa/jdbc/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/build.gradle @@ -59,7 +59,7 @@ subprojects { apply plugin: 'elasticsearch.internal-testclusters' apply plugin: 'elasticsearch.rest-test' - testClusters.all { + testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.ml.enabled', 'false' setting 'xpack.watcher.enabled', 'false' diff --git a/x-pack/plugin/sql/qa/jdbc/multi-node/build.gradle b/x-pack/plugin/sql/qa/jdbc/multi-node/build.gradle index 24d23b31f7c9..c25918337c07 100644 --- a/x-pack/plugin/sql/qa/jdbc/multi-node/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/multi-node/build.gradle @@ -1,6 +1,6 @@ description = 'Run SQL JDBC tests against multiple nodes' -testClusters.all { +testClusters.configureEach { numberOfNodes = 2 setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/sql/qa/jdbc/no-sql/build.gradle b/x-pack/plugin/sql/qa/jdbc/no-sql/build.gradle index 08a706b85e1f..7a741c4d04ca 100644 --- a/x-pack/plugin/sql/qa/jdbc/no-sql/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/no-sql/build.gradle @@ -1,4 +1,4 @@ -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/plugin/sql/qa/jdbc/security/build.gradle b/x-pack/plugin/sql/qa/jdbc/security/build.gradle index 917d319888cf..c70fe0a38f3b 100644 --- a/x-pack/plugin/sql/qa/jdbc/security/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/security/build.gradle @@ -17,7 +17,7 @@ subprojects { testArtifacts testArtifact(project(mainProject.path)) } - testClusters.all { + testClusters.configureEach { testDistribution = 'DEFAULT' // Setup auditing so we can use it in some tests setting 'xpack.security.audit.enabled', 'true' diff --git a/x-pack/plugin/sql/qa/jdbc/security/with-ssl/build.gradle b/x-pack/plugin/sql/qa/jdbc/security/with-ssl/build.gradle index 89c5d93ac3ee..172151b560b7 100644 --- a/x-pack/plugin/sql/qa/jdbc/security/with-ssl/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/security/with-ssl/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.test-with-ssl' -testClusters.all { +testClusters.configureEach { // The setup that we actually want setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.security.http.ssl.enabled', 'true' diff --git a/x-pack/plugin/sql/qa/jdbc/security/without-ssl/build.gradle b/x-pack/plugin/sql/qa/jdbc/security/without-ssl/build.gradle index a33b27be3a16..ef6c36e7849d 100644 --- a/x-pack/plugin/sql/qa/jdbc/security/without-ssl/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/security/without-ssl/build.gradle @@ -4,6 +4,6 @@ tasks.withType(RestIntegTestTask).configureEach { systemProperty 'tests.ssl.enabled', 'false' } -testClusters.all { +testClusters.configureEach { setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/plugin/sql/qa/jdbc/single-node/build.gradle b/x-pack/plugin/sql/qa/jdbc/single-node/build.gradle index 4222575cd94a..317e3391f9df 100644 --- a/x-pack/plugin/sql/qa/jdbc/single-node/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/single-node/build.gradle @@ -1,4 +1,4 @@ -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/plugin/sql/qa/mixed-node/build.gradle b/x-pack/plugin/sql/qa/mixed-node/build.gradle index 9965f433031a..98857b00500a 100644 --- a/x-pack/plugin/sql/qa/mixed-node/build.gradle +++ b/x-pack/plugin/sql/qa/mixed-node/build.gradle @@ -14,7 +14,7 @@ dependencies { testImplementation project(xpackModule('sql')) } -testClusters.all { +testClusters.configureEach { setting 'xpack.security.enabled', 'false' } @@ -27,11 +27,11 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.on continue; } - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersion - testClusters { - "${baseName}" { - versions = [bwcVersion.toString(), project.version] + def baseCluster = testClusters.register(baseName) { + versions = [bwcVersionString, project.version] numberOfNodes = 3 testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' @@ -40,21 +40,21 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.on setting 'xpack.license.self_generated.type', 'trial' // for debugging purposes // setting 'logger.org.elasticsearch.xpack.sql.plugin.TransportSqlQueryAction', 'TRACE' - } } tasks.register("${baseName}#mixedClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") doFirst { + def cluster = baseCluster.get() // Getting the endpoints causes a wait for the cluster - println "Endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" + println "Endpoints are: ${-> cluster.allHttpSocketURI.join(",")}" println "Upgrading one node to create a mixed cluster" - testClusters."${baseName}".nextNodeToNextVersion() + cluster.nextNodeToNextVersion() - println "Upgrade complete, endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + println "Upgrade complete, endpoints are: ${-> cluster.allHttpSocketURI.join(",")}" + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } onlyIf { project.bwc_tests_enabled } } diff --git a/x-pack/plugin/stack/qa/rest/build.gradle b/x-pack/plugin/stack/qa/rest/build.gradle index 3520020b8239..770a52fde68b 100644 --- a/x-pack/plugin/stack/qa/rest/build.gradle +++ b/x-pack/plugin/stack/qa/rest/build.gradle @@ -12,7 +12,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.ml.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle b/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle index 219ce40562c3..61e208b16762 100644 --- a/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle +++ b/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle @@ -19,7 +19,7 @@ restResources { tasks.named("yamlRestTest").configure { } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' extraConfigFile 'roles.yml', file('roles.yml') user username: "x_pack_rest_user", password: "x-pack-test-password" diff --git a/x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle b/x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle index b8e5b79e3d47..72fa66e43c17 100644 --- a/x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle +++ b/x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle @@ -16,8 +16,7 @@ restResources { } -testClusters { - 'remote-cluster' { +def remoteCluster = testClusters.register('remote-cluster') { testDistribution = 'DEFAULT' numberOfNodes = 2 setting 'node.roles', '[data,ingest,master]' @@ -26,9 +25,9 @@ testClusters { setting 'xpack.license.self_generated.type', 'trial' user username: "test_user", password: "x-pack-test-password" - } +} - 'mixed-cluster' { +testClusters.register('mixed-cluster') { testDistribution = 'DEFAULT' numberOfNodes = 2 // Node roles are configured this way in order to verify redirecting the transform request from the node lacking @@ -39,12 +38,11 @@ testClusters { setting 'xpack.watcher.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' setting 'cluster.remote.my_remote_cluster.seeds', { - testClusters.'remote-cluster'.getAllTransportPortURI().collect { "\"$it\"" }.toString() + remoteCluster.get().getAllTransportPortURI().collect { "\"$it\"" }.toString() } setting 'cluster.remote.connections_per_cluster', "1" user username: "test_user", password: "x-pack-test-password" - } } tasks.register('remote-cluster', RestIntegTestTask) { @@ -52,10 +50,9 @@ tasks.register('remote-cluster', RestIntegTestTask) { systemProperty 'tests.rest.suite', 'remote_cluster' } - tasks.register('mixed-cluster', RestIntegTestTask) { dependsOn 'remote-cluster' - useCluster testClusters.'remote-cluster' + useCluster remoteCluster systemProperty 'tests.rest.suite', 'multi_cluster' } diff --git a/x-pack/plugin/transform/qa/single-node-tests/build.gradle b/x-pack/plugin/transform/qa/single-node-tests/build.gradle index 5f90c0c8235b..c28d6561aebc 100644 --- a/x-pack/plugin/transform/qa/single-node-tests/build.gradle +++ b/x-pack/plugin/transform/qa/single-node-tests/build.gradle @@ -6,7 +6,7 @@ dependencies { javaRestTestImplementation project(path: xpackModule('transform')) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/vector-tile/build.gradle b/x-pack/plugin/vector-tile/build.gradle index 7feeccbdb8c3..3ce757288a9c 100644 --- a/x-pack/plugin/vector-tile/build.gradle +++ b/x-pack/plugin/vector-tile/build.gradle @@ -40,7 +40,7 @@ dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { setting 'xpack.license.self_generated.type', 'trial' testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' diff --git a/x-pack/plugin/watcher/qa/rest/build.gradle b/x-pack/plugin/watcher/qa/rest/build.gradle index 097c410f2856..cfb75b244aa5 100644 --- a/x-pack/plugin/watcher/qa/rest/build.gradle +++ b/x-pack/plugin/watcher/qa/rest/build.gradle @@ -21,7 +21,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.ml.enabled', 'false' diff --git a/x-pack/plugin/watcher/qa/with-monitoring/build.gradle b/x-pack/plugin/watcher/qa/with-monitoring/build.gradle index 1b824f349e11..b1f8d157394e 100644 --- a/x-pack/plugin/watcher/qa/with-monitoring/build.gradle +++ b/x-pack/plugin/watcher/qa/with-monitoring/build.gradle @@ -7,7 +7,7 @@ dependencies { javaRestTestImplementation project(path: ':x-pack:plugin:watcher:qa:common') } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.monitoring.collection.enabled', 'true' setting 'xpack.monitoring.collection.interval', '1s' diff --git a/x-pack/plugin/watcher/qa/with-security/build.gradle b/x-pack/plugin/watcher/qa/with-security/build.gradle index 20cfbc14de53..18864ae029a4 100644 --- a/x-pack/plugin/watcher/qa/with-security/build.gradle +++ b/x-pack/plugin/watcher/qa/with-security/build.gradle @@ -19,7 +19,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.ml.enabled', 'false' setting 'xpack.security.enabled', 'true' diff --git a/x-pack/qa/full-cluster-restart/build.gradle b/x-pack/qa/full-cluster-restart/build.gradle index 338a04aa1f6f..ccc75ea05c01 100644 --- a/x-pack/qa/full-cluster-restart/build.gradle +++ b/x-pack/qa/full-cluster-restart/build.gradle @@ -31,12 +31,12 @@ tasks.register("copyTestNodeKeyMaterial", Copy) { } for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { - String baseName = "v${bwcVersion}" + def bwcVersionString = bwcVersion.toString(); + String baseName = "v"+ bwcVersionString; - testClusters { - "${baseName}" { + def baseCluster = testClusters.register(baseName) { testDistribution = "DEFAULT" - versions = [bwcVersion.toString(), project.version] + versions = [bwcVersionString, project.version] numberOfNodes = 2 setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" user username: "test_user", password: "x-pack-test-password" @@ -59,13 +59,12 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode' setting 'xpack.security.authc.api_key.enabled', 'true' - } } tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) { mustRunAfter("precommit") - useCluster testClusters."${baseName}" - dependsOn copyTestNodeKeyMaterial + useCluster baseCluster + dependsOn "copyTestNodeKeyMaterial" doFirst { delete("${buildDir}/cluster/shared/repo/${baseName}") } @@ -77,10 +76,10 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) { mustRunAfter("precommit") - useCluster testClusters."${baseName}" + useCluster baseCluster dependsOn "${baseName}#oldClusterTest" doFirst { - testClusters."${baseName}".goToNextVersion() + testClusters.named(baseName).get().goToNextVersion() } systemProperty 'tests.is_old_cluster', 'false' exclude 'org/elasticsearch/upgrades/FullClusterRestartIT.class' @@ -88,12 +87,12 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { exclude 'org/elasticsearch/upgrades/QueryBuilderBWCIT.class' } - String oldVersion = bwcVersion.toString().minus("-SNAPSHOT") + String oldVersion = bwcVersionString.minus("-SNAPSHOT") tasks.matching { it.name.startsWith("${baseName}#") && it.name.endsWith("ClusterTest") }.configureEach { it.systemProperty 'tests.old_cluster_version', oldVersion it.systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}" - it.nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + it.nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(","))) + it.nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register(bwcTaskName(bwcVersion)) { diff --git a/x-pack/qa/mixed-tier-cluster/build.gradle b/x-pack/qa/mixed-tier-cluster/build.gradle index d8c4568b6b2f..2884e2df7f3c 100644 --- a/x-pack/qa/mixed-tier-cluster/build.gradle +++ b/x-pack/qa/mixed-tier-cluster/build.gradle @@ -19,38 +19,37 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.on continue; } - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersionString - testClusters { - "${baseName}" { - versions = [bwcVersion.toString(), project.version] - numberOfNodes = 3 - testDistribution = 'DEFAULT' - setting 'xpack.security.enabled', 'false' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' - nodes."${baseName}-0".setting 'node.roles', '["master"]' - // data_* roles were introduced in 7.10.0, so use 'data' for older versions - if (bwcVersion.before('7.10.0')) { - nodes."${baseName}-1".setting 'node.roles', '["data"]' - } else { - nodes."${baseName}-1".setting 'node.roles', '["data_content", "data_hot"]' - } - nodes."${baseName}-2".setting 'node.roles', '["master"]' + def baseCluster = testClusters.register(baseName) { + versions = [bwcVersionString, project.version] + numberOfNodes = 3 + testDistribution = 'DEFAULT' + setting 'xpack.security.enabled', 'false' + setting 'xpack.watcher.enabled', 'false' + setting 'xpack.ml.enabled', 'false' + setting 'xpack.license.self_generated.type', 'trial' + nodes."${baseName}-0".setting 'node.roles', '["master"]' + // data_* roles were introduced in 7.10.0, so use 'data' for older versions + if (bwcVersion.before('7.10.0')) { + nodes."${baseName}-1".setting 'node.roles', '["data"]' + } else { + nodes."${baseName}-1".setting 'node.roles', '["data_content", "data_hot"]' } + nodes."${baseName}-2".setting 'node.roles', '["master"]' } tasks.register("${baseName}#mixedClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") doFirst { // Getting the endpoints causes a wait for the cluster - println "Endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",")}" - testClusters."${baseName}".nextNodeToNextVersion() + println "Endpoints are: ${-> baseCluster.get().allHttpSocketURI.join(",")}" + baseCluster.get().nextNodeToNextVersion() - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } onlyIf { project.bwc_tests_enabled } } @@ -60,7 +59,6 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.on } } - // Security is explicitly disabled, do not run tests in FIPS mode tasks.withType(Test).configureEach { onlyIf { BuildParams.inFipsJvm == false} diff --git a/x-pack/qa/multi-cluster-search-security/build.gradle b/x-pack/qa/multi-cluster-search-security/build.gradle index dcc6e3f36e59..48da226f8efe 100644 --- a/x-pack/qa/multi-cluster-search-security/build.gradle +++ b/x-pack/qa/multi-cluster-search-security/build.gradle @@ -24,44 +24,42 @@ tasks.register('remote-cluster', RestIntegTestTask) { // randomise between sniff and proxy modes boolean proxyMode = (new Random(Long.parseUnsignedLong(BuildParams.testSeed.tokenize(':').get(0), 16))).nextBoolean() -testClusters { - 'remote-cluster' { - testDistribution = 'DEFAULT' - numberOfNodes = 2 - setting 'node.roles', '[data,ingest,master]' - setting 'xpack.security.enabled', 'true' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' +def remoteCluster = testClusters.register('remote-cluster') { + testDistribution = 'DEFAULT' + numberOfNodes = 2 + setting 'node.roles', '[data,ingest,master]' + setting 'xpack.security.enabled', 'true' + setting 'xpack.watcher.enabled', 'false' + setting 'xpack.ml.enabled', 'false' + setting 'xpack.license.self_generated.type', 'trial' - user username: "test_user", password: "x-pack-test-password" - } + user username: "test_user", password: "x-pack-test-password" +} - 'mixed-cluster' { - testDistribution = 'DEFAULT' - setting 'xpack.security.enabled', 'true' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' - if (proxyMode) { - setting 'cluster.remote.my_remote_cluster.mode', 'proxy' - setting 'cluster.remote.my_remote_cluster.proxy_address', { - "\"${testClusters.'remote-cluster'.getAllTransportPortURI().get(0)}\"" - } - } else { - setting 'cluster.remote.my_remote_cluster.seeds', { - testClusters.'remote-cluster'.getAllTransportPortURI().collect { "\"$it\"" }.toString() - } +def mixedCluster = testClusters.register('mixed-cluster') { + testDistribution = 'DEFAULT' + setting 'xpack.security.enabled', 'true' + setting 'xpack.watcher.enabled', 'false' + setting 'xpack.ml.enabled', 'false' + setting 'xpack.license.self_generated.type', 'trial' + if (proxyMode) { + setting 'cluster.remote.my_remote_cluster.mode', 'proxy' + setting 'cluster.remote.my_remote_cluster.proxy_address', { + "\"${remoteCluster.get().getAllTransportPortURI().get(0)}\"" + } + } else { + setting 'cluster.remote.my_remote_cluster.seeds', { + remoteCluster.get().getAllTransportPortURI().collect { "\"$it\"" }.toString() } - setting 'cluster.remote.connections_per_cluster', "1" - - user username: "test_user", password: "x-pack-test-password" } + setting 'cluster.remote.connections_per_cluster', "1" + + user username: "test_user", password: "x-pack-test-password" } tasks.register('mixed-cluster', RestIntegTestTask) { dependsOn 'remote-cluster' - useCluster testClusters.'remote-cluster' + useCluster remoteCluster systemProperty 'tests.rest.suite', 'multi_cluster' if (proxyMode) { systemProperty 'tests.rest.blacklist', [ diff --git a/x-pack/qa/rolling-upgrade-basic/build.gradle b/x-pack/qa/rolling-upgrade-basic/build.gradle index 037e92992fe9..d02c652b4482 100644 --- a/x-pack/qa/rolling-upgrade-basic/build.gradle +++ b/x-pack/qa/rolling-upgrade-basic/build.gradle @@ -11,40 +11,39 @@ dependencies { } for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersionString - testClusters { - "${baseName}" { - testDistribution = "DEFAULT" - versions = [bwcVersion.toString(), project.version] - numberOfNodes = 3 + def baseCluster = testClusters.register(baseName) { + testDistribution = "DEFAULT" + versions = [bwcVersionString, project.version] + numberOfNodes = 3 - setting 'repositories.url.allowed_urls', 'http://snapshot.test*' - setting 'xpack.security.enabled', 'false' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.license.self_generated.type', 'basic' - } + setting 'repositories.url.allowed_urls', 'http://snapshot.test*' + setting 'xpack.security.enabled', 'false' + setting 'xpack.ml.enabled', 'false' + setting 'xpack.watcher.enabled', 'false' + setting 'xpack.license.self_generated.type', 'basic' } tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") systemProperty 'tests.rest.suite', 'old_cluster' systemProperty 'tests.upgrade_from_version', version.toString().replace('-SNAPSHOT', '') - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } - String oldVersion = bwcVersion.toString().replace('-SNAPSHOT', '') + String oldVersion = bwcVersionString.replace('-SNAPSHOT', '') tasks.register("${baseName}#oneThirdUpgradedTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oldClusterTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) systemProperty 'tests.rest.suite', 'mixed_cluster' systemProperty 'tests.first_round', 'true' systemProperty 'tests.upgrade_from_version', oldVersion @@ -52,12 +51,12 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { tasks.register("${baseName}#twoThirdsUpgradedTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oneThirdUpgradedTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) systemProperty 'tests.rest.suite', 'mixed_cluster' systemProperty 'tests.first_round', 'false' systemProperty 'tests.upgrade_from_version', oldVersion @@ -65,12 +64,12 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#twoThirdsUpgradedTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) systemProperty 'tests.rest.suite', 'upgraded_cluster' systemProperty 'tests.upgrade_from_version', oldVersion } diff --git a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle index 4d78bc32880c..efddd145167e 100644 --- a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle +++ b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle @@ -11,19 +11,18 @@ dependencies { } for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersionString - testClusters { - "${baseName}-leader" { + def baseLeaderCluster = testClusters.register("${baseName}-leader") { numberOfNodes = 3 - } - "${baseName}-follower" { - numberOfNodes = 3 - } + } + def baseFollowerCluster = testClusters.register("${baseName}-follower") { + numberOfNodes = 3 } testClusters.matching { it.name.startsWith("${baseName}-") }.configureEach { testDistribution = "DEFAULT" - versions = [bwcVersion.toString(), project.version] + versions = [bwcVersionString, project.version] setting 'repositories.url.allowed_urls', 'http://snapshot.test*' setting 'xpack.security.enabled', 'false' @@ -33,21 +32,22 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { } tasks.withType(StandaloneRestIntegTestTask).matching { it.name.startsWith("${baseName}#") }.configureEach { - useCluster testClusters."${baseName}-leader" - useCluster testClusters."${baseName}-follower" - systemProperty 'tests.upgrade_from_version', bwcVersion.toString().replace('-SNAPSHOT', '') + useCluster baseLeaderCluster + useCluster baseFollowerCluster + systemProperty 'tests.upgrade_from_version', bwcVersionString.replace('-SNAPSHOT', '') doFirst { + def baseCluster = testClusters.named("${baseName}-${kindExt}").get() if (name.endsWith("#clusterTest") == false) { println "Upgrade node $it" - testClusters."${baseName}-${kindExt}".nextNodeToNextVersion() + baseCluster.nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}-${kindExt}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}-${kindExt}".getName()}") - nonInputProperties.systemProperty('tests.leader_host', "${-> testClusters."${baseName}-leader".allHttpSocketURI.last()}") - nonInputProperties.systemProperty('tests.leader_remote_cluster_seed', "${-> testClusters."${baseName}-leader".allTransportPortURI.last()}") - nonInputProperties.systemProperty('tests.follower_host', "${-> testClusters."${baseName}-follower".allHttpSocketURI.last()}") - nonInputProperties.systemProperty('tests.follower_remote_cluster_seed', "${-> testClusters."${baseName}-follower".allTransportPortURI.last()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.allHttpSocketURI.join(",")) + nonInputProperties.systemProperty('tests.clustername', baseName) + nonInputProperties.systemProperty('tests.leader_host', baseLeaderCluster.map(c->c.allHttpSocketURI.last())) + nonInputProperties.systemProperty('tests.leader_remote_cluster_seed', baseLeaderCluster.map(c -> c.allTransportPortURI.last())) + nonInputProperties.systemProperty('tests.follower_host', baseFollowerCluster.map(c -> c.allHttpSocketURI.last())) + nonInputProperties.systemProperty('tests.follower_remote_cluster_seed', baseFollowerCluster.map(c -> c.allTransportPortURI.last())) } } diff --git a/x-pack/qa/rolling-upgrade/build.gradle b/x-pack/qa/rolling-upgrade/build.gradle index ba070adc2b20..186e8042a0f0 100644 --- a/x-pack/qa/rolling-upgrade/build.gradle +++ b/x-pack/qa/rolling-upgrade/build.gradle @@ -31,72 +31,71 @@ tasks.register("copyTestNodeKeyMaterial", Copy) { } for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { - String baseName = "v${bwcVersion}" + String bwcVersionString = bwcVersion.toString() + String baseName = "v" + bwcVersionString // SearchableSnapshotsRollingUpgradeIT uses a specific repository to not interfere with other tests String searchableSnapshotRepository = "${buildDir}/cluster/shared/searchable-snapshots-repo/${baseName}" - testClusters { - "${baseName}" { - testDistribution = "DEFAULT" - versions = [bwcVersion.toString(), project.version] - numberOfNodes = 3 + def baseCluster = testClusters.register(baseName) { + testDistribution = "DEFAULT" + versions = [bwcVersionString, project.version] + numberOfNodes = 3 - setting 'repositories.url.allowed_urls', 'http://snapshot.test*' - setting 'path.repo', "['${buildDir}/cluster/shared/repo/${baseName}', '${searchableSnapshotRepository}']" - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - setting 'xpack.security.transport.ssl.enabled', 'true' - setting 'xpack.security.authc.token.enabled', 'true' - setting 'xpack.security.authc.token.timeout', '60m' - setting 'xpack.security.authc.api_key.enabled', 'true' - setting 'xpack.security.audit.enabled', 'true' - setting 'xpack.security.transport.ssl.key', 'testnode.pem' - setting 'xpack.security.transport.ssl.certificate', 'testnode.crt' - keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode' + setting 'repositories.url.allowed_urls', 'http://snapshot.test*' + setting 'path.repo', "['${buildDir}/cluster/shared/repo/${baseName}', '${searchableSnapshotRepository}']" + setting 'xpack.license.self_generated.type', 'trial' + setting 'xpack.security.enabled', 'true' + setting 'xpack.security.transport.ssl.enabled', 'true' + setting 'xpack.security.authc.token.enabled', 'true' + setting 'xpack.security.authc.token.timeout', '60m' + setting 'xpack.security.authc.api_key.enabled', 'true' + setting 'xpack.security.audit.enabled', 'true' + setting 'xpack.security.transport.ssl.key', 'testnode.pem' + setting 'xpack.security.transport.ssl.certificate', 'testnode.crt' + keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode' - if (bwcVersion.onOrAfter('7.0.0')) { - setting 'xpack.security.authc.realms.file.file1.order', '0' - setting 'xpack.security.authc.realms.native.native1.order', '1' - } else { - setting 'xpack.security.authc.realms.file1.type', 'file' - setting 'xpack.security.authc.realms.file1.order', '0' - setting 'xpack.security.authc.realms.native1.type', 'native' - setting 'xpack.security.authc.realms.native1.order', '1' - } - if (bwcVersion.onOrAfter('6.6.0')) { - setting 'ccr.auto_follow.wait_for_metadata_timeout', '1s' - } + if (bwcVersion.onOrAfter('7.0.0')) { + setting 'xpack.security.authc.realms.file.file1.order', '0' + setting 'xpack.security.authc.realms.native.native1.order', '1' + } else { + setting 'xpack.security.authc.realms.file1.type', 'file' + setting 'xpack.security.authc.realms.file1.order', '0' + setting 'xpack.security.authc.realms.native1.type', 'native' + setting 'xpack.security.authc.realms.native1.order', '1' + } + if (bwcVersion.onOrAfter('6.6.0')) { + setting 'ccr.auto_follow.wait_for_metadata_timeout', '1s' + } - user username: "test_user", password: "x-pack-test-password" + user username: "test_user", password: "x-pack-test-password" - extraConfigFile 'testnode.pem', file("$outputDir/testnode.pem") - extraConfigFile 'testnode.crt', file("$outputDir/testnode.crt") + extraConfigFile 'testnode.pem', file("$outputDir/testnode.pem") + extraConfigFile 'testnode.crt', file("$outputDir/testnode.crt") - keystore 'xpack.watcher.encryption_key', file("${project.projectDir}/src/test/resources/system_key") - setting 'xpack.watcher.encrypt_sensitive_data', 'true' + keystore 'xpack.watcher.encryption_key', file("${project.projectDir}/src/test/resources/system_key") + setting 'xpack.watcher.encrypt_sensitive_data', 'true' - // Old versions of the code contain an invalid assertion that trips - // during tests. Versions 5.6.9 and 6.2.4 have been fixed by removing - // the assertion, but this is impossible for released versions. - // However, released versions run without assertions, so end users won't - // be suffering the effects. This argument effectively removes the - // incorrect assertion from the older versions used in the BWC tests. - if (bwcVersion.before('5.6.9') || (bwcVersion.onOrAfter('6.0.0') && bwcVersion.before('6.2.4'))) { - jvmArgs '-da:org.elasticsearch.xpack.monitoring.exporter.http.HttpExportBulk' - } - setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG' + // Old versions of the code contain an invalid assertion that trips + // during tests. Versions 5.6.9 and 6.2.4 have been fixed by removing + // the assertion, but this is impossible for released versions. + // However, released versions run without assertions, so end users won't + // be suffering the effects. This argument effectively removes the + // incorrect assertion from the older versions used in the BWC tests. + if (bwcVersion.before('5.6.9') || (bwcVersion.onOrAfter('6.0.0') && bwcVersion.before('6.2.4'))) { + jvmArgs '-da:org.elasticsearch.xpack.monitoring.exporter.http.HttpExportBulk' + } + setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG' - if (bwcVersion.onOrAfter('7.12.0')) { - setting 'xpack.searchable.snapshot.shared_cache.size', '10mb' - } + if (bwcVersion.onOrAfter('7.12.0')) { + setting 'xpack.searchable.snapshot.shared_cache.size', '10mb' } } - String oldVersion = bwcVersion.toString() + String oldVersion = bwcVersionString tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}" + useCluster baseCluster mustRunAfter("precommit") dependsOn "copyTestNodeKeyMaterial" doFirst { @@ -107,18 +106,18 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { systemProperty 'tests.rest.suite', 'old_cluster' systemProperty 'tests.upgrade_from_version', oldVersion systemProperty 'tests.path.searchable.snapshots.repo', searchableSnapshotRepository - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) } tasks.register("${baseName}#oneThirdUpgradedTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oldClusterTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(","))) + nonInputProperties.systemProperty('tests.clustername', baseName) systemProperty 'tests.rest.suite', 'mixed_cluster' systemProperty 'tests.first_round', 'true' systemProperty 'tests.upgrade_from_version', oldVersion @@ -141,12 +140,12 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { tasks.register("${baseName}#twoThirdsUpgradedTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#oneThirdUpgradedTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', "${-> baseCluster.get().allHttpSocketURI.join(",")}") + nonInputProperties.systemProperty('tests.clustername', baseName) systemProperty 'tests.rest.suite', 'mixed_cluster' systemProperty 'tests.first_round', 'false' systemProperty 'tests.upgrade_from_version', oldVersion @@ -155,12 +154,12 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) { dependsOn "${baseName}#twoThirdsUpgradedTest" - useCluster testClusters."${baseName}" + useCluster baseCluster doFirst { - testClusters."${baseName}".nextNodeToNextVersion() + baseCluster.get().nextNodeToNextVersion() } - nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") - nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") + nonInputProperties.systemProperty('tests.rest.cluster', "${-> baseCluster.get().allHttpSocketURI.join(",")}") + nonInputProperties.systemProperty('tests.clustername', baseName) systemProperty 'tests.rest.suite', 'upgraded_cluster' systemProperty 'tests.upgrade_from_version', oldVersion systemProperty 'tests.path.searchable.snapshots.repo', searchableSnapshotRepository diff --git a/x-pack/qa/runtime-fields/with-security/build.gradle b/x-pack/qa/runtime-fields/with-security/build.gradle index ab19b6eb3392..659c4f57f9c2 100644 --- a/x-pack/qa/runtime-fields/with-security/build.gradle +++ b/x-pack/qa/runtime-fields/with-security/build.gradle @@ -5,7 +5,7 @@ dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.watcher.enabled', 'false' setting 'xpack.ml.enabled', 'false' diff --git a/x-pack/qa/security-example-spi-extension/build.gradle b/x-pack/qa/security-example-spi-extension/build.gradle index f1d6404ecb7d..0bafd3f46bff 100644 --- a/x-pack/qa/security-example-spi-extension/build.gradle +++ b/x-pack/qa/security-example-spi-extension/build.gradle @@ -18,7 +18,7 @@ dependencies { javaRestTestImplementation project.sourceSets.main.runtimeClasspath } -testClusters.all { +testClusters.configureEach { // This is important, so that all the modules are available too. // There are index templates that use token filters that are in analysis-module and // processors are being used that are in ingest-common module. diff --git a/x-pack/qa/security-setup-password-tests/build.gradle b/x-pack/qa/security-setup-password-tests/build.gradle index 4c94bf0e4a52..deb13e014240 100644 --- a/x-pack/qa/security-setup-password-tests/build.gradle +++ b/x-pack/qa/security-setup-password-tests/build.gradle @@ -8,7 +8,7 @@ dependencies { } tasks.named("integTest").configure { - nonInputProperties.systemProperty 'tests.config.dir', "${-> testClusters.integTest.singleNode().getConfigDir()}" + nonInputProperties.systemProperty 'tests.config.dir', testClusters.named("integTest").map(c -> c.singleNode().getConfigDir()) systemProperty 'tests.security.manager', 'false' } diff --git a/x-pack/qa/smoke-test-security-with-mustache/build.gradle b/x-pack/qa/smoke-test-security-with-mustache/build.gradle index 2e9276d27272..67d01d251a23 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/build.gradle +++ b/x-pack/qa/smoke-test-security-with-mustache/build.gradle @@ -13,7 +13,7 @@ restResources { } } -testClusters.all { +testClusters.configureEach { testDistribution = 'DEFAULT' setting 'xpack.watcher.enabled', 'false' setting 'xpack.security.enabled', 'true'