-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Smarter copying of the rest specs and tests #52114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jakelandis
merged 27 commits into
elastic:master
from
jakelandis:rest_spec_from_common_dir3
Feb 26, 2020
Merged
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c7d36e0
Smarter copying of the rest specs and tests
jakelandis 1e02fbe
fix autoscaling project (merge clash)
jakelandis 02f95b8
fix graph tests
jakelandis 7b81e65
fix xpack docs build
jakelandis f334d40
fix ml tests
jakelandis c1ee4ff
Merge branch 'master' into rest_spec_from_common_dir3
elasticmachine f43429c
Use lazy config, task, and review comments
jakelandis 818e761
Merge branch 'master' into rest_spec_from_common_dir3
jakelandis bddf05b
change name of plugin
jakelandis 0c1d164
fix hlrc test
jakelandis bbcde3a
fix some missed includes
jakelandis 2dc1a3a
move to 1 extension, minor clean up
jakelandis 8942ac2
split to two tasks
jakelandis 2f5739c
fix smoke-test-security-with-mustache test
jakelandis 907c0dd
fix some of the x-pack:qa tests
jakelandis 173b494
fix another x-pack qa test
jakelandis 6d0aec5
fix spotless
jakelandis 6a74f0b
another qa xpack test fix
jakelandis a391dd7
fix another x-pack test (the prior iteration auto added all of x-pac…
jakelandis 9583d15
clean up
jakelandis 1617f6f
Merge remote-tracking branch 'upstream/master' into rest_spec_from_co…
jakelandis d86fc58
move logger to debug and remove incidental change
jakelandis 852b30e
fix 3rd party config and remove uneeded copy
jakelandis 10700bc
address review comments
jakelandis bb84161
fix checkStyle
jakelandis 2e4d1d6
Merge remote-tracking branch 'upstream/master' into rest_spec_from_co…
jakelandis 9e6e2aa
fix plugin name
jakelandis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| /* | ||
| * 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 CopyRestApiPlugin} 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 CopyRestApiPlugin} 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 CopyRestApiPlugin 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 dependency = project.getDependencies() | ||
| .project(Map.of("path", ":rest-api-spec", "configuration", "restTests")); | ||
| project.getDependencies().add(task.coreConfig.getName(), dependency); | ||
|
|
||
| task.xpackConfig = project.getConfigurations().create("restXpackTest"); | ||
| dependency = project.getDependencies().project(Map.of("path", ":x-pack:plugin", "configuration", "restXpackTests")); | ||
jakelandis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| project.getDependencies().add(task.xpackConfig.getName(), dependency); | ||
| 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 dependency = project.getDependencies() | ||
| .project(Map.of("path", ":rest-api-spec", "configuration", "restSpecs")); | ||
| project.getDependencies().add(task.coreConfig.getName(), dependency); | ||
|
|
||
| task.xpackConfig = project.getConfigurations().create("restXpackSpec"); | ||
| dependency = project.getDependencies().project(Map.of("path", ":x-pack:plugin", "configuration", "restXpackSpecs")); | ||
| project.getDependencies().add(task.xpackConfig.getName(), dependency); | ||
| 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)); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.