-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c8916c2
commit 108e432
Showing
52 changed files
with
205 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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 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 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
57 changes: 57 additions & 0 deletions
57
...ools/src/integTest/groovy/org/elasticsearch/gradle/test/JavaRestTestPluginFuncTest.groovy
This file contains 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,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.test | ||
|
||
import org.elasticsearch.gradle.VersionProperties | ||
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest | ||
import org.gradle.testkit.runner.TaskOutcome | ||
|
||
class JavaRestTestPluginFuncTest extends AbstractGradleFuncTest { | ||
|
||
def "declares default dependencies"() { | ||
given: | ||
buildFile << """ | ||
plugins { | ||
id 'elasticsearch.java-rest-test' | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("dependencies").build() | ||
def output = normalized(result.output) | ||
then: | ||
output.contains(normalized(""" | ||
javaRestTestImplementation - Implementation only dependencies for source set 'java rest test'. (n) | ||
/--- org.elasticsearch.test:framework:${VersionProperties.elasticsearch} (n)""")) | ||
} | ||
|
||
def "javaRestTest does nothing when there are no tests"() { | ||
given: | ||
buildFile << """ | ||
plugins { | ||
id 'elasticsearch.java-rest-test' | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
javaRestTestImplementation "org.elasticsearch.test:framework:7.14.0" | ||
} | ||
""" | ||
|
||
when: | ||
def result = gradleRunner("javaRestTest").build() | ||
then: | ||
result.task(':compileJavaRestTestJava').outcome == TaskOutcome.NO_SOURCE | ||
result.task(':javaRestTest').outcome == TaskOutcome.NO_SOURCE | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
build-tools/src/main/java/org/elasticsearch/gradle/test/JavaRestTestPlugin.java
This file contains 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,77 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.test; | ||
|
||
import org.elasticsearch.gradle.VersionProperties; | ||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin; | ||
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster; | ||
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask; | ||
import org.elasticsearch.gradle.testclusters.TestClustersPlugin; | ||
import org.gradle.api.NamedDomainObjectContainer; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.plugins.JavaBasePlugin; | ||
import org.gradle.api.tasks.SourceSetContainer; | ||
import org.gradle.api.tasks.TaskProvider; | ||
import org.gradle.api.tasks.bundling.Zip; | ||
import org.gradle.language.base.plugins.LifecycleBasePlugin; | ||
|
||
import static org.elasticsearch.gradle.plugin.PluginBuildPlugin.BUNDLE_PLUGIN_TASK_NAME; | ||
|
||
public class JavaRestTestPlugin implements Plugin<Project> { | ||
|
||
public static final String JAVA_REST_TEST = "javaRestTest"; | ||
|
||
@Override | ||
public void apply(Project project) { | ||
project.getPluginManager().apply(GradleTestPolicySetupPlugin.class); | ||
project.getPluginManager().apply(TestClustersPlugin.class); | ||
project.getPluginManager().apply(JavaBasePlugin.class); | ||
|
||
// Setup source set and dependencies | ||
var sourceSets = project.getExtensions().getByType(SourceSetContainer.class); | ||
var testSourceSet = sourceSets.maybeCreate(JAVA_REST_TEST); | ||
var javaRestTestImplementation = project.getConfigurations().getByName(testSourceSet.getImplementationConfigurationName()); | ||
|
||
String elasticsearchVersion = VersionProperties.getElasticsearch(); | ||
javaRestTestImplementation.defaultDependencies( | ||
deps -> deps.add(project.getDependencies().create("org.elasticsearch.test:framework:" + elasticsearchVersion)) | ||
); | ||
|
||
// Register test cluster | ||
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project | ||
.getExtensions() | ||
.getByName(TestClustersPlugin.EXTENSION_NAME); | ||
var cluster = testClusters.maybeCreate(JAVA_REST_TEST); | ||
|
||
// Register test task | ||
TaskProvider<StandaloneRestIntegTestTask> javaRestTestTask = project.getTasks() | ||
.register(JAVA_REST_TEST, StandaloneRestIntegTestTask.class, task -> { | ||
task.useCluster(cluster); | ||
task.setTestClassesDirs(testSourceSet.getOutput().getClassesDirs()); | ||
task.setClasspath(testSourceSet.getRuntimeClasspath()); | ||
|
||
var nonInputProperties = new SystemPropertyCommandLineArgumentProvider(); | ||
nonInputProperties.systemProperty("tests.rest.cluster", () -> String.join(",", cluster.getAllHttpSocketURI())); | ||
nonInputProperties.systemProperty("tests.cluster", () -> String.join(",", cluster.getAllTransportPortURI())); | ||
nonInputProperties.systemProperty("tests.clustername", () -> cluster.getName()); | ||
task.getJvmArgumentProviders().add(nonInputProperties); | ||
}); | ||
|
||
// Register plugin bundle with test cluster | ||
project.getPlugins().withType(PluginBuildPlugin.class, p -> { | ||
TaskProvider<Zip> bundle = project.getTasks().withType(Zip.class).named(BUNDLE_PLUGIN_TASK_NAME); | ||
cluster.plugin(bundle.flatMap(Zip::getArchiveFile)); | ||
javaRestTestTask.configure(t -> t.dependsOn(bundle)); | ||
}); | ||
|
||
// Wire up to check task | ||
project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(check -> check.dependsOn(javaRestTestTask)); | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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
2 changes: 1 addition & 1 deletion
2
x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle
This file contains 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.