Browse Source

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.
Rene Groeschke 4 years ago
parent
commit
97749a3372
49 changed files with 122 additions and 110 deletions
  1. 3 2
      build.gradle
  2. 2 2
      buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy
  3. 6 4
      buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy
  4. 12 8
      buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/RestResourcesPlugin.java
  5. 9 5
      buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/YamlRestTestPlugin.java
  6. 0 1
      buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java
  7. 6 4
      buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java
  8. 14 14
      docs/build.gradle
  9. 1 1
      plugins/repository-hdfs/build.gradle
  10. 2 2
      qa/die-with-dignity/build.gradle
  11. 2 2
      qa/logging-config/build.gradle
  12. 1 1
      qa/smoke-test-ingest-disabled/build.gradle
  13. 2 2
      qa/smoke-test-multinode/build.gradle
  14. 1 1
      qa/smoke-test-plugins/build.gradle
  15. 2 2
      qa/unconfigured-node-name/build.gradle
  16. 2 2
      rest-api-spec/build.gradle
  17. 1 1
      x-pack/docs/build.gradle
  18. 1 1
      x-pack/plugin/deprecation/qa/rest/build.gradle
  19. 16 15
      x-pack/plugin/ilm/qa/multi-cluster/build.gradle
  20. 1 1
      x-pack/plugin/ilm/qa/multi-node/build.gradle
  21. 1 1
      x-pack/plugin/repositories-metering-api/qa/azure/build.gradle
  22. 1 1
      x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle
  23. 1 1
      x-pack/plugin/repositories-metering-api/qa/s3/build.gradle
  24. 9 10
      x-pack/plugin/rollup/qa/rest/build.gradle
  25. 1 1
      x-pack/plugin/searchable-snapshots/qa/azure/build.gradle
  26. 1 1
      x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle
  27. 1 1
      x-pack/plugin/searchable-snapshots/qa/minio/build.gradle
  28. 1 1
      x-pack/plugin/searchable-snapshots/qa/rest/build.gradle
  29. 1 1
      x-pack/plugin/searchable-snapshots/qa/s3/build.gradle
  30. 1 1
      x-pack/plugin/sql/qa/server/build.gradle
  31. 1 1
      x-pack/plugin/sql/qa/server/multi-node/build.gradle
  32. 1 1
      x-pack/plugin/sql/qa/server/security/build.gradle
  33. 1 1
      x-pack/plugin/sql/qa/server/security/with-ssl/build.gradle
  34. 1 1
      x-pack/plugin/sql/qa/server/security/without-ssl/build.gradle
  35. 1 1
      x-pack/plugin/sql/qa/server/single-node/build.gradle
  36. 1 1
      x-pack/qa/core-rest-tests-with-security/build.gradle
  37. 1 1
      x-pack/qa/kerberos-tests/build.gradle
  38. 1 1
      x-pack/qa/multi-node/build.gradle
  39. 1 1
      x-pack/qa/password-protected-keystore/build.gradle
  40. 1 1
      x-pack/qa/reindex-tests-with-security/build.gradle
  41. 1 1
      x-pack/qa/rolling-upgrade-multi-cluster/build.gradle
  42. 1 1
      x-pack/qa/saml-idp-tests/build.gradle
  43. 2 2
      x-pack/qa/security-setup-password-tests/build.gradle
  44. 1 1
      x-pack/qa/smoke-test-plugins-ssl/build.gradle
  45. 1 1
      x-pack/qa/smoke-test-plugins/build.gradle
  46. 1 1
      x-pack/qa/smoke-test-security-with-mustache/build.gradle
  47. 1 1
      x-pack/qa/third-party/jira/build.gradle
  48. 1 1
      x-pack/qa/third-party/pagerduty/build.gradle
  49. 1 1
      x-pack/qa/third-party/slack/build.gradle

+ 3 - 2
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

+ 2 - 2
buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy

@@ -39,8 +39,8 @@ class DocsTestPlugin implements Plugin<Project> {
 
         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<String, String> commonDefaultSubstitutions = [

+ 6 - 4
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> {
         }
         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<RestIntegTestTask> 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) }
     }
 }

+ 12 - 8
buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/RestResourcesPlugin.java

@@ -24,12 +24,14 @@ import org.gradle.api.Plugin;
 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;
+
 /**
  * <p>
  * 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 class RestResourcesPlugin implements Plugin<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 class RestResourcesPlugin implements Plugin<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 class RestResourcesPlugin implements Plugin<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))
+                );
         });
     }
 }

+ 9 - 5
buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/YamlRestTestPlugin.java

@@ -64,11 +64,15 @@ public class YamlRestTestPlugin implements Plugin<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);

+ 0 - 1
buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersAware.java

@@ -44,5 +44,4 @@ public interface TestClustersAware extends Task {
     }
 
     default void beforeStart() {}
-
 }

+ 6 - 4
buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java

@@ -200,12 +200,14 @@ public abstract class GradleUtils {
      * 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> 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());
+            });
         }
     }
 

+ 14 - 14
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) {

+ 1 - 1
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)
 }
 

+ 2 - 2
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()}"

+ 2 - 2
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()}"
 }

+ 1 - 1
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]'
 }

+ 2 - 2
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()

+ 1 - 1
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)

+ 2 - 2
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()}"
 }

+ 2 - 2
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 }

+ 1 - 1
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")

+ 1 - 1
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 {

+ 16 - 15
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 }

+ 1 - 1
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")

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 9 - 10
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'
 }
-

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 1 - 1
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'

+ 1 - 1
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
 

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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'
 }

+ 1 - 1
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'
 }

+ 1 - 1
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'

+ 1 - 1
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

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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')

+ 1 - 1
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]
 

+ 1 - 1
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'

+ 2 - 2
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'

+ 1 - 1
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'
 

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 1
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'