-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Convert RestIntegTestTask to Java #54528
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 6 commits into
elastic:master
from
jakelandis:RestIntegTestTask_to_Java
Apr 1, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e18b5bf
move files and add supplier
jakelandis 609026d
RestIntegTestTask to java
jakelandis d4cac28
spotless
jakelandis 784d953
fix test failure (wrong depends) and review comments
jakelandis 78d4b5d
fix warning, remove uneeded code
jakelandis 205ed00
bring back isEnabled setEnabled to pass validation
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
97 changes: 0 additions & 97 deletions
97
buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy
This file was deleted.
Oops, something went wrong.
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
104 changes: 104 additions & 0 deletions
104
buildSrc/src/main/java/org/elasticsearch/gradle/test/RestIntegTestTask.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,104 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| import org.elasticsearch.gradle.SystemPropertyCommandLineArgumentProvider; | ||
| import org.elasticsearch.gradle.testclusters.ElasticsearchCluster; | ||
| import org.elasticsearch.gradle.testclusters.RestTestRunnerTask; | ||
| import org.elasticsearch.gradle.testclusters.TestClustersPlugin; | ||
| import org.gradle.api.Action; | ||
| import org.gradle.api.DefaultTask; | ||
| import org.gradle.api.NamedDomainObjectContainer; | ||
| import org.gradle.api.Project; | ||
| import org.gradle.api.Task; | ||
|
|
||
| public class RestIntegTestTask extends DefaultTask { | ||
|
|
||
| protected RestTestRunnerTask runner; | ||
| private static final String TESTS_REST_CLUSTER = "tests.rest.cluster"; | ||
| private static final String TESTS_CLUSTER = "tests.cluster"; | ||
| private static final String TESTS_CLUSTER_NAME = "tests.clustername"; | ||
|
|
||
| public RestIntegTestTask() { | ||
| Project project = getProject(); | ||
| String name = getName(); | ||
| runner = project.getTasks().create(name + "Runner", RestTestRunnerTask.class); | ||
| super.dependsOn(runner); | ||
| @SuppressWarnings("unchecked") | ||
| NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project | ||
| .getExtensions() | ||
| .getByName(TestClustersPlugin.EXTENSION_NAME); | ||
| ElasticsearchCluster cluster = testClusters.create(name); | ||
| runner.useCluster(cluster); | ||
| runner.include("**/*IT.class"); | ||
| runner.systemProperty("tests.rest.load_packaged", Boolean.FALSE.toString()); | ||
| if (System.getProperty(TESTS_REST_CLUSTER) == null) { | ||
| if (System.getProperty(TESTS_CLUSTER) != null || System.getProperty(TESTS_CLUSTER_NAME) != null) { | ||
| throw new IllegalArgumentException( | ||
| String.format("%s, %s, and %s must all be null or non-null", TESTS_REST_CLUSTER, TESTS_CLUSTER, TESTS_CLUSTER_NAME) | ||
| ); | ||
| } | ||
| SystemPropertyCommandLineArgumentProvider runnerNonInputProperties = (SystemPropertyCommandLineArgumentProvider) runner | ||
| .getExtensions() | ||
| .getByName("nonInputProperties"); | ||
| runnerNonInputProperties.systemProperty(TESTS_REST_CLUSTER, () -> String.join(",", cluster.getAllHttpSocketURI())); | ||
| runnerNonInputProperties.systemProperty(TESTS_CLUSTER, () -> String.join(",", cluster.getAllTransportPortURI())); | ||
| runnerNonInputProperties.systemProperty(TESTS_CLUSTER_NAME, cluster::getName); | ||
| } else { | ||
| if (System.getProperty(TESTS_CLUSTER) == null || System.getProperty(TESTS_CLUSTER_NAME) == null) { | ||
| throw new IllegalArgumentException( | ||
| String.format("%s, %s, and %s must all be null or non-null", TESTS_REST_CLUSTER, TESTS_CLUSTER, TESTS_CLUSTER_NAME) | ||
| ); | ||
| } | ||
| } | ||
| // this must run after all projects have been configured, so we know any project | ||
| // references can be accessed as a fully configured | ||
| project.getGradle().projectsEvaluated(x -> { | ||
| if (isEnabled() == false) { | ||
| runner.setEnabled(false); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public Task dependsOn(Object... dependencies) { | ||
| runner.dependsOn(dependencies); | ||
| for (Object dependency : dependencies) { | ||
| if (dependency instanceof Fixture) { | ||
| runner.finalizedBy(((Fixture) dependency).getStopTask()); | ||
| } | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public void setDependsOn(Iterable<?> dependencies) { | ||
| runner.setDependsOn(dependencies); | ||
| for (Object dependency : dependencies) { | ||
| if (dependency instanceof Fixture) { | ||
| runner.finalizedBy(((Fixture) dependency).getStopTask()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void runner(Action<? super RestTestRunnerTask> configure) { | ||
| configure.execute(runner); | ||
| } | ||
| } | ||
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.