From 97749a3372f584e812bb06c5e96bdcc1c8a8a7dc Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Thu, 26 Nov 2020 10:30:06 +0100 Subject: [PATCH] Port rest integ tests to use task avoidance api (#65011) This ports the majority of the rest integ tests tasks to use the task avoidance api. - There are some edge cases left that we need to investigate, but we can do that separately. --- build.gradle | 5 +-- .../gradle/doc/DocsTestPlugin.groovy | 4 +-- .../gradle/test/RestTestPlugin.groovy | 10 +++--- .../gradle/test/rest/RestResourcesPlugin.java | 20 +++++++----- .../gradle/test/rest/YamlRestTestPlugin.java | 14 ++++++--- .../testclusters/TestClustersAware.java | 1 - .../gradle/util/GradleUtils.java | 10 +++--- docs/build.gradle | 28 ++++++++--------- plugins/repository-hdfs/build.gradle | 2 +- qa/die-with-dignity/build.gradle | 4 +-- qa/logging-config/build.gradle | 4 +-- qa/smoke-test-ingest-disabled/build.gradle | 2 +- qa/smoke-test-multinode/build.gradle | 4 +-- qa/smoke-test-plugins/build.gradle | 2 +- qa/unconfigured-node-name/build.gradle | 4 +-- rest-api-spec/build.gradle | 4 +-- x-pack/docs/build.gradle | 2 +- .../plugin/deprecation/qa/rest/build.gradle | 2 +- .../plugin/ilm/qa/multi-cluster/build.gradle | 31 ++++++++++--------- x-pack/plugin/ilm/qa/multi-node/build.gradle | 2 +- .../qa/azure/build.gradle | 2 +- .../qa/gcs/build.gradle | 2 +- .../qa/s3/build.gradle | 2 +- x-pack/plugin/rollup/qa/rest/build.gradle | 19 ++++++------ .../qa/azure/build.gradle | 2 +- .../searchable-snapshots/qa/gcs/build.gradle | 2 +- .../qa/minio/build.gradle | 2 +- .../searchable-snapshots/qa/rest/build.gradle | 2 +- .../searchable-snapshots/qa/s3/build.gradle | 2 +- x-pack/plugin/sql/qa/server/build.gradle | 2 +- .../sql/qa/server/multi-node/build.gradle | 2 +- .../sql/qa/server/security/build.gradle | 2 +- .../qa/server/security/with-ssl/build.gradle | 2 +- .../server/security/without-ssl/build.gradle | 2 +- .../sql/qa/server/single-node/build.gradle | 2 +- .../build.gradle | 2 +- x-pack/qa/kerberos-tests/build.gradle | 2 +- x-pack/qa/multi-node/build.gradle | 2 +- .../password-protected-keystore/build.gradle | 2 +- .../reindex-tests-with-security/build.gradle | 2 +- .../build.gradle | 2 +- x-pack/qa/saml-idp-tests/build.gradle | 2 +- .../build.gradle | 4 +-- x-pack/qa/smoke-test-plugins-ssl/build.gradle | 2 +- x-pack/qa/smoke-test-plugins/build.gradle | 2 +- .../build.gradle | 2 +- x-pack/qa/third-party/jira/build.gradle | 2 +- x-pack/qa/third-party/pagerduty/build.gradle | 2 +- x-pack/qa/third-party/slack/build.gradle | 2 +- 49 files changed, 122 insertions(+), 110 deletions(-) diff --git a/build.gradle b/build.gradle index cc246b1994372..4a7952374e44d 100644 --- a/build.gradle +++ b/build.gradle @@ -287,9 +287,10 @@ gradle.projectsEvaluated { // :test:framework:test cannot run before and after :server:test return } - if (tasks.findByPath('test') != null && tasks.findByPath('integTest') != null) { - integTest.mustRunAfter test + tasks.matching {it.name.equals('integTest')}.configureEach {integTestTask -> + integTestTask.mustRunAfter tasks.matching { it.name.equals("test") } } + configurations.matching { it.canBeResolved }.all { Configuration configuration -> dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep -> Project upstreamProject = dep.dependencyProject diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index ab57ccf5c4722..496c5e13f4db9 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -39,8 +39,8 @@ class DocsTestPlugin implements Plugin { String distribution = System.getProperty('tests.distribution', 'default') // The distribution can be configured with -Dtests.distribution on the command line - project.testClusters.integTest.testDistribution = distribution.toUpperCase() - project.testClusters.integTest.nameCustomization = { it.replace("integTest", "node") } + project.testClusters.matching { it.name.equals("integTest") }.configureEach { testDistribution = distribution.toUpperCase() } + project.testClusters.matching { it.name.equals("integTest") }.configureEach { nameCustomization = { it.replace("integTest", "node") } } // Docs are published separately so no need to assemble project.tasks.named("assemble").configure {enabled = false } Map commonDefaultSubstitutions = [ diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy index a499655f18b81..55502a314bb82 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy @@ -25,6 +25,7 @@ import org.gradle.api.InvalidUserDataException import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaBasePlugin +import org.gradle.api.tasks.TaskProvider /** * Adds support for starting an Elasticsearch cluster before running integration @@ -47,10 +48,11 @@ class RestTestPlugin implements Plugin { } project.getPlugins().apply(RestTestBasePlugin.class); project.pluginManager.apply(TestClustersPlugin) - RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class) - integTest.description = 'Runs rest tests against an elasticsearch cluster.' - integTest.group = JavaBasePlugin.VERIFICATION_GROUP - integTest.mustRunAfter(project.tasks.named('precommit')) + TaskProvider integTest = project.tasks.register('integTest', RestIntegTestTask.class) { + it.description = 'Runs rest tests against an elasticsearch cluster.' + it.group = JavaBasePlugin.VERIFICATION_GROUP + it.mustRunAfter(project.tasks.named('precommit')) + } project.tasks.named('check').configure { it.dependsOn(integTest) } } } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/RestResourcesPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/RestResourcesPlugin.java index f7d71d0cb92e0..7f46874c8a0b2 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/RestResourcesPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/RestResourcesPlugin.java @@ -24,12 +24,14 @@ import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; +import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import java.util.Map; +import static org.gradle.api.tasks.SourceSet.TEST_SOURCE_SET_NAME; + /** *

* Gradle plugin to help configure {@link CopyRestApiTask}'s and {@link CopyRestTestsTask} that copies the artifacts needed for the Rest API @@ -100,7 +102,7 @@ public void apply(Project project) { task.includeCore.set(extension.restTests.getIncludeCore()); task.includeXpack.set(extension.restTests.getIncludeXpack()); task.coreConfig = testConfig; - task.sourceSetName = SourceSet.TEST_SOURCE_SET_NAME; + task.sourceSetName = TEST_SOURCE_SET_NAME; if (BuildParams.isInternal()) { // core Dependency restTestdependency = project.getDependencies() @@ -131,7 +133,7 @@ public void apply(Project project) { task.includeXpack.set(extension.restApi.getIncludeXpack()); task.dependsOn(copyRestYamlTestTask); task.coreConfig = specConfig; - task.sourceSetName = SourceSet.TEST_SOURCE_SET_NAME; + task.sourceSetName = TEST_SOURCE_SET_NAME; if (BuildParams.isInternal()) { Dependency restSpecDependency = project.getDependencies() .project(Map.of("path", ":rest-api-spec", "configuration", "restSpecs")); @@ -149,12 +151,14 @@ public void apply(Project project) { task.dependsOn(xpackSpecConfig); }); - project.afterEvaluate(p -> { + project.getPlugins().withType(JavaBasePlugin.class).configureEach(javaBasePlugin -> { SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet testSourceSet = sourceSets.findByName(SourceSet.TEST_SOURCE_SET_NAME); - if (testSourceSet != null) { - project.getTasks().named(testSourceSet.getProcessResourcesTaskName()).configure(t -> t.dependsOn(copyRestYamlSpecTask)); - } + sourceSets.matching(sourceSet -> sourceSet.getName().equals(TEST_SOURCE_SET_NAME)) + .configureEach( + testSourceSet -> project.getTasks() + .named(testSourceSet.getProcessResourcesTaskName()) + .configure(t -> t.dependsOn(copyRestYamlSpecTask)) + ); }); } } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/YamlRestTestPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/YamlRestTestPlugin.java index 7f4f974c6c193..8fc6c9e4311ff 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/YamlRestTestPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/YamlRestTestPlugin.java @@ -64,11 +64,15 @@ public void apply(Project project) { setupDependencies(project, yamlTestSourceSet); // setup the copy for the rest resources - project.getTasks().withType(CopyRestApiTask.class, copyRestApiTask -> { - copyRestApiTask.sourceSetName = SOURCE_SET_NAME; - project.getTasks().named(yamlTestSourceSet.getProcessResourcesTaskName()).configure(t -> t.dependsOn(copyRestApiTask)); - }); - project.getTasks().withType(CopyRestTestsTask.class, copyRestTestTask -> { copyRestTestTask.sourceSetName = SOURCE_SET_NAME; }); + project.getTasks() + .withType(CopyRestApiTask.class) + .configureEach(copyRestApiTask -> { copyRestApiTask.sourceSetName = SOURCE_SET_NAME; }); + project.getTasks() + .named(yamlTestSourceSet.getProcessResourcesTaskName()) + .configure(t -> t.dependsOn(project.getTasks().withType(CopyRestApiTask.class))); + project.getTasks() + .withType(CopyRestTestsTask.class) + .configureEach(copyRestTestTask -> copyRestTestTask.sourceSetName = SOURCE_SET_NAME); // setup IDE GradleUtils.setupIdeForTestSourceSet(project, yamlTestSourceSet); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java index e288b31e43496..c36b3eda603a5 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java @@ -44,5 +44,4 @@ default void useCluster(ElasticsearchCluster cluster) { } default void beforeStart() {} - } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java b/buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java index 48619a5ed42e1..b0bf20bb65c82 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java @@ -200,12 +200,14 @@ public static void extendSourceSet(Project project, String parentSourceSetName, * Extends one configuration from another and refreshes the classpath of a provided Test. * The Test parameter is only needed for eagerly defined test tasks. */ - public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName, Test test) { + public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName, TaskProvider test) { extendSourceSet(project, parentSourceSetName, childSourceSetName); if (test != null) { - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet child = sourceSets.getByName(childSourceSetName); - test.setClasspath(child.getRuntimeClasspath()); + test.configure(t -> { + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); + SourceSet child = sourceSets.getByName(childSourceSetName); + t.setClasspath(child.getRuntimeClasspath()); + }); } } diff --git a/docs/build.gradle b/docs/build.gradle index 31241f0c3782c..7518bc59e91de 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -48,7 +48,7 @@ restResources { } } -testClusters.integTest { +testClusters.matching { it.name == "integTest"}.configureEach { if (singleNode().testDistribution == DEFAULT) { setting 'xpack.license.self_generated.type', 'trial' setting 'indices.lifecycle.history_index_enabled', 'false' @@ -82,21 +82,21 @@ testClusters.integTest { // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0 systemProperty 'es.transport.cname_in_publish_address', 'true' -} -// build the cluster with all plugins -project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj -> - /* Skip repositories. We just aren't going to be able to test them so it - * doesn't make sense to waste time installing them. - */ - if (subproj.path.startsWith(':plugins:repository-')) { - return - } - // Do not install ingest-attachment in a FIPS 140 JVM as this is not supported - if (subproj.path.startsWith(':plugins:ingest-attachment') && BuildParams.inFipsJvm) { - return + // build the cluster with all plugins + project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj -> + /* Skip repositories. We just aren't going to be able to test them so it + * doesn't make sense to waste time installing them. + */ + if (subproj.path.startsWith(':plugins:repository-')) { + return + } + // Do not install ingest-attachment in a FIPS 140 JVM as this is not supported + if (subproj.path.startsWith(':plugins:ingest-attachment') && BuildParams.inFipsJvm) { + return + } + plugin subproj.path } - testClusters.integTest.plugin subproj.path } buildRestTests.docs = fileTree(projectDir) { diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 3ae6ca3028243..6d752dee50599 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -99,7 +99,7 @@ tasks.named("integTest").configure { dependsOn(project.tasks.named("bundlePlugin")) } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { plugin(project.tasks.bundlePlugin.archiveFile) } diff --git a/qa/die-with-dignity/build.gradle b/qa/die-with-dignity/build.gradle index 7a612e4553ad8..ada0bed05f3f4 100644 --- a/qa/die-with-dignity/build.gradle +++ b/qa/die-with-dignity/build.gradle @@ -10,9 +10,9 @@ esplugin { } // let the javaRestTest see the classpath of main -GradleUtils.extendSourceSet(project, "main", "javaRestTest", javaRestTest) +GradleUtils.extendSourceSet(project, "main", "javaRestTest", tasks.named("javaRestTest")) -javaRestTest { +tasks.named("javaRestTest").configure { systemProperty 'tests.security.manager', 'false' systemProperty 'tests.system_call_filter', 'false' nonInputProperties.systemProperty 'log', "${-> testClusters.javaRestTest.singleNode().getServerLog()}" diff --git a/qa/logging-config/build.gradle b/qa/logging-config/build.gradle index 16b67ca83369e..f5782ad254d9d 100644 --- a/qa/logging-config/build.gradle +++ b/qa/logging-config/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.standalone-test' -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { /** * Provide a custom log4j configuration where layout is an old style pattern and confirm that Elasticsearch * can successfully startup. @@ -33,7 +33,7 @@ testClusters.integTest { integTest { nonInputProperties.systemProperty 'tests.logfile', "${-> testClusters.integTest.singleNode().getServerLog().absolutePath.replaceAll("_server.json", ".log")}" - + nonInputProperties.systemProperty 'tests.jsonLogfile', "${-> testClusters.integTest.singleNode().getServerLog()}" } diff --git a/qa/smoke-test-ingest-disabled/build.gradle b/qa/smoke-test-ingest-disabled/build.gradle index 441e0f2328bb9..b8f8d04a210f2 100644 --- a/qa/smoke-test-ingest-disabled/build.gradle +++ b/qa/smoke-test-ingest-disabled/build.gradle @@ -26,6 +26,6 @@ dependencies { testImplementation project(':modules:ingest-common') } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { setting 'node.roles', '[data,master,remote_cluster_client]' } diff --git a/qa/smoke-test-multinode/build.gradle b/qa/smoke-test-multinode/build.gradle index b72402c73128f..a9d854cc473b3 100644 --- a/qa/smoke-test-multinode/build.gradle +++ b/qa/smoke-test-multinode/build.gradle @@ -29,12 +29,12 @@ restResources { } File repo = file("$buildDir/testclusters/repo") -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { numberOfNodes = 2 setting 'path.repo', repo.absolutePath } -integTest { +tasks.named("integTest").configure { doFirst { project.delete(repo) repo.mkdirs() diff --git a/qa/smoke-test-plugins/build.gradle b/qa/smoke-test-plugins/build.gradle index e7a0e753fc7a4..309b5d38e7a42 100644 --- a/qa/smoke-test-plugins/build.gradle +++ b/qa/smoke-test-plugins/build.gradle @@ -27,7 +27,7 @@ apply plugin: 'elasticsearch.rest-resources' int pluginsCount = 0 -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { project(':plugins').getChildProjects().each { pluginName, pluginProject -> if (BuildParams.inFipsJvm && pluginName == "ingest-attachment") { // Do not attempt to install ingest-attachment in FIPS 140 as it is not supported (it depends on non-FIPS BouncyCastle) diff --git a/qa/unconfigured-node-name/build.gradle b/qa/unconfigured-node-name/build.gradle index 4736504df7b30..2ae94e6d67187 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/build.gradle @@ -23,11 +23,11 @@ apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { nameCustomization = { null } } -integTest { +tasks.named("integTest").configure { nonInputProperties.systemProperty 'tests.logfile', "${-> testClusters.integTest.singleNode().getServerLog()}" } diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index a8fed883c2d7b..8af6df35e6fa1 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -19,5 +19,5 @@ testClusters.all { module ':modules:mapper-extras' } -test.enabled = false -jarHell.enabled = false +tasks.named("test").configure {enabled = false } +tasks.named("jarHell").configure {enabled = false } diff --git a/x-pack/docs/build.gradle b/x-pack/docs/build.gradle index 06aec099fb2f5..e12a95e9f4fab 100644 --- a/x-pack/docs/build.gradle +++ b/x-pack/docs/build.gradle @@ -27,7 +27,7 @@ restResources { } } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { extraConfigFile 'op-jwks.json', xpackProject('test:idp-fixture').file("oidc/op-jwks.json") extraConfigFile 'idp-docs-metadata.xml', xpackProject('test:idp-fixture').file("idp/shibboleth-idp/metadata/idp-docs-metadata.xml") extraConfigFile 'testClient.crt', xpackProject('plugin:security').file("src/test/resources/org/elasticsearch/xpack/security/action/pki_delegation/testClient.crt") diff --git a/x-pack/plugin/deprecation/qa/rest/build.gradle b/x-pack/plugin/deprecation/qa/rest/build.gradle index 27cc80b55d37d..85b9f7cbe4826 100644 --- a/x-pack/plugin/deprecation/qa/rest/build.gradle +++ b/x-pack/plugin/deprecation/qa/rest/build.gradle @@ -14,7 +14,7 @@ dependencies { } // let the javaRestTest see the classpath of main -GradleUtils.extendSourceSet(project, "main", "javaRestTest", javaRestTest) +GradleUtils.extendSourceSet(project, "main", "javaRestTest", tasks.named("javaRestTest")) restResources { restApi { diff --git a/x-pack/plugin/ilm/qa/multi-cluster/build.gradle b/x-pack/plugin/ilm/qa/multi-cluster/build.gradle index 2125c2768eaba..698d769e73239 100644 --- a/x-pack/plugin/ilm/qa/multi-cluster/build.gradle +++ b/x-pack/plugin/ilm/qa/multi-cluster/build.gradle @@ -11,14 +11,14 @@ dependencies { File repoDir = file("$buildDir/testclusters/repo") -task 'leader-cluster'(type: RestIntegTestTask) { +tasks.register('leader-cluster', RestIntegTestTask) { mustRunAfter("precommit") systemProperty 'tests.target_cluster', 'leader' /* To support taking index snapshots, we have to set path.repo setting */ systemProperty 'tests.path.repo', repoDir.absolutePath } -testClusters.'leader-cluster' { +testClusters.matching { it.name == 'leader-cluster' }.configureEach { testDistribution = 'DEFAULT' setting 'path.repo', repoDir.absolutePath setting 'xpack.ccr.enabled', 'true' @@ -29,19 +29,19 @@ testClusters.'leader-cluster' { setting 'indices.lifecycle.poll_interval', '1000ms' } -task 'follow-cluster'(type: RestIntegTestTask) { - dependsOn 'leader-cluster' - useCluster testClusters.'leader-cluster' - systemProperty 'tests.target_cluster', 'follow' - nonInputProperties.systemProperty 'tests.leader_host', - "${-> testClusters."leader-cluster".getAllHttpSocketURI().get(0)}" - nonInputProperties.systemProperty 'tests.leader_remote_cluster_seed', - "${-> testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}" - /* To support taking index snapshots, we have to set path.repo setting */ - systemProperty 'tests.path.repo', repoDir.absolutePath +tasks.register('follow-cluster', RestIntegTestTask) { + dependsOn tasks.findByName('leader-cluster') + useCluster testClusters.'leader-cluster' + systemProperty 'tests.target_cluster', 'follow' + nonInputProperties.systemProperty 'tests.leader_host', + "${-> testClusters."leader-cluster".getAllHttpSocketURI().get(0)}" + nonInputProperties.systemProperty 'tests.leader_remote_cluster_seed', + "${-> testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}" + /* To support taking index snapshots, we have to set path.repo setting */ + systemProperty 'tests.path.repo', repoDir.absolutePath } -testClusters.'follow-cluster' { +testClusters.matching{ it.name == 'follow-cluster' }.configureEach { testDistribution = 'DEFAULT' setting 'path.repo', repoDir.absolutePath setting 'xpack.ccr.enabled', 'true' @@ -54,5 +54,6 @@ testClusters.'follow-cluster' { { "\"${testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}\"" } } -check.dependsOn 'follow-cluster' -test.enabled = false // no unit tests for this module, only the rest integration test +tasks.named("check").configure { dependsOn 'follow-cluster' } +// no unit tests for this module, only the rest integration test +tasks.named("test").configure { enabled = false } diff --git a/x-pack/plugin/ilm/qa/multi-node/build.gradle b/x-pack/plugin/ilm/qa/multi-node/build.gradle index 50b2fed425949..71ffb394bb627 100644 --- a/x-pack/plugin/ilm/qa/multi-node/build.gradle +++ b/x-pack/plugin/ilm/qa/multi-node/build.gradle @@ -7,7 +7,7 @@ dependencies { } // let the javaRestTest see the classpath of main -GradleUtils.extendSourceSet(project, "main", "javaRestTest", javaRestTest) +GradleUtils.extendSourceSet(project, "main", "javaRestTest", tasks.named("javaRestTest")) File repoDir = file("$buildDir/testclusters/repo") 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 560d6fad19364..e278f9cc76dfc 100644 --- a/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle @@ -66,7 +66,7 @@ integTest { nonInputProperties.systemProperty 'test.azure.base_path', azureBasePath + "_repositories_metering_tests_" + BuildParams.testSeed } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.bundlePlugin.archiveFile 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 9de6417051a1e..b68c7cd47ebf4 100644 --- a/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle @@ -110,7 +110,7 @@ integTest { nonInputProperties.systemProperty 'test.gcs.base_path', gcsBasePath + "_repositories_metering" + BuildParams.testSeed } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.bundlePlugin.archiveFile diff --git a/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle b/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle index 63e2d46bb0321..efd59a6d8fae8 100644 --- a/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle @@ -48,7 +48,7 @@ integTest { nonInputProperties.systemProperty 'test.s3.base_path', s3BasePath ? s3BasePath + "_repositories_metering" + BuildParams.testSeed : 'base_path' } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.bundlePlugin.archiveFile diff --git a/x-pack/plugin/rollup/qa/rest/build.gradle b/x-pack/plugin/rollup/qa/rest/build.gradle index dc909f0e0a35d..9e4f0ed9194f2 100644 --- a/x-pack/plugin/rollup/qa/rest/build.gradle +++ b/x-pack/plugin/rollup/qa/rest/build.gradle @@ -10,19 +10,18 @@ apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-resources' dependencies { - testImplementation project(path: xpackModule('rollup')) + testImplementation project(path: xpackModule('rollup')) } restResources { - restApi { - includeCore '_common', 'bulk', 'cluster', 'indices', 'search' - includeXpack 'rollup' - } + restApi { + includeCore '_common', 'bulk', 'cluster', 'indices', 'search' + includeXpack 'rollup' + } } -testClusters.integTest { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'basic' - systemProperty 'es.rollup_v2_feature_flag_enabled', 'true' +testClusters.matching { it.name == "integTest" }.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/azure/build.gradle b/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle index e7918009a9f42..9efbbb683a2da 100644 --- a/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle @@ -47,7 +47,7 @@ integTest { nonInputProperties.systemProperty 'test.azure.base_path', azureBasePath + "_searchable_snapshots_tests_" + BuildParams.testSeed } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.path diff --git a/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle b/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle index 8faee373d9254..b715745510a30 100644 --- a/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle @@ -91,7 +91,7 @@ integTest { nonInputProperties.systemProperty 'test.gcs.base_path', gcsBasePath + "_searchable_snapshots_tests" + BuildParams.testSeed } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.path diff --git a/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle b/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle index b19ef31c970ad..ed472aab324f7 100644 --- a/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle @@ -32,7 +32,7 @@ integTest { systemProperty 'test.minio.base_path', 'searchable_snapshots_tests' } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.path diff --git a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle index fc741f9728d62..e8d4bcf161234 100644 --- a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle @@ -13,7 +13,7 @@ integTest { systemProperty 'tests.path.repo', repoDir } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'path.repo', repoDir.absolutePath setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle b/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle index db27a341e04c8..3274b7abd5e1e 100644 --- a/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle @@ -47,7 +47,7 @@ integTest { nonInputProperties.systemProperty 'test.s3.base_path', s3BasePath ? s3BasePath + "_searchable_snapshots_tests" + BuildParams.testSeed : 'base_path' } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' plugin repositoryPlugin.path diff --git a/x-pack/plugin/sql/qa/server/build.gradle b/x-pack/plugin/sql/qa/server/build.gradle index efe18fe7e395e..aed41298ce3b0 100644 --- a/x-pack/plugin/sql/qa/server/build.gradle +++ b/x-pack/plugin/sql/qa/server/build.gradle @@ -106,7 +106,7 @@ subprojects { apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.rest-test' - testClusters.integTest { + testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.ml.enabled', 'false' setting 'xpack.watcher.enabled', 'false' diff --git a/x-pack/plugin/sql/qa/server/multi-node/build.gradle b/x-pack/plugin/sql/qa/server/multi-node/build.gradle index 7e048be414d98..73a775e18f0c8 100644 --- a/x-pack/plugin/sql/qa/server/multi-node/build.gradle +++ b/x-pack/plugin/sql/qa/server/multi-node/build.gradle @@ -6,7 +6,7 @@ description = 'Run a subset of SQL tests against multiple nodes' * feel should need to be tested against more than one node. */ -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { numberOfNodes = 2 setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/plugin/sql/qa/server/security/build.gradle b/x-pack/plugin/sql/qa/server/security/build.gradle index 50e75c1376b25..6797b9b638de9 100644 --- a/x-pack/plugin/sql/qa/server/security/build.gradle +++ b/x-pack/plugin/sql/qa/server/security/build.gradle @@ -27,7 +27,7 @@ subprojects { testArtifacts project(path: mainProject.path, configuration: 'testArtifacts') } - testClusters.integTest { + testClusters.matching { it.name == "integTest" }.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/server/security/with-ssl/build.gradle b/x-pack/plugin/sql/qa/server/security/with-ssl/build.gradle index 80aa1632b50a9..44e7353c7a23b 100644 --- a/x-pack/plugin/sql/qa/server/security/with-ssl/build.gradle +++ b/x-pack/plugin/sql/qa/server/security/with-ssl/build.gradle @@ -11,7 +11,7 @@ integTest { } } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.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/server/security/without-ssl/build.gradle b/x-pack/plugin/sql/qa/server/security/without-ssl/build.gradle index 0f27f7a4c48c1..d8539ebcf0477 100644 --- a/x-pack/plugin/sql/qa/server/security/without-ssl/build.gradle +++ b/x-pack/plugin/sql/qa/server/security/without-ssl/build.gradle @@ -2,6 +2,6 @@ integTest { systemProperty 'tests.ssl.enabled', 'false' } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/plugin/sql/qa/server/single-node/build.gradle b/x-pack/plugin/sql/qa/server/single-node/build.gradle index 137ffed68ad52..b66ed7ca5038b 100644 --- a/x-pack/plugin/sql/qa/server/single-node/build.gradle +++ b/x-pack/plugin/sql/qa/server/single-node/build.gradle @@ -1,4 +1,4 @@ -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/qa/core-rest-tests-with-security/build.gradle b/x-pack/qa/core-rest-tests-with-security/build.gradle index bd0b5bff2ba1d..b3623cb6f086a 100644 --- a/x-pack/qa/core-rest-tests-with-security/build.gradle +++ b/x-pack/qa/core-rest-tests-with-security/build.gradle @@ -24,7 +24,7 @@ integTest { systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'x-pack-test-password') } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.watcher.enabled', 'false' diff --git a/x-pack/qa/kerberos-tests/build.gradle b/x-pack/qa/kerberos-tests/build.gradle index d75321b11aea1..774e3a7b4a1e6 100644 --- a/x-pack/qa/kerberos-tests/build.gradle +++ b/x-pack/qa/kerberos-tests/build.gradle @@ -14,7 +14,7 @@ dependencies { testImplementation project(path: xpackModule('security'), configuration: 'testArtifacts') } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' // force localhost IPv4 otherwise it is a chicken and egg problem where we need the keytab for the hostname when starting the cluster // but do not know the exact address that is first in the http ports file diff --git a/x-pack/qa/multi-node/build.gradle b/x-pack/qa/multi-node/build.gradle index bc2e7f8e51b7c..35e90a23e8179 100644 --- a/x-pack/qa/multi-node/build.gradle +++ b/x-pack/qa/multi-node/build.gradle @@ -6,7 +6,7 @@ dependencies { testImplementation project(':x-pack:qa') } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 2 setting 'xpack.security.enabled', 'true' diff --git a/x-pack/qa/password-protected-keystore/build.gradle b/x-pack/qa/password-protected-keystore/build.gradle index f4a1f41a4a3c6..090a0e6f60f85 100644 --- a/x-pack/qa/password-protected-keystore/build.gradle +++ b/x-pack/qa/password-protected-keystore/build.gradle @@ -10,7 +10,7 @@ dependencies { testImplementation project(path: xpackModule('core'), configuration: 'default') } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 2 keystorePassword 's3cr3t' diff --git a/x-pack/qa/reindex-tests-with-security/build.gradle b/x-pack/qa/reindex-tests-with-security/build.gradle index 9186fc883d53a..33c240184efe5 100644 --- a/x-pack/qa/reindex-tests-with-security/build.gradle +++ b/x-pack/qa/reindex-tests-with-security/build.gradle @@ -21,7 +21,7 @@ forbiddenPatterns { File caFile = project.file('src/test/resources/ssl/ca.p12') -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' // Whitelist reindexing from the local node so we can test it. extraConfigFile 'http.key', file('src/test/resources/ssl/http.key') diff --git a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle index 5574552d4687c..7bea9c143c888 100644 --- a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle +++ b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle @@ -21,7 +21,7 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { numberOfNodes = 3 } } - testClusters.matching { it.name.startsWith("${baseName}-") }.all { + testClusters.matching { it.name.startsWith("${baseName}-") }.configureEach { testDistribution = "DEFAULT" versions = [bwcVersion.toString(), project.version] diff --git a/x-pack/qa/saml-idp-tests/build.gradle b/x-pack/qa/saml-idp-tests/build.gradle index ea28cfa4d89a0..f71dcb2fe8a62 100644 --- a/x-pack/qa/saml-idp-tests/build.gradle +++ b/x-pack/qa/saml-idp-tests/build.gradle @@ -41,7 +41,7 @@ tasks.register("setupPorts") { integTest.dependsOn "setupPorts" -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.security.enabled', 'true' diff --git a/x-pack/qa/security-setup-password-tests/build.gradle b/x-pack/qa/security-setup-password-tests/build.gradle index 78f094d93dfde..43ede673fc549 100644 --- a/x-pack/qa/security-setup-password-tests/build.gradle +++ b/x-pack/qa/security-setup-password-tests/build.gradle @@ -8,12 +8,12 @@ dependencies { testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') } -integTest { +tasks.named("integTest").configure { nonInputProperties.systemProperty 'tests.config.dir', "${-> testClusters.integTest.singleNode().getConfigDir()}" systemProperty 'tests.security.manager', 'false' } -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' diff --git a/x-pack/qa/smoke-test-plugins-ssl/build.gradle b/x-pack/qa/smoke-test-plugins-ssl/build.gradle index c422c46e289c2..02df57a788de7 100644 --- a/x-pack/qa/smoke-test-plugins-ssl/build.gradle +++ b/x-pack/qa/smoke-test-plugins-ssl/build.gradle @@ -44,7 +44,7 @@ processTestResources.dependsOn(copyKeyCerts) integTest.dependsOn(copyKeyCerts) def pluginsCount = 0 -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.monitoring.collection.interval', '1s' diff --git a/x-pack/qa/smoke-test-plugins/build.gradle b/x-pack/qa/smoke-test-plugins/build.gradle index d8cfc2bf92b74..44e704f95ed81 100644 --- a/x-pack/qa/smoke-test-plugins/build.gradle +++ b/x-pack/qa/smoke-test-plugins/build.gradle @@ -11,7 +11,7 @@ dependencies { } int pluginsCount = 0 -testClusters.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' setting 'xpack.license.self_generated.type', 'trial' 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 0d9c92141b49e..575e99fc303e7 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.integTest { +testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.watcher.enabled', 'false' setting 'xpack.security.enabled', 'true' diff --git a/x-pack/qa/third-party/jira/build.gradle b/x-pack/qa/third-party/jira/build.gradle index 80704b0fd4f9f..9577f10dbf4e2 100644 --- a/x-pack/qa/third-party/jira/build.gradle +++ b/x-pack/qa/third-party/jira/build.gradle @@ -41,7 +41,7 @@ if (!jiraUrl && !jiraUser && !jiraPassword && !jiraProject) { integTest.enabled = false testingConventions.enabled = false } else { - testClusters.integTest { + testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.ml.enabled', 'false' diff --git a/x-pack/qa/third-party/pagerduty/build.gradle b/x-pack/qa/third-party/pagerduty/build.gradle index d23cc39a77e1e..9378e7975f8bc 100644 --- a/x-pack/qa/third-party/pagerduty/build.gradle +++ b/x-pack/qa/third-party/pagerduty/build.gradle @@ -20,7 +20,7 @@ if (!pagerDutyServiceKey) { integTest.enabled = false testingConventions.enabled = false } else { - testClusters.integTest { + testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.ml.enabled', 'false' diff --git a/x-pack/qa/third-party/slack/build.gradle b/x-pack/qa/third-party/slack/build.gradle index 3860522db4d42..461ccdff160b0 100644 --- a/x-pack/qa/third-party/slack/build.gradle +++ b/x-pack/qa/third-party/slack/build.gradle @@ -20,7 +20,7 @@ if (!slackUrl) { integTest.enabled = false testingConventions.enabled = false } else { - testClusters.integTest { + testClusters.matching { it.name == "integTest" }.configureEach { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.ml.enabled', 'false'