[7.x] Smarter copying of the rest specs and tests (#52114) (#52798)

* Smarter copying of the rest specs and tests (#52114)

This PR addresses the unnecessary copying of the rest specs and allows
for better semantics for which specs and tests are copied. By default
the rest specs will get copied if the project applies
`elasticsearch.standalone-rest-test` or `esplugin` and the project
has rest tests or you configure the custom extension `restResources`.

This PR also removes the need for dozens of places where the x-pack
specs were copied by supporting copying of the x-pack rest specs too.

The plugin/task introduced here can also copy the rest tests to the
local project through a similar configuration.

The new plugin/task allows a user to minimize the surface area of
which rest specs are copied. Per project can be configured to include
only a subset of the specs (or tests). Configuring a project to only
copy the specs when actually needed should help with build cache hit
rates since we can better define what is actually in use.
However, project level optimizations for build cache hit rates are
not included with this PR.

Also, with this PR you can no longer use the includePackaged flag on
integTest task.

The following items are included in this PR:
* new plugin: `elasticsearch.rest-resources`
* new tasks: CopyRestApiTask and CopyRestTestsTask - performs the copy
* new extension 'restResources'
```
restResources {
  restApi {
    includeCore 'foo' , 'bar' //will include the core specs that start with foo and bar
    includeXpack 'baz' //will include x-pack specs that start with baz
  }
  restTests {
    includeCore 'foo', 'bar' //will include the core tests that start with foo and bar
    includeXpack 'baz' //will include the x-pack tests that start with baz
  }
}

```
This commit is contained in:
Jake Landis 2020-02-26 08:13:41 -06:00 committed by GitHub
parent 2a6c3bea3f
commit 8d311297ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 743 additions and 345 deletions

View File

@ -25,6 +25,7 @@ import org.elasticsearch.gradle.NoticeTask
import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.info.BuildParams import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
import org.elasticsearch.gradle.test.RestIntegTestTask import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.testclusters.RunTask import org.elasticsearch.gradle.testclusters.RunTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin import org.elasticsearch.gradle.testclusters.TestClustersPlugin
@ -54,6 +55,7 @@ class PluginBuildPlugin implements Plugin<Project> {
void apply(Project project) { void apply(Project project) {
project.pluginManager.apply(BuildPlugin) project.pluginManager.apply(BuildPlugin)
project.pluginManager.apply(TestClustersPlugin) project.pluginManager.apply(TestClustersPlugin)
project.pluginManager.apply(RestResourcesPlugin)
PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project) PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)
configureDependencies(project) configureDependencies(project)

View File

@ -18,18 +18,12 @@
*/ */
package org.elasticsearch.gradle.test 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.ElasticsearchCluster
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
import org.elasticsearch.gradle.tool.Boilerplate
import org.gradle.api.DefaultTask import org.gradle.api.DefaultTask
import org.gradle.api.Task 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.api.tasks.testing.Test
import org.gradle.plugins.ide.idea.IdeaPlugin
/** /**
* A wrapper task around setting up a cluster and running rest tests. * A wrapper task around setting up a cluster and running rest tests.
*/ */
@ -37,10 +31,6 @@ class RestIntegTestTask extends DefaultTask {
protected Test runner protected Test runner
/** Flag indicating whether the rest tests in the rest spec should be run. */
@Input
Boolean includePackaged = false
RestIntegTestTask() { RestIntegTestTask() {
runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class) runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class)
super.dependsOn(runner) super.dependsOn(runner)
@ -68,10 +58,6 @@ class RestIntegTestTask extends DefaultTask {
runner.systemProperty('test.cluster', System.getProperty("tests.cluster")) runner.systemProperty('test.cluster', System.getProperty("tests.cluster"))
} }
// 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 // this must run after all projects have been configured, so we know any project
// references can be accessed as a fully configured // references can be accessed as a fully configured
project.gradle.projectsEvaluated { project.gradle.projectsEvaluated {
@ -82,11 +68,6 @@ class RestIntegTestTask extends DefaultTask {
} }
} }
/** Sets the includePackaged property */
public void includePackaged(boolean include) {
includePackaged = include
}
@Override @Override
public Task dependsOn(Object... dependencies) { public Task dependsOn(Object... dependencies) {
runner.dependsOn(dependencies) runner.dependsOn(dependencies)
@ -112,37 +93,4 @@ class RestIntegTestTask extends DefaultTask {
project.tasks.getByName("${name}Runner").configure(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)
}
}
}
}
}
}
} }

View File

@ -26,9 +26,9 @@ import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
import org.elasticsearch.gradle.info.BuildParams import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
import org.elasticsearch.gradle.testclusters.TestClustersPlugin import org.elasticsearch.gradle.testclusters.TestClustersPlugin
import org.gradle.api.InvalidUserDataException import org.gradle.api.InvalidUserDataException
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.Configuration
@ -42,6 +42,7 @@ import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.Test
import org.gradle.plugins.ide.eclipse.model.EclipseModel import org.gradle.plugins.ide.eclipse.model.EclipseModel
import org.gradle.plugins.ide.idea.model.IdeaModel import org.gradle.plugins.ide.idea.model.IdeaModel
/** /**
* Configures the build to compile tests against Elasticsearch's test framework * Configures the build to compile tests against Elasticsearch's test framework
* and run REST tests. Use BuildPlugin if you want to build main code as well * and run REST tests. Use BuildPlugin if you want to build main code as well
@ -74,6 +75,8 @@ class StandaloneRestTestPlugin implements Plugin<Project> {
// only setup tests to build // only setup tests to build
SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer) SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer)
SourceSet testSourceSet = sourceSets.create('test') SourceSet testSourceSet = sourceSets.create('test')
// need to apply plugin after test source sets are created
project.pluginManager.apply(RestResourcesPlugin)
project.tasks.withType(Test) { Test test -> project.tasks.withType(Test) { Test test ->
test.testClassesDirs = testSourceSet.output.classesDirs test.testClassesDirs = testSourceSet.output.classesDirs

View File

@ -250,7 +250,7 @@ public class TestingConventionsTasks extends DefaultTask {
Files.write(getSuccessMarker().toPath(), new byte[] {}, StandardOpenOption.CREATE); Files.write(getSuccessMarker().toPath(), new byte[] {}, StandardOpenOption.CREATE);
} else { } else {
getLogger().error(problems); getLogger().error(problems);
throw new IllegalStateException("Testing conventions are not honored"); throw new IllegalStateException(String.format("Testing conventions [%s] are not honored", problems));
} }
} }

View File

@ -0,0 +1,195 @@
/*
* 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.
*/
package org.elasticsearch.gradle.test.rest;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.info.BuildParams;
import org.elasticsearch.gradle.tool.Boilerplate;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileTree;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.util.PatternFilterable;
import org.gradle.api.tasks.util.PatternSet;
import org.gradle.internal.Factory;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Copies the files needed for the Rest YAML specs to the current projects test resources output directory.
* This is intended to be be used from {@link RestResourcesPlugin} since the plugin wires up the needed
* configurations and custom extensions.
* @see RestResourcesPlugin
*/
public class CopyRestApiTask extends DefaultTask {
private static final String COPY_TO = "rest-api-spec/api";
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);
Configuration coreConfig;
Configuration xpackConfig;
private final PatternFilterable corePatternSet;
private final PatternFilterable xpackPatternSet;
public CopyRestApiTask() {
corePatternSet = getPatternSetFactory().create();
xpackPatternSet = getPatternSetFactory().create();
}
@Inject
protected Factory<PatternSet> getPatternSetFactory() {
throw new UnsupportedOperationException();
}
@Input
public ListProperty<String> getIncludeCore() {
return includeCore;
}
@Input
public ListProperty<String> getIncludeXpack() {
return includeXpack;
}
@SkipWhenEmpty
@InputFiles
public FileTree getInputDir() {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
ConfigurableFileCollection fileCollection = getProject().files(xpackConfig.getAsFileTree().matching(xpackPatternSet));
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
fileCollection.plus(coreConfig.getAsFileTree().matching(corePatternSet));
} else {
fileCollection.plus(coreConfig);
}
// if project has rest tests or the includes are explicitly configured execute the task, else NO-SOURCE due to the null input
return projectHasYamlRestTests() || includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false
? fileCollection.getAsFileTree()
: null;
}
@OutputDirectory
public File getOutputDir() {
return new File(getTestSourceSet().getOutput().getResourcesDir(), COPY_TO);
}
@TaskAction
void copy() {
Project project = getProject();
// always copy the core specs if the task executes
if (BuildParams.isInternal()) {
getLogger().debug("Rest specs for project [{}] will be copied to the test resources.", project.getPath());
project.copy(c -> {
c.from(coreConfig.getSingleFile());
c.into(getOutputDir());
c.include(corePatternSet.getIncludes());
});
} else {
getLogger().debug(
"Rest specs for project [{}] will be copied to the test resources from the published jar (version: [{}]).",
project.getPath(),
VersionProperties.getElasticsearch()
);
project.copy(c -> {
c.from(project.zipTree(coreConfig.getSingleFile()));
c.into(getTestSourceSet().getOutput().getResourcesDir()); // this ends up as the same dir as outputDir
c.include(includeCore.get().stream().map(prefix -> COPY_TO + "/" + prefix + "*/**").collect(Collectors.toList()));
});
}
// only copy x-pack specs if explicitly instructed
if (includeXpack.get().isEmpty() == false) {
getLogger().debug("X-pack rest specs for project [{}] will be copied to the test resources.", project.getPath());
project.copy(c -> {
c.from(xpackConfig.getSingleFile());
c.into(getOutputDir());
c.include(xpackPatternSet.getIncludes());
});
}
}
/**
* Returns true if any files with a .yml extension exist the test resources rest-api-spec/test directory (from source or output dir)
*/
private boolean projectHasYamlRestTests() {
File testSourceResourceDir = getTestSourceResourceDir();
File testOutputResourceDir = getTestOutputResourceDir(); // check output for cases where tests are copied programmatically
if (testSourceResourceDir == null && testOutputResourceDir == null) {
return false;
}
try {
if (testSourceResourceDir != null) {
return new File(testSourceResourceDir, "rest-api-spec/test").exists() == false
|| Files.walk(testSourceResourceDir.toPath().resolve("rest-api-spec/test"))
.anyMatch(p -> p.getFileName().toString().endsWith("yml"));
}
if (testOutputResourceDir != null) {
return new File(testOutputResourceDir, "rest-api-spec/test").exists() == false
|| Files.walk(testOutputResourceDir.toPath().resolve("rest-api-spec/test"))
.anyMatch(p -> p.getFileName().toString().endsWith("yml"));
}
} catch (IOException e) {
throw new IllegalStateException(String.format("Error determining if this project [%s] has rest tests.", getProject()), e);
}
return false;
}
private File getTestSourceResourceDir() {
SourceSet testSources = getTestSourceSet();
if (testSources == null) {
return null;
}
Set<File> resourceDir = testSources.getResources()
.getSrcDirs()
.stream()
.filter(f -> f.isDirectory() && f.getParentFile().getName().equals("test") && f.getName().equals("resources"))
.collect(Collectors.toSet());
assert resourceDir.size() <= 1;
if (resourceDir.size() == 0) {
return null;
}
return resourceDir.iterator().next();
}
private File getTestOutputResourceDir() {
SourceSet testSources = getTestSourceSet();
if (testSources == null) {
return null;
}
return testSources.getOutput().getResourcesDir();
}
private SourceSet getTestSourceSet() {
return Boilerplate.getJavaSourceSets(getProject()).findByName("test");
}
}

View File

@ -0,0 +1,141 @@
/*
* 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.
*/
package org.elasticsearch.gradle.test.rest;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.info.BuildParams;
import org.elasticsearch.gradle.tool.Boilerplate;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileTree;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.util.PatternFilterable;
import org.gradle.api.tasks.util.PatternSet;
import org.gradle.internal.Factory;
import javax.inject.Inject;
import java.io.File;
import java.util.stream.Collectors;
/**
* Copies the Rest YAML test to the current projects test resources output directory.
* This is intended to be be used from {@link RestResourcesPlugin} since the plugin wires up the needed
* configurations and custom extensions.
* @see RestResourcesPlugin
*/
public class CopyRestTestsTask extends DefaultTask {
private static final String COPY_TO = "rest-api-spec/test";
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);
Configuration coreConfig;
Configuration xpackConfig;
private final PatternFilterable corePatternSet;
private final PatternFilterable xpackPatternSet;
public CopyRestTestsTask() {
corePatternSet = getPatternSetFactory().create();
xpackPatternSet = getPatternSetFactory().create();
}
@Inject
protected Factory<PatternSet> getPatternSetFactory() {
throw new UnsupportedOperationException();
}
@Input
public ListProperty<String> getIncludeCore() {
return includeCore;
}
@Input
public ListProperty<String> getIncludeXpack() {
return includeXpack;
}
@SkipWhenEmpty
@InputFiles
public FileTree getInputDir() {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
ConfigurableFileCollection fileCollection = getProject().files(xpackConfig.getAsFileTree().matching(xpackPatternSet));
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
fileCollection.plus(coreConfig.getAsFileTree().matching(corePatternSet));
} else {
fileCollection.plus(coreConfig);
}
// copy tests only if explicitly requested
return includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false ? fileCollection.getAsFileTree() : null;
}
@OutputDirectory
public File getOutputDir() {
return new File(getTestSourceSet().getOutput().getResourcesDir(), COPY_TO);
}
@TaskAction
void copy() {
Project project = getProject();
// only copy core tests if explicitly instructed
if (includeCore.get().isEmpty() == false) {
if (BuildParams.isInternal()) {
getLogger().debug("Rest tests for project [{}] will be copied to the test resources.", project.getPath());
project.copy(c -> {
c.from(coreConfig.getSingleFile());
c.into(getOutputDir());
c.include(corePatternSet.getIncludes());
});
} else {
getLogger().debug(
"Rest tests for project [{}] will be copied to the test resources from the published jar (version: [{}]).",
project.getPath(),
VersionProperties.getElasticsearch()
);
project.copy(c -> {
c.from(project.zipTree(coreConfig.getSingleFile()));
c.into(getTestSourceSet().getOutput().getResourcesDir()); // this ends up as the same dir as outputDir
c.include(includeCore.get().stream().map(prefix -> COPY_TO + "/" + prefix + "*/**").collect(Collectors.toList()));
});
}
}
// only copy x-pack tests if explicitly instructed
if (includeXpack.get().isEmpty() == false) {
getLogger().debug("X-pack rest tests for project [{}] will be copied to the test resources.", project.getPath());
project.copy(c -> {
c.from(xpackConfig.getSingleFile());
c.into(getOutputDir());
c.include(xpackPatternSet.getIncludes());
});
}
}
private SourceSet getTestSourceSet() {
return Boilerplate.getJavaSourceSets(getProject()).findByName("test");
}
}

View File

@ -0,0 +1,79 @@
/*
* 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.
*/
package org.elasticsearch.gradle.test.rest;
import org.elasticsearch.gradle.info.BuildParams;
import org.gradle.api.Action;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.ListProperty;
import javax.inject.Inject;
/**
* Custom extension to configure the {@link CopyRestApiTask}
*/
public class RestResourcesExtension {
final RestResourcesSpec restApi;
final RestResourcesSpec restTests;
@Inject
public RestResourcesExtension(ObjectFactory objects) {
restApi = new RestResourcesSpec(objects);
restTests = new RestResourcesSpec(objects);
}
void restApi(Action<? super RestResourcesSpec> spec) {
spec.execute(restApi);
}
void restTests(Action<? super RestResourcesSpec> spec) {
spec.execute(restTests);
}
static class RestResourcesSpec {
private final ListProperty<String> includeCore;
private final ListProperty<String> includeXpack;
RestResourcesSpec(ObjectFactory objects) {
includeCore = objects.listProperty(String.class);
includeXpack = objects.listProperty(String.class);
}
public void includeCore(String... include) {
this.includeCore.addAll(include);
}
public void includeXpack(String... include) {
if (BuildParams.isInternal() == false) {
throw new IllegalStateException("Can not include x-pack rest resources from an external build.");
}
this.includeXpack.addAll(include);
}
public ListProperty<String> getIncludeCore() {
return includeCore;
}
public ListProperty<String> getIncludeXpack() {
return includeXpack;
}
}
}

View File

@ -0,0 +1,138 @@
/*
* 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.
*/
package org.elasticsearch.gradle.test.rest;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.info.BuildParams;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.provider.Provider;
import java.util.Map;
/**
* <p>
* Gradle plugin to help configure {@link CopyRestApiTask}'s and {@link CopyRestTestsTask} that copies the artifacts needed for the Rest API
* spec and YAML based rest tests.
* </p>
* <strong>Rest API specification:</strong> <br>
* When the {@link RestResourcesPlugin} has been applied the {@link CopyRestApiTask} will automatically copy the core Rest API specification
* if there are any Rest YAML tests present in source, or copied from {@link CopyRestTestsTask} output. X-pack specs must be explicitly
* declared to be copied.
* <br>
* <i>For example:</i>
* <pre>
* restResources {
* restApi {
* includeXpack 'enrich'
* }
* }
* </pre>
* Will copy the entire core Rest API specifications (assuming the project has tests) and any of the the X-pack specs starting with enrich*.
* It is recommended (but not required) to also explicitly declare which core specs your project depends on to help optimize the caching
* behavior.
* <i>For example:</i>
* <pre>
* restResources {
* restApi {
* includeCore 'index', 'cat'
* includeXpack 'enrich'
* }
* }
* </pre>
* <br>
* <strong>Rest YAML tests :</strong> <br>
* When the {@link RestResourcesPlugin} has been applied the {@link CopyRestTestsTask} will copy the Rest YAML tests if explicitly
* configured with `includeCore` or `includeXpack` through the `restResources.restTests` extension.
* <i>For example:</i>
* <pre>
* restResources {
* restApi {
* includeXpack 'graph'
* }
* restTests {
* includeXpack 'graph'
* }
* }
* </pre>
* Will copy any of the the x-pack tests that start with graph, and will copy the X-pack graph specification, as well as the full core
* Rest API specification.
*
* @see CopyRestApiTask
* @see CopyRestTestsTask
*/
public class RestResourcesPlugin implements Plugin<Project> {
private static final String EXTENSION_NAME = "restResources";
@Override
public void apply(Project project) {
RestResourcesExtension extension = project.getExtensions().create(EXTENSION_NAME, RestResourcesExtension.class);
Provider<CopyRestTestsTask> copyRestYamlTestTask = project.getTasks()
.register("copyYamlTestsTask", CopyRestTestsTask.class, task -> {
task.includeCore.set(extension.restTests.getIncludeCore());
task.includeXpack.set(extension.restTests.getIncludeXpack());
task.coreConfig = project.getConfigurations().create("restTest");
if (BuildParams.isInternal()) {
Dependency restTestdependency = project.getDependencies()
.project(Map.of("path", ":rest-api-spec", "configuration", "restTests"));
project.getDependencies().add(task.coreConfig.getName(), restTestdependency);
task.xpackConfig = project.getConfigurations().create("restXpackTest");
Dependency restXPackTestdependency = project.getDependencies()
.project(Map.of("path", ":x-pack:plugin", "configuration", "restXpackTests"));
project.getDependencies().add(task.xpackConfig.getName(), restXPackTestdependency);
task.dependsOn(task.xpackConfig);
} else {
Dependency dependency = project.getDependencies()
.create("org.elasticsearch:rest-api-spec:" + VersionProperties.getElasticsearch());
project.getDependencies().add(task.coreConfig.getName(), dependency);
}
task.dependsOn(task.coreConfig);
});
Provider<CopyRestApiTask> copyRestYamlSpecTask = project.getTasks()
.register("copyRestApiSpecsTask", CopyRestApiTask.class, task -> {
task.includeCore.set(extension.restApi.getIncludeCore());
task.includeXpack.set(extension.restApi.getIncludeXpack());
task.dependsOn(copyRestYamlTestTask);
task.coreConfig = project.getConfigurations().create("restSpec");
if (BuildParams.isInternal()) {
Dependency restSpecDependency = project.getDependencies()
.project(Map.of("path", ":rest-api-spec", "configuration", "restSpecs"));
project.getDependencies().add(task.coreConfig.getName(), restSpecDependency);
task.xpackConfig = project.getConfigurations().create("restXpackSpec");
Dependency restXpackSpecDependency = project.getDependencies()
.project(Map.of("path", ":x-pack:plugin", "configuration", "restXpackSpecs"));
project.getDependencies().add(task.xpackConfig.getName(), restXpackSpecDependency);
task.dependsOn(task.xpackConfig);
} else {
Dependency dependency = project.getDependencies()
.create("org.elasticsearch:rest-api-spec:" + VersionProperties.getElasticsearch());
project.getDependencies().add(task.coreConfig.getName(), dependency);
}
task.dependsOn(task.coreConfig);
});
project.getTasks().named("processTestResources").configure(t -> t.dependsOn(copyRestYamlSpecTask));
}
}

View File

@ -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.rest.RestResourcesPlugin

View File

@ -24,6 +24,7 @@ apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
apply plugin: 'nebula.maven-base-publish' apply plugin: 'nebula.maven-base-publish'
apply plugin: 'nebula.maven-scm' apply plugin: 'nebula.maven-scm'
apply plugin: 'elasticsearch.rest-resources'
group = 'org.elasticsearch.client' group = 'org.elasticsearch.client'
archivesBaseName = 'elasticsearch-rest-high-level-client' archivesBaseName = 'elasticsearch-rest-high-level-client'
@ -36,15 +37,10 @@ publishing {
} }
} }
configurations { restResources {
restSpec //we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions)
} restApi {
includeCore '*'
idea {
module {
if (scopes.TEST != null) {
scopes.TEST.plus.add(project.configurations.restSpec)
}
} }
} }
@ -69,16 +65,9 @@ dependencies {
exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client' exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client'
} }
testCompile(project(':x-pack:plugin:eql')) testCompile(project(':x-pack:plugin:eql'))
restSpec project(':rest-api-spec')
} }
//we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions)
processTestResources { 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')) from(project(':client:rest-high-level').file('src/test/resources'))
} }

View File

@ -319,9 +319,14 @@ configure(subprojects.findAll { it.name == 'integ-test-zip' }) {
group = "org.elasticsearch.distribution.integ-test-zip" group = "org.elasticsearch.distribution.integ-test-zip"
restResources {
restTests {
includeCore '*'
}
}
integTest { integTest {
dependsOn assemble dependsOn assemble
includePackaged = true
runner { runner {
if (Os.isFamily(Os.FAMILY_WINDOWS) && System.getProperty('tests.timeoutSuite') == null) { if (Os.isFamily(Os.FAMILY_WINDOWS) && System.getProperty('tests.timeoutSuite') == null) {
// override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man // override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man

View File

@ -14,13 +14,11 @@ configurations {
dockerPlugins dockerPlugins
dockerSource dockerSource
ossDockerSource ossDockerSource
restSpec
} }
dependencies { dependencies {
dockerSource project(path: ":distribution:archives:linux-tar") dockerSource project(path: ":distribution:archives:linux-tar")
ossDockerSource project(path: ":distribution:archives:oss-linux-tar") ossDockerSource project(path: ":distribution:archives:oss-linux-tar")
restSpec project(':rest-api-spec')
} }
ext.expansions = { oss, local -> ext.expansions = { oss, local ->
@ -138,12 +136,8 @@ preProcessFixture {
} }
processTestResources { processTestResources {
from({ zipTree(configurations.restSpec.singleFile) }) {
include 'rest-api-spec/api/**'
}
from project(':x-pack:plugin:core') from project(':x-pack:plugin:core')
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks')
dependsOn configurations.restSpec
} }
task integTest(type: Test) { task integTest(type: Test) {

View File

@ -41,6 +41,12 @@ buildRestTests.expectedUnconvertedCandidates = [
'reference/ml/anomaly-detection/apis/update-job.asciidoc' 'reference/ml/anomaly-detection/apis/update-job.asciidoc'
] ]
restResources {
restApi {
includeCore '*'
}
}
testClusters.integTest { testClusters.integTest {
if (singleNode().testDistribution == DEFAULT) { if (singleNode().testDistribution == DEFAULT) {
setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.license.self_generated.type', 'trial'

View File

@ -30,17 +30,10 @@ tasks.register("bwcTest") {
group = 'verification' group = 'verification'
} }
configurations { restResources {
restSpec restTests {
} includeCore '*'
}
dependencies {
restSpec project(':rest-api-spec')
}
processTestResources {
from({ zipTree(configurations.restSpec.singleFile) })
dependsOn configurations.restSpec
} }
for (Version bwcVersion : bwcVersions.wireCompatible) { for (Version bwcVersion : bwcVersions.wireCompatible) {

View File

@ -25,12 +25,7 @@ apply plugin: 'elasticsearch.distribution-download'
testFixtures.useFixture() testFixtures.useFixture()
configurations {
restSpec
}
dependencies { dependencies {
restSpec project(':rest-api-spec')
testCompile project(':client:rest-high-level') testCompile project(':client:rest-high-level')
} }
@ -90,12 +85,8 @@ def createAndSetWritable(Object... locations) {
} }
processTestResources { processTestResources {
from({ zipTree(configurations.restSpec.singleFile) }) {
include 'rest-api-spec/api/**'
}
from project(':x-pack:plugin:core') from project(':x-pack:plugin:core')
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks')
dependsOn configurations.restSpec
} }
task integTest(type: Test) { task integTest(type: Test) {

View File

@ -31,21 +31,6 @@ task bwcTest {
group = 'verification' 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) { for (Version bwcVersion : bwcVersions.wireCompatible) {
/* /*
* The goal here is to: * The goal here is to:

View File

@ -21,8 +21,10 @@ apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
integTest { restResources {
includePackaged = true restTests {
includeCore '*'
}
} }
File repo = file("$buildDir/testclusters/repo") File repo = file("$buildDir/testclusters/repo")

View File

@ -4,3 +4,13 @@ apply plugin: 'nebula.maven-scm'
test.enabled = false test.enabled = false
jarHell.enabled = false jarHell.enabled = false
configurations {
restSpecs
restTests
}
artifacts {
restSpecs(new File(projectDir, "src/main/resources/rest-api-spec/api"))
restTests(new File(projectDir, "src/main/resources/rest-api-spec/test"))
}

View File

@ -1,5 +1,3 @@
import java.nio.charset.StandardCharsets
apply plugin: 'elasticsearch.docs-test' apply plugin: 'elasticsearch.docs-test'
/* List of files that have snippets that probably should be converted to /* List of files that have snippets that probably should be converted to
@ -21,10 +19,11 @@ dependencies {
testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts') testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts')
} }
// copy xpack rest api restResources {
File xpackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources') restApi {
project.copyRestSpec.from(xpackResources) { includeCore '*'
include 'rest-api-spec/api/**' includeXpack '*'
}
} }
testClusters.integTest { testClusters.integTest {

View File

@ -1,18 +1,6 @@
import org.elasticsearch.gradle.test.RestIntegTestTask
apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.build'
test.enabled = false test.enabled = false
dependencies { dependencies {
compile project(':test:framework') 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/**'
}
}
}

View File

@ -9,6 +9,12 @@ dependencies {
testCompile project(path: xpackModule('autoscaling'), configuration: 'runtime') testCompile project(path: xpackModule('autoscaling'), configuration: 'runtime')
} }
restResources {
restApi {
includeXpack 'autoscaling'
}
}
task restTest(type: RestIntegTestTask) { task restTest(type: RestIntegTestTask) {
mustRunAfter(precommit) mustRunAfter(precommit)
} }

View File

@ -66,6 +66,13 @@ subprojects {
// https://github.com/elastic/x-plugins/issues/724 // https://github.com/elastic/x-plugins/issues/724
configurations { configurations {
testArtifacts.extendsFrom testRuntime testArtifacts.extendsFrom testRuntime
restXpackSpecs
restXpackTests
}
artifacts {
restXpackSpecs(new File(projectDir, "src/test/resources/rest-api-spec/api"))
restXpackTests(new File(projectDir, "src/test/resources/rest-api-spec/test"))
} }
task testJar(type: Jar) { task testJar(type: Jar) {

View File

@ -1,18 +1,6 @@
import org.elasticsearch.gradle.test.RestIntegTestTask
apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.build'
test.enabled = false test.enabled = false
dependencies { dependencies {
compile project(':test:framework') 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/**'
}
}
}

View File

@ -3,6 +3,12 @@ import org.elasticsearch.gradle.test.RestIntegTestTask
apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test' apply plugin: 'elasticsearch.standalone-test'
restResources {
restApi {
includeXpack 'ccr'
}
}
dependencies { dependencies {
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
testCompile project(path: xpackModule('ccr'), configuration: 'runtime') testCompile project(path: xpackModule('ccr'), configuration: 'runtime')

View File

@ -6,12 +6,3 @@ test.enabled = false
dependencies { dependencies {
compile project(':test:framework') 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/**'
}
}
}

View File

@ -2,6 +2,12 @@ apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
restResources {
restApi {
includeXpack 'enrich'
}
}
dependencies { dependencies {
testCompile project(path: xpackModule('enrich'), configuration: 'runtime') testCompile project(path: xpackModule('enrich'), configuration: 'runtime')
testCompile project(path: xpackModule('enrich:qa:common'), configuration: 'runtime') testCompile project(path: xpackModule('enrich:qa:common'), configuration: 'runtime')

View File

@ -6,12 +6,3 @@ test.enabled = false
dependencies { dependencies {
compile project(':test:framework') 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/**'
}
}
}

View File

@ -4,6 +4,12 @@ apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
restResources {
restApi {
includeXpack 'eql'
}
}
dependencies { dependencies {
testCompile project(path: xpackModule('eql'), configuration: 'runtime') testCompile project(path: xpackModule('eql'), configuration: 'runtime')
testCompile project(path: xpackModule('eql:qa:common'), configuration: 'runtime') testCompile project(path: xpackModule('eql:qa:common'), configuration: 'runtime')

View File

@ -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/**'
}
}
}

View File

@ -7,14 +7,15 @@ dependencies {
} }
// bring in graph rest test suite // bring in graph rest test suite
task copyGraphRestTests(type: Copy) { restResources {
into project.sourceSets.test.output.resourcesDir restApi {
from project(xpackProject('plugin').path).sourceSets.test.resources.srcDirs includeXpack 'graph'
include 'rest-api-spec/test/graph/**' }
restTests {
includeXpack 'graph'
}
} }
integTest.dependsOn copyGraphRestTests
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'true' setting 'xpack.security.enabled', 'true'

View File

@ -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/**'
}
}
}

View File

@ -8,6 +8,12 @@ dependencies {
testCompile project(path: xpackModule('ilm'), configuration: 'runtime') testCompile project(path: xpackModule('ilm'), configuration: 'runtime')
} }
restResources {
restApi {
includeXpack 'ilm', 'slm'
}
}
def clusterCredentials = [username: System.getProperty('tests.rest.cluster.username', 'test_admin'), def clusterCredentials = [username: System.getProperty('tests.rest.cluster.username', 'test_admin'),
password: System.getProperty('tests.rest.cluster.password', 'x-pack-test-password')] password: System.getProperty('tests.rest.cluster.password', 'x-pack-test-password')]

View File

@ -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/**'
}
}
}

View File

@ -9,15 +9,15 @@ dependencies {
} }
// bring in machine learning rest test suite // bring in machine learning rest test suite
task copyMlRestTests(type: Copy) { restResources {
into project.sourceSets.test.output.resourcesDir restApi {
from project(xpackProject('plugin').path).sourceSets.test.resources.srcDirs includeXpack 'ml', 'cat'
include 'rest-api-spec/test/ml/**' }
restTests {
includeXpack 'ml'
}
} }
integTest.runner {
dependsOn copyMlRestTests
}
integTest.runner { integTest.runner {
systemProperty 'tests.rest.blacklist', [ systemProperty 'tests.rest.blacklist', [
// Remove this test because it doesn't call an ML endpoint and we don't want // Remove this test because it doesn't call an ML endpoint and we don't want

View File

@ -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/**'
}
}
}

View File

@ -1,27 +1,9 @@
// this file must exist so that qa projects are found // this file must exist so that qa projects are found
// by the elasticsearch x-plugins include mechanism // by the elasticsearch x-plugins include mechanism
import org.elasticsearch.gradle.test.RestIntegTestTask
apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.build'
test.enabled = false test.enabled = false
dependencies { dependencies {
compile project(':test:framework') 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/**'
}
}
}

View File

@ -6,8 +6,13 @@ dependencies {
testCompile project(':x-pack:qa') testCompile project(':x-pack:qa')
} }
restResources {
restTests {
includeCore '*'
}
}
integTest { integTest {
includePackaged = true
runner { runner {
systemProperty 'tests.rest.blacklist', systemProperty 'tests.rest.blacklist',
[ [

View File

@ -1,8 +1,6 @@
import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test' apply plugin: 'elasticsearch.standalone-test'
@ -39,24 +37,6 @@ tasks.register("copyTestNodeKeyMaterial", Copy) {
into outputDir 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) { for (Version bwcVersion : bwcVersions.indexCompatible) {
String baseName = "v${bwcVersion}" String baseName = "v${bwcVersion}"

View File

@ -7,6 +7,12 @@ dependencies {
testCompile project(':x-pack:qa') testCompile project(':x-pack:qa')
} }
restResources {
restApi {
includeXpack 'security'
}
}
task 'remote-cluster'(type: RestIntegTestTask) { task 'remote-cluster'(type: RestIntegTestTask) {
mustRunAfter(precommit) mustRunAfter(precommit)
runner { runner {

View File

@ -8,6 +8,12 @@ dependencies {
testCompile project(':client:rest-high-level') testCompile project(':client:rest-high-level')
} }
restResources {
restApi {
includeXpack 'security', 'transform'
}
}
task 'remote-cluster'(type: RestIntegTestTask) { task 'remote-cluster'(type: RestIntegTestTask) {
mustRunAfter(precommit) mustRunAfter(precommit)
runner { runner {

View File

@ -1,5 +1,4 @@
import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.testclusters'
@ -14,25 +13,6 @@ tasks.register("bwcTest") {
group = 'verification' 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) { for (Version bwcVersion : bwcVersions.wireCompatible) {
String baseName = "v${bwcVersion}" String baseName = "v${bwcVersion}"

View File

@ -1,5 +1,4 @@
import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.testclusters'
@ -14,24 +13,6 @@ tasks.register("bwcTest") {
group = 'verification' 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) { for (Version bwcVersion : bwcVersions.wireCompatible) {
String baseName = "v${bwcVersion}" String baseName = "v${bwcVersion}"

View File

@ -1,5 +1,4 @@
import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.testclusters'
@ -10,6 +9,13 @@ dependencies {
testCompile project(':client:rest-high-level') testCompile project(':client:rest-high-level')
} }
restResources {
restApi {
includeCore '*'
includeXpack '*'
}
}
forbiddenPatterns { forbiddenPatterns {
exclude '**/system_key' exclude '**/system_key'
} }
@ -21,24 +27,6 @@ tasks.register("bwcTest") {
group = 'verification' 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) { task copyTestNodeKeyMaterial(type: Copy) {
from project(':x-pack:plugin:core').files('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem', 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') 'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt')

View File

@ -6,6 +6,12 @@ dependencies {
testCompile project(':x-pack:qa') testCompile project(':x-pack:qa')
} }
restResources {
restApi {
includeXpack 'security'
}
}
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.watcher.enabled', 'false' setting 'xpack.watcher.enabled', 'false'

View File

@ -6,14 +6,15 @@ dependencies {
testCompile project(':x-pack:qa') testCompile project(':x-pack:qa')
} }
// bring in watcher rest test suite restResources {
task copyWatcherRestTests(type: Copy) { restApi {
into project.sourceSets.test.output.resourcesDir includeXpack 'watcher', 'security', 'xpack'
from project(xpackProject('plugin').path).sourceSets.test.resources.srcDirs }
include 'rest-api-spec/test/watcher/**' restTests {
includeXpack 'watcher'
}
} }
integTest.runner.dependsOn copyWatcherRestTests
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.ilm.enabled', 'false' setting 'xpack.ilm.enabled', 'false'

View File

@ -6,6 +6,12 @@ dependencies {
testCompile project(':x-pack:qa') testCompile project(':x-pack:qa')
} }
restResources {
restApi {
includeXpack 'watcher'
}
}
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.slm.enabled', 'false' setting 'xpack.slm.enabled', 'false'

View File

@ -12,22 +12,17 @@ dependencies {
testCompile project(path: xpackModule('watcher'), configuration: 'runtime') testCompile project(path: xpackModule('watcher'), configuration: 'runtime')
} }
restResources {
restApi {
includeXpack 'watcher'
}
}
String jiraUrl = System.getenv('jira_url') String jiraUrl = System.getenv('jira_url')
String jiraUser = System.getenv('jira_user') String jiraUser = System.getenv('jira_user')
String jiraPassword = System.getenv('jira_password') String jiraPassword = System.getenv('jira_password')
String jiraProject = System.getenv('jira_project') String jiraProject = System.getenv('jira_project')
testClusters.integTest {
setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
setting 'xpack.notification.jira.account.test.issue_defaults.issuetype.name', 'Bug'
setting 'xpack.notification.jira.account.test.issue_defaults.labels.0', 'integration-tests'
}
task cleanJira(type: DefaultTask) { task cleanJira(type: DefaultTask) {
doLast { doLast {
List<String> issues = jiraIssues(jiraProject) List<String> issues = jiraIssues(jiraProject)
@ -46,6 +41,14 @@ if (!jiraUrl && !jiraUser && !jiraPassword && !jiraProject) {
testingConventions.enabled = false testingConventions.enabled = false
} else { } else {
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
setting 'xpack.notification.jira.account.test.issue_defaults.issuetype.name', 'Bug'
setting 'xpack.notification.jira.account.test.issue_defaults.labels.0', 'integration-tests'
setting 'xpack.notification.jira.account.test.issue_defaults.project.key', jiraProject setting 'xpack.notification.jira.account.test.issue_defaults.project.key', jiraProject
keystore 'xpack.notification.jira.account.test.secure_url', jiraUrl keystore 'xpack.notification.jira.account.test.secure_url', jiraUrl
keystore 'xpack.notification.jira.account.test.secure_user', jiraUser keystore 'xpack.notification.jira.account.test.secure_user', jiraUser

View File

@ -9,11 +9,18 @@ dependencies {
String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key') String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key')
restResources {
restApi {
includeXpack 'watcher'
}
}
if (!pagerDutyServiceKey) { if (!pagerDutyServiceKey) {
integTest.enabled = false integTest.enabled = false
testingConventions.enabled = false testingConventions.enabled = false
} else { } else {
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false' setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false' setting 'xpack.ml.enabled', 'false'

View File

@ -7,6 +7,12 @@ dependencies {
testCompile project(path: xpackModule('watcher'), configuration: 'runtime') testCompile project(path: xpackModule('watcher'), configuration: 'runtime')
} }
restResources {
restApi {
includeXpack 'watcher'
}
}
String slackUrl = System.getenv('slack_url') String slackUrl = System.getenv('slack_url')
if (!slackUrl) { if (!slackUrl) {
@ -14,6 +20,7 @@ if (!slackUrl) {
testingConventions.enabled = false testingConventions.enabled = false
} else { } else {
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false' setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false' setting 'xpack.ml.enabled', 'false'