Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void copy() {
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.from(coreConfig.getAsFileTree());
c.into(getOutputDir());
c.include(corePatternSet.getIncludes());
});
Expand All @@ -138,7 +138,7 @@ void copy() {
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.from(xpackConfig.getAsFileTree());
c.into(getOutputDir());
c.include(xpackPatternSet.getIncludes());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.elasticsearch.gradle.info.BuildParams;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.provider.Provider;

Expand Down Expand Up @@ -86,21 +87,31 @@ public class RestResourcesPlugin implements Plugin<Project> {
public void apply(Project project) {
RestResourcesExtension extension = project.getExtensions().create(EXTENSION_NAME, RestResourcesExtension.class);

// tests
Configuration testConfig = project.getConfigurations().create("restTestConfig");
Configuration xpackTestConfig = project.getConfigurations().create("restXpackTest");
project.getConfigurations().create("restTests");
project.getConfigurations().create("restXpackTests");
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");
task.coreConfig = testConfig;
if (BuildParams.isInternal()) {
// core
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");
// x-pack
task.xpackConfig = xpackTestConfig;
Dependency restXPackTestdependency = project.getDependencies()
.project(Map.of("path", ":x-pack:plugin", "configuration", "restXpackTests"));
project.getDependencies().add(task.xpackConfig.getName(), restXPackTestdependency);
task.dependsOn(task.xpackConfig);
// watcher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particular excited about us hard-coding these mappings. Are we going to have to add something here for every project that shares tests. Also, if we want to get to a point where we can aggregate all xpack tests (as the clients team has asked about) we'll need a more generic solution here likely based on some convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to have to add something here for every project that shares tests

Yeah, as-is unfortunately. I agree this is less then ideal, and will get ugly after a few more of these. If you have any suggestions, I can explore (but preferably in a different PR).

Dependency restWatcherTests = project.getDependencies()
.project(Map.of("path", ":x-pack:plugin:watcher:qa:rest", "configuration", "restXpackTests"));
project.getDependencies().add(task.xpackConfig.getName(), restWatcherTests);
} else {
Dependency dependency = project.getDependencies()
.create("org.elasticsearch:rest-api-spec:" + VersionProperties.getElasticsearch());
Expand All @@ -109,18 +120,22 @@ public void apply(Project project) {
task.dependsOn(task.coreConfig);
});

// api
Configuration specConfig = project.getConfigurations().create("restSpec"); // name chosen for passivity
Configuration xpackSpecConfig = project.getConfigurations().create("restXpackSpec");
project.getConfigurations().create("restSpecs");
project.getConfigurations().create("restXpackSpecs");
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");
task.coreConfig = specConfig;
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");
task.xpackConfig = xpackSpecConfig;
Dependency restXpackSpecDependency = project.getDependencies()
.project(Map.of("path", ":x-pack:plugin", "configuration", "restXpackSpecs"));
project.getDependencies().add(task.xpackConfig.getName(), restXpackSpecDependency);
Expand Down
6 changes: 1 addition & 5 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
apply plugin: 'elasticsearch.build'
apply plugin: 'nebula.maven-base-publish'
apply plugin: 'nebula.maven-scm'
apply plugin: 'elasticsearch.rest-resources'

test.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"))
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ dependencies {

configurations {
testArtifacts.extendsFrom testRuntime
restXpackSpecs
restXpackTests
}

artifacts {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/watcher/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ task testJar(type: Jar) {

artifacts {
testArtifacts testJar
restXpackTests(new File(projectDir, "src/test/resources/rest-api-spec/test"))
}

restResources {
Expand Down
12 changes: 3 additions & 9 deletions x-pack/plugin/watcher/qa/with-security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ dependencies {
testCompile project(path: ':x-pack:plugin:watcher:qa:rest', configuration: 'testArtifacts')
}


// bring in watcher rest test suite from the rest project
task copyWatcherRestTests(type: Copy) {
into project.sourceSets.test.output.resourcesDir
from project(xpackProject('plugin:watcher:qa:rest').path).sourceSets.test.resources.srcDirs
include 'rest-api-spec/test/watcher/**'
}

restResources {
restApi {
includeXpack 'watcher', 'security', 'xpack'
}
restTests {
includeXpack 'watcher'
}
}

integTest.runner.dependsOn copyWatcherRestTests
testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.ilm.enabled', 'false'
Expand Down