From 925b203f03e34ccf1850995ec17cfd7d836d517c Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 4 Feb 2020 14:50:32 -0600 Subject: [PATCH 1/6] Read the full REST spec from a common directory This commit changes where the REST API specs are read. The REST API spec is required to run the REST YAML tests and are currently copied to every project that has REST YAML tests. The REST API specs are now copied to the build directory of the root gradle project. Since each module or plugin (including all x-pack plugins) can contribute to the REST API spec, they too are copied to the common directory. The result is a single directory created during the build which includes the full REST API spec. Configuration is added to each project that has a RestIntegTestTask to enable ensure that the common directory is created when needed. The numerous places where this spec was copied around has now been removed in favor of the new common directory, which is the full spec and is part of the test classpath. Additionally, to enable plugin developers, a new plugin copy-rest-api-spec has been introduced that allows the specs to be copied locally from the jar. This is plugin is also used for the BWC tests which need to copy the tests for the spec to the local resource directory. --- build.gradle | 12 ++++ .../gradle/test/CopyRestApiSpecPlugin.groovy | 40 ++++++++++++ .../gradle/test/RestIntegTestTask.groovy | 57 +---------------- ...lasticsearch.copy-rest-api-spec.properties | 20 ++++++ client/rest-high-level/build.gradle | 19 ------ distribution/archives/build.gradle | 6 +- distribution/docker/build.gradle | 6 -- gradle/copy-rest-api-spec-to-global.gradle | 61 +++++++++++++++++++ modules/lang-painless/build.gradle | 2 + plugins/examples/rest-handler/build.gradle | 7 ++- qa/mixed-cluster/build.gradle | 14 ++--- qa/remote-clusters/build.gradle | 4 -- qa/rolling-upgrade/build.gradle | 15 ----- qa/smoke-test-multinode/build.gradle | 9 ++- x-pack/docs/build.gradle | 6 -- x-pack/plugin/ccr/qa/build.gradle | 9 --- x-pack/plugin/enrich/qa/build.gradle | 10 --- x-pack/plugin/eql/qa/build.gradle | 9 --- x-pack/plugin/graph/qa/build.gradle | 17 ------ x-pack/plugin/ilm/qa/build.gradle | 10 --- x-pack/plugin/ml/qa/build.gradle | 17 ------ x-pack/plugin/security/qa/build.gradle | 11 ---- x-pack/qa/build.gradle | 17 ------ .../build.gradle | 9 ++- x-pack/qa/full-cluster-restart/build.gradle | 18 ------ x-pack/qa/rolling-upgrade-basic/build.gradle | 19 ------ .../build.gradle | 18 ------ x-pack/qa/rolling-upgrade/build.gradle | 18 ------ 28 files changed, 167 insertions(+), 293 deletions(-) create mode 100644 buildSrc/src/main/groovy/org/elasticsearch/gradle/test/CopyRestApiSpecPlugin.groovy create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/elasticsearch.copy-rest-api-spec.properties create mode 100644 gradle/copy-rest-api-spec-to-global.gradle diff --git a/build.gradle b/build.gradle index e1dfdce13eaf7..f8f5fea92e62f 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,8 @@ import org.elasticsearch.gradle.BwcVersions import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.plugin.PluginBuildPlugin +import org.elasticsearch.gradle.test.RestIntegTestTask +import org.elasticsearch.gradle.test.RestTestPlugin import org.gradle.plugins.ide.eclipse.model.SourceFolder import org.gradle.util.DistributionLocator import org.gradle.util.GradleVersion @@ -41,6 +43,7 @@ apply plugin: 'nebula.info-scm' apply from: 'gradle/build-scan.gradle' apply from: 'gradle/build-complete.gradle' apply from: 'gradle/runtime-jdk-provision.gradle' +apply from: 'gradle/copy-rest-api-spec-to-global.gradle' // common maven publishing configuration allprojects { @@ -138,6 +141,15 @@ subprojects { precommit.dependsOn 'spotlessJavaCheck' } } + //copy the rest api spec to a global location and add to the test classpath + project.tasks.withType(RestIntegTestTask) { + configurations { + copyRestApiSpecGlobal + } + dependencies { + testRuntime project(path: ':', configuration: 'copyRestApiSpecGlobal') + } + } } /* Introspect all versions of ES that may be tested against for backwards diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/CopyRestApiSpecPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/CopyRestApiSpecPlugin.groovy new file mode 100644 index 0000000000000..5b3fef9c32c85 --- /dev/null +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/CopyRestApiSpecPlugin.groovy @@ -0,0 +1,40 @@ +package org.elasticsearch.gradle.test + +import org.elasticsearch.gradle.VersionProperties +import org.elasticsearch.gradle.info.BuildParams +import org.elasticsearch.gradle.testclusters.RestTestRunnerTask +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.tasks.Copy + +/** + * Copies the core REST specs to the local resource directory for the REST YAML tests. + */ +class CopyRestApiSpecPlugin implements Plugin { + + @Override + void apply(Project project) { + project.with { + configurations.create('restSpec') + dependencies.add( + 'restSpec', + BuildParams.internal ? project.project(':rest-api-spec') : + "org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}" + ) + + tasks.create("copyCoreRestSpecLocal", Copy) { + dependsOn project.configurations.restSpec + into(project.sourceSets.test.output.resourcesDir) + from({ project.zipTree(project.configurations.restSpec.singleFile) }) { + includeEmptyDirs = false + include 'rest-api-spec/api/**' + } + } + + tasks.withType(RestTestRunnerTask).each { Task t -> + t.dependsOn('copyCoreRestSpecLocal') + } + } + } +} diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy index 58e72e2dd7be4..835df65803367 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy @@ -18,18 +18,13 @@ */ package org.elasticsearch.gradle.test -import org.elasticsearch.gradle.VersionProperties -import org.elasticsearch.gradle.info.BuildParams + import org.elasticsearch.gradle.testclusters.ElasticsearchCluster import org.elasticsearch.gradle.testclusters.RestTestRunnerTask -import org.elasticsearch.gradle.tool.Boilerplate import org.gradle.api.DefaultTask import org.gradle.api.Task -import org.gradle.api.file.FileCopyDetails -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.Input import org.gradle.api.tasks.testing.Test -import org.gradle.plugins.ide.idea.IdeaPlugin + /** * A wrapper task around setting up a cluster and running rest tests. */ @@ -37,10 +32,6 @@ class RestIntegTestTask extends DefaultTask { protected Test runner - /** Flag indicating whether the rest tests in the rest spec should be run. */ - @Input - Boolean includePackaged = false - RestIntegTestTask() { runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class) super.dependsOn(runner) @@ -69,10 +60,6 @@ class RestIntegTestTask extends DefaultTask { runner.systemProperty('test.clustername', System.getProperty("tests.clustername")) } - // copy the rest spec/tests onto the test classpath - Copy copyRestSpec = createCopyRestSpecTask() - project.sourceSets.test.output.builtBy(copyRestSpec) - // this must run after all projects have been configured, so we know any project // references can be accessed as a fully configured project.gradle.projectsEvaluated { @@ -83,12 +70,6 @@ class RestIntegTestTask extends DefaultTask { } } - /** Sets the includePackaged property */ - public void includePackaged(boolean include) { - includePackaged = include - } - - @Override public Task dependsOn(Object... dependencies) { runner.dependsOn(dependencies) @@ -113,38 +94,4 @@ class RestIntegTestTask extends DefaultTask { public void runner(Closure configure) { project.tasks.getByName("${name}Runner").configure(configure) } - - Copy createCopyRestSpecTask() { - Boilerplate.maybeCreate(project.configurations, 'restSpec') { - project.dependencies.add( - 'restSpec', - BuildParams.internal ? project.project(':rest-api-spec') : - "org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}" - ) - } - - return Boilerplate.maybeCreate(project.tasks, 'copyRestSpec', Copy) { Copy copy -> - copy.dependsOn project.configurations.restSpec - copy.into(project.sourceSets.test.output.resourcesDir) - copy.from({ project.zipTree(project.configurations.restSpec.singleFile) }) { - includeEmptyDirs = false - include 'rest-api-spec/**' - filesMatching('rest-api-spec/test/**') { FileCopyDetails details -> - if (includePackaged == false) { - details.exclude() - } - } - } - - if (project.plugins.hasPlugin(IdeaPlugin)) { - project.idea { - module { - if (scopes.TEST != null) { - scopes.TEST.plus.add(project.configurations.restSpec) - } - } - } - } - } - } } diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/elasticsearch.copy-rest-api-spec.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/elasticsearch.copy-rest-api-spec.properties new file mode 100644 index 0000000000000..1bb4c4d776bd7 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/elasticsearch.copy-rest-api-spec.properties @@ -0,0 +1,20 @@ +# +# Licensed to Elasticsearch under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +implementation-class=org.elasticsearch.gradle.test.CopyRestApiSpecPlugin diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle index fc15a4550f0a2..b25664e44dc70 100644 --- a/client/rest-high-level/build.gradle +++ b/client/rest-high-level/build.gradle @@ -36,18 +36,6 @@ publishing { } } -configurations { - restSpec -} - -idea { - module { - if (scopes.TEST != null) { - scopes.TEST.plus.add(project.configurations.restSpec) - } - } -} - dependencies { compile project(':modules:mapper-extras') compile project(':modules:parent-join') @@ -70,16 +58,9 @@ dependencies { testCompile(project(':x-pack:plugin:core')) { exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client' } - - restSpec project(':rest-api-spec') } -//we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions) processTestResources { - dependsOn configurations.restSpec // so that configurations resolve - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } from(project(':client:rest-high-level').file('src/test/resources')) } diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index 022453f945e6a..791bc94b041f3 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -305,17 +305,21 @@ subprojects { configure(subprojects.findAll { it.name == 'integ-test-zip' }) { apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' + apply plugin: 'elasticsearch.copy-rest-api-spec' group = "org.elasticsearch.distribution.integ-test-zip" integTest { dependsOn assemble - includePackaged = true } processTestResources { + from({ zipTree(configurations.restSpec.singleFile) }) { + include 'rest-api-spec/test/**' + } inputs.properties(project(':distribution').restTestExpansions) MavenFilteringHack.filter(it, project(':distribution').restTestExpansions) + dependsOn configurations.restSpec } diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index f9d12ce242da8..246969d6182d6 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -13,13 +13,11 @@ configurations { dockerPlugins dockerSource ossDockerSource - restSpec } dependencies { dockerSource project(path: ":distribution:archives:linux-tar") ossDockerSource project(path: ":distribution:archives:oss-linux-tar") - restSpec project(':rest-api-spec') } ext.expansions = { oss, local -> @@ -128,12 +126,8 @@ preProcessFixture { } processTestResources { - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') - dependsOn configurations.restSpec } task integTest(type: Test) { diff --git a/gradle/copy-rest-api-spec-to-global.gradle b/gradle/copy-rest-api-spec-to-global.gradle new file mode 100644 index 0000000000000..0c59d3dcd440b --- /dev/null +++ b/gradle/copy-rest-api-spec-to-global.gradle @@ -0,0 +1,61 @@ + +/** + * Copies all of the REST api specs (including core, modules, plugins, and x-pack) to common location for the REST YAML test. + * This plugin is expected to only be applied to applied to the root project. + */ +File rootBuildDir = rootProject.buildDir + +tasks.create("copyCoreRestSpecGlobal", Copy) { + from project.findProject(':rest-api-spec').projectDir + into rootBuildDir + includeEmptyDirs = false + include '**/src/**/rest-api-spec/api/**' + eachFile { + path = new File("rest-api-spec/api", name) + } +} + +tasks.create("copyModulesRestSpecGlobal", Copy) { + from project.findProject(':modules').projectDir + into rootBuildDir + includeEmptyDirs = false + include '**/src/**/rest-api-spec/api/**' + eachFile { + path = new File("rest-api-spec/api", name) + } +} + +tasks.create("copyPluginsRestSpecGlobal", Copy) { + from project.findProject(':plugins').projectDir + into rootBuildDir + includeEmptyDirs = false + include '**/src/**/rest-api-spec/api/**' + exclude '**/examples/**' + eachFile { + path = new File("rest-api-spec/api", name) + } +} + +tasks.create("copyXpackPluginsRestSpecGlobal", Copy) { + from project.findProject(':x-pack:plugin').projectDir + into rootBuildDir + includeEmptyDirs = false + include '**/src/**/rest-api-spec/api/**' + eachFile { + path = new File("rest-api-spec/api", name) + } +} + +tasks.create("copyAllRestSpecsGlobal") { + dependsOn copyCoreRestSpecGlobal + dependsOn copyModulesRestSpecGlobal + dependsOn copyPluginsRestSpecGlobal + dependsOn copyXpackPluginsRestSpecGlobal +} + +configurations { + copyRestApiSpecGlobal +} +artifacts { + copyRestApiSpecGlobal(file(rootBuildDir)) { builtBy copyAllRestSpecsGlobal } +} diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index 75e41dcf2e2aa..71d7618b4a3e9 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -22,6 +22,8 @@ esplugin { description 'An easy, safe and fast scripting language for Elasticsearch' classname 'org.elasticsearch.painless.PainlessPlugin' } +//since there are local api specs, we need to copy the core spec locally too +apply plugin: 'elasticsearch.copy-rest-api-spec' testClusters.integTest { module file(project(':modules:mapper-extras').tasks.bundlePlugin.archiveFile) diff --git a/plugins/examples/rest-handler/build.gradle b/plugins/examples/rest-handler/build.gradle index 12f3c0e095335..d00e0202a465e 100644 --- a/plugins/examples/rest-handler/build.gradle +++ b/plugins/examples/rest-handler/build.gradle @@ -1,5 +1,3 @@ -import org.elasticsearch.gradle.info.BuildParams - /* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with @@ -18,8 +16,11 @@ import org.elasticsearch.gradle.info.BuildParams * specific language governing permissions and limitations * under the License. */ +import org.elasticsearch.gradle.info.BuildParams + apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.esplugin' +apply plugin: 'elasticsearch.copy-rest-api-spec' esplugin { name 'rest-handler' @@ -51,3 +52,5 @@ testingConventions.naming { baseClass 'org.elasticsearch.test.ESTestCase' } } + + diff --git a/qa/mixed-cluster/build.gradle b/qa/mixed-cluster/build.gradle index 0f02cbd52d4e9..358a8cca22934 100644 --- a/qa/mixed-cluster/build.gradle +++ b/qa/mixed-cluster/build.gradle @@ -24,23 +24,19 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-test' +apply plugin: 'elasticsearch.copy-rest-api-spec' tasks.register("bwcTest") { description = 'Runs backwards compatibility tests.' group = 'verification' } -configurations { - restSpec -} - -dependencies { - restSpec project(':rest-api-spec') -} - processTestResources { - from({ zipTree(configurations.restSpec.singleFile) }) + from({ zipTree(configurations.restSpec.singleFile) }) { + include 'rest-api-spec/test/**' + } dependsOn configurations.restSpec + dependsOn copyCoreRestSpecLocal } for (Version bwcVersion : bwcVersions.wireCompatible) { diff --git a/qa/remote-clusters/build.gradle b/qa/remote-clusters/build.gradle index f3027a0d5b91b..2286012a63702 100644 --- a/qa/remote-clusters/build.gradle +++ b/qa/remote-clusters/build.gradle @@ -88,12 +88,8 @@ def createAndSetWritable(Object... locations) { } processTestResources { - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') - dependsOn configurations.restSpec } task integTest(type: Test) { diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index bf1bc2d5b1073..003fc75910523 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -31,21 +31,6 @@ task bwcTest { group = 'verification' } -configurations { - restSpec -} - -dependencies { - restSpec project(':rest-api-spec') -} - -processTestResources { - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } - dependsOn configurations.restSpec -} - for (Version bwcVersion : bwcVersions.wireCompatible) { /* * The goal here is to: diff --git a/qa/smoke-test-multinode/build.gradle b/qa/smoke-test-multinode/build.gradle index b76a865c6f898..99387cccc152d 100644 --- a/qa/smoke-test-multinode/build.gradle +++ b/qa/smoke-test-multinode/build.gradle @@ -20,11 +20,16 @@ apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' +apply plugin: 'elasticsearch.copy-rest-api-spec' -integTest { - includePackaged = true +processTestResources { + from({ zipTree(configurations.restSpec.singleFile) }) { + include 'rest-api-spec/test/**' + } + dependsOn configurations.restSpec } + File repo = file("$buildDir/testclusters/repo") testClusters.integTest { numberOfNodes = 2 diff --git a/x-pack/docs/build.gradle b/x-pack/docs/build.gradle index 57759b9427bee..f6c3ed7947fe5 100644 --- a/x-pack/docs/build.gradle +++ b/x-pack/docs/build.gradle @@ -21,12 +21,6 @@ dependencies { testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts') } -// copy xpack rest api -File xpackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') -project.copyRestSpec.from(xpackResources) { - include 'rest-api-spec/api/**' -} - testClusters.integTest { 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") diff --git a/x-pack/plugin/ccr/qa/build.gradle b/x-pack/plugin/ccr/qa/build.gradle index 46609933699ca..4306abf6b7f8b 100644 --- a/x-pack/plugin/ccr/qa/build.gradle +++ b/x-pack/plugin/ccr/qa/build.gradle @@ -7,12 +7,3 @@ dependencies { compile project(':test:framework') } -subprojects { - project.tasks.withType(RestIntegTestTask) { - final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xPackResources) { - include 'rest-api-spec/api/**' - } - } - -} diff --git a/x-pack/plugin/enrich/qa/build.gradle b/x-pack/plugin/enrich/qa/build.gradle index d3e95d997c3fb..ef337d3df0b4c 100644 --- a/x-pack/plugin/enrich/qa/build.gradle +++ b/x-pack/plugin/enrich/qa/build.gradle @@ -1,4 +1,3 @@ -import org.elasticsearch.gradle.test.RestIntegTestTask apply plugin: 'elasticsearch.build' test.enabled = false @@ -6,12 +5,3 @@ test.enabled = false dependencies { compile project(':test:framework') } - -subprojects { - project.tasks.withType(RestIntegTestTask) { - final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xPackResources) { - include 'rest-api-spec/api/**' - } - } -} diff --git a/x-pack/plugin/eql/qa/build.gradle b/x-pack/plugin/eql/qa/build.gradle index d3e95d997c3fb..79ff4091f6d2d 100644 --- a/x-pack/plugin/eql/qa/build.gradle +++ b/x-pack/plugin/eql/qa/build.gradle @@ -6,12 +6,3 @@ test.enabled = false dependencies { compile project(':test:framework') } - -subprojects { - project.tasks.withType(RestIntegTestTask) { - final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xPackResources) { - include 'rest-api-spec/api/**' - } - } -} diff --git a/x-pack/plugin/graph/qa/build.gradle b/x-pack/plugin/graph/qa/build.gradle index 012e25f5d4f9d..e69de29bb2d1d 100644 --- a/x-pack/plugin/graph/qa/build.gradle +++ b/x-pack/plugin/graph/qa/build.gradle @@ -1,17 +0,0 @@ -import org.elasticsearch.gradle.test.RestIntegTestTask - -subprojects { - // HACK: please fix this - // we want to add the rest api specs for xpack to qa tests, but we - // need to wait until after the project is evaluated to only apply - // to those that rest tests. this used to be done automatically - // when xpack was a plugin, but now there is no place with xpack as a module. - // instead, we should package these and make them easy to use for rest tests, - // but currently, they must be copied into the resources of the test runner. - project.tasks.withType(RestIntegTestTask) { - File xpackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xpackResources) { - include 'rest-api-spec/api/**' - } - } -} diff --git a/x-pack/plugin/ilm/qa/build.gradle b/x-pack/plugin/ilm/qa/build.gradle index 46908e1d849b9..8b137891791fe 100644 --- a/x-pack/plugin/ilm/qa/build.gradle +++ b/x-pack/plugin/ilm/qa/build.gradle @@ -1,11 +1 @@ -import org.elasticsearch.gradle.test.RestIntegTestTask - -subprojects { - project.tasks.withType(RestIntegTestTask) { - final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xPackResources) { - include 'rest-api-spec/api/**' - } - } -} diff --git a/x-pack/plugin/ml/qa/build.gradle b/x-pack/plugin/ml/qa/build.gradle index 012e25f5d4f9d..e69de29bb2d1d 100644 --- a/x-pack/plugin/ml/qa/build.gradle +++ b/x-pack/plugin/ml/qa/build.gradle @@ -1,17 +0,0 @@ -import org.elasticsearch.gradle.test.RestIntegTestTask - -subprojects { - // HACK: please fix this - // we want to add the rest api specs for xpack to qa tests, but we - // need to wait until after the project is evaluated to only apply - // to those that rest tests. this used to be done automatically - // when xpack was a plugin, but now there is no place with xpack as a module. - // instead, we should package these and make them easy to use for rest tests, - // but currently, they must be copied into the resources of the test runner. - project.tasks.withType(RestIntegTestTask) { - File xpackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xpackResources) { - include 'rest-api-spec/api/**' - } - } -} diff --git a/x-pack/plugin/security/qa/build.gradle b/x-pack/plugin/security/qa/build.gradle index 46908e1d849b9..e69de29bb2d1d 100644 --- a/x-pack/plugin/security/qa/build.gradle +++ b/x-pack/plugin/security/qa/build.gradle @@ -1,11 +0,0 @@ -import org.elasticsearch.gradle.test.RestIntegTestTask - -subprojects { - project.tasks.withType(RestIntegTestTask) { - final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xPackResources) { - include 'rest-api-spec/api/**' - } - } -} - diff --git a/x-pack/qa/build.gradle b/x-pack/qa/build.gradle index 2555b0ef729dc..c710c625a9898 100644 --- a/x-pack/qa/build.gradle +++ b/x-pack/qa/build.gradle @@ -1,8 +1,6 @@ // this file must exist so that qa projects are found // by the elasticsearch x-plugins include mechanism -import org.elasticsearch.gradle.test.RestIntegTestTask - apply plugin: 'elasticsearch.build' test.enabled = false @@ -10,18 +8,3 @@ dependencies { compile project(':test:framework') } -subprojects { - // HACK: please fix this - // we want to add the rest api specs for xpack to qa tests, but we - // need to wait until after the project is evaluated to only apply - // to those that rest tests. this used to be done automatically - // when xpack was a plugin, but now there is no place with xpack as a module. - // instead, we should package these and make them easy to use for rest tests, - // but currently, they must be copied into the resources of the test runner. - project.tasks.withType(RestIntegTestTask) { - File xpackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') - project.copyRestSpec.from(xpackResources) { - include 'rest-api-spec/api/**' - } - } -} 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 f273efaf5bcd2..a34ccd30a7c31 100644 --- a/x-pack/qa/core-rest-tests-with-security/build.gradle +++ b/x-pack/qa/core-rest-tests-with-security/build.gradle @@ -1,13 +1,20 @@ apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' +apply plugin: 'elasticsearch.copy-rest-api-spec' dependencies { testCompile project(':x-pack:qa') } +processTestResources { + from({ zipTree(configurations.restSpec.singleFile) }) { + include 'rest-api-spec/test/**' + } + dependsOn configurations.restSpec +} + integTest { - includePackaged = true runner { systemProperty 'tests.rest.blacklist', [ diff --git a/x-pack/qa/full-cluster-restart/build.gradle b/x-pack/qa/full-cluster-restart/build.gradle index 180d42e7d5dc9..cd0a6aaeff8e8 100644 --- a/x-pack/qa/full-cluster-restart/build.gradle +++ b/x-pack/qa/full-cluster-restart/build.gradle @@ -39,24 +39,6 @@ tasks.register("copyTestNodeKeyMaterial", Copy) { into outputDir } -configurations { - restSpec -} - -dependencies { - restSpec project(':rest-api-spec') -} - -processTestResources { - dependsOn configurations.restSpec - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } - from(project(xpackModule('core')).sourceSets.test.resources) { - include 'rest-api-spec/api/**' - } -} - for (Version bwcVersion : bwcVersions.indexCompatible) { String baseName = "v${bwcVersion}" diff --git a/x-pack/qa/rolling-upgrade-basic/build.gradle b/x-pack/qa/rolling-upgrade-basic/build.gradle index 9367b74aae379..27c2b697438a7 100644 --- a/x-pack/qa/rolling-upgrade-basic/build.gradle +++ b/x-pack/qa/rolling-upgrade-basic/build.gradle @@ -14,25 +14,6 @@ tasks.register("bwcTest") { group = 'verification' } -configurations { - restSpec -} - -dependencies { - restSpec project(':rest-api-spec') -} - -processTestResources { - dependsOn configurations.restSpec - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } - from(project(xpackProject('plugin').path).sourceSets.test.resources) { - include 'rest-api-spec/api/**' - } -} - - for (Version bwcVersion : bwcVersions.wireCompatible) { String baseName = "v${bwcVersion}" diff --git a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle index bba1d1fd96e24..c28e8cfd8baae 100644 --- a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle +++ b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle @@ -14,24 +14,6 @@ tasks.register("bwcTest") { group = 'verification' } -configurations { - restSpec -} - -dependencies { - restSpec project(':rest-api-spec') -} - -processTestResources { - dependsOn configurations.restSpec - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } - from(project(xpackProject('plugin').path).sourceSets.test.resources) { - include 'rest-api-spec/api/**' - } -} - for (Version bwcVersion : bwcVersions.wireCompatible) { String baseName = "v${bwcVersion}" diff --git a/x-pack/qa/rolling-upgrade/build.gradle b/x-pack/qa/rolling-upgrade/build.gradle index 1cd40dd7856b0..c4656cde92809 100644 --- a/x-pack/qa/rolling-upgrade/build.gradle +++ b/x-pack/qa/rolling-upgrade/build.gradle @@ -23,24 +23,6 @@ tasks.register("bwcTest") { group = 'verification' } -configurations { - restSpec -} - -dependencies { - restSpec project(':rest-api-spec') -} - -processTestResources { - dependsOn configurations.restSpec - from({ zipTree(configurations.restSpec.singleFile) }) { - include 'rest-api-spec/api/**' - } - from(project(xpackProject('plugin').path).sourceSets.test.resources) { - include 'rest-api-spec/api/**' - } -} - task copyTestNodeKeyMaterial(type: Copy) { from project(':x-pack:plugin:core').files('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem', 'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt') From 4266f67455315b0e3e057a79668502a1ad3b1c31 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 4 Feb 2020 15:34:02 -0600 Subject: [PATCH 2/6] fix HLRC test --- client/rest-high-level/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle index b25664e44dc70..28a708b1eaf1e 100644 --- a/client/rest-high-level/build.gradle +++ b/client/rest-high-level/build.gradle @@ -24,6 +24,7 @@ apply plugin: 'elasticsearch.rest-test' apply plugin: 'nebula.maven-base-publish' apply plugin: 'nebula.maven-scm' apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'elasticsearch.copy-rest-api-spec' group = 'org.elasticsearch.client' archivesBaseName = 'elasticsearch-rest-high-level-client' @@ -62,6 +63,7 @@ dependencies { processTestResources { from(project(':client:rest-high-level').file('src/test/resources')) + dependsOn copyCoreRestSpecLocal } dependencyLicenses { From 8500ad7546180e2f1c3a43a32fc9b6cd9729fb54 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 4 Feb 2020 15:55:56 -0600 Subject: [PATCH 3/6] fix docker tests --- distribution/docker/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 246969d6182d6..8cc7a00672426 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -6,6 +6,7 @@ import org.elasticsearch.gradle.testfixtures.TestFixturesPlugin apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.test.fixtures' +apply plugin: 'elasticsearch.copy-rest-api-spec' testFixtures.useFixture() @@ -128,6 +129,7 @@ preProcessFixture { processTestResources { from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') + dependsOn copyCoreRestSpecLocal } task integTest(type: Test) { From df804c10f17c5a5a92be4b3b29222be20d70573f Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 4 Feb 2020 16:12:40 -0600 Subject: [PATCH 4/6] fix xpack doc tests --- x-pack/docs/build.gradle | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-pack/docs/build.gradle b/x-pack/docs/build.gradle index f6c3ed7947fe5..01632ee0c17d2 100644 --- a/x-pack/docs/build.gradle +++ b/x-pack/docs/build.gradle @@ -1,6 +1,7 @@ import java.nio.charset.StandardCharsets apply plugin: 'elasticsearch.docs-test' +apply plugin: 'elasticsearch.copy-rest-api-spec' /* List of files that have snippets that probably should be converted to * `// CONSOLE` and `// TESTRESPONSE` but have yet to be converted. Try and @@ -21,6 +22,14 @@ dependencies { testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts') } +processTestResources { + from({ new File(xpackProject('plugin').projectDir, 'src/test/resources')}) { + include 'rest-api-spec/api/**' + } + dependsOn configurations.restSpec + dependsOn copyCoreRestSpecLocal +} + testClusters.integTest { 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") From ec68975772cf213449159d89ce83bd192cdeb65e Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 4 Feb 2020 16:26:10 -0600 Subject: [PATCH 5/6] fix rolling upgrade --- qa/rolling-upgrade/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index 003fc75910523..cefe23ac38ab5 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -23,6 +23,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-test' +apply plugin: 'elasticsearch.copy-rest-api-spec' // This is a top level task which we will add dependencies to below. // It is a single task that can be used to backcompat tests against all versions. @@ -31,6 +32,10 @@ task bwcTest { group = 'verification' } +processTestResources { + dependsOn copyCoreRestSpecLocal +} + for (Version bwcVersion : bwcVersions.wireCompatible) { /* * The goal here is to: From 5c3c36a2e97a59442576469052b40714ebaddc25 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 4 Feb 2020 17:10:32 -0600 Subject: [PATCH 6/6] fix Xpack Rest Tests --- x-pack/plugin/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index 85d28fcd65d40..26d9b24692f77 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -3,6 +3,7 @@ import org.elasticsearch.gradle.info.BuildParams apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' +apply plugin: 'elasticsearch.copy-rest-api-spec' archivesBaseName = 'x-pack' @@ -55,7 +56,10 @@ task copyKeyCerts(type: Copy) { } // Add keystores to test classpath: it expects it there sourceSets.test.resources.srcDir(keystoreDir) -processTestResources.dependsOn(copyKeyCerts) +processTestResources { + dependsOn copyKeyCerts + dependsOn copyCoreRestSpecLocal +} integTest.runner { /*