Require either BuildPlugin or StandaloneTestBasePlugin to use RestTestPlugin

It used to be that RestTestPlugin "came with" StandaloneTestBasePlugin
but we'd like to use it with BuildPlugin for the high level rest client.
This commit is contained in:
Nik Everett 2017-01-03 15:39:36 -05:00 committed by Luca Cavanna
parent f0181b19f5
commit 812f63e5ef
15 changed files with 80 additions and 15 deletions

View File

@ -21,6 +21,7 @@ package org.elasticsearch.gradle
import nebula.plugin.extraconfigurations.ProvidedBasePlugin import nebula.plugin.extraconfigurations.ProvidedBasePlugin
import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.GradleException import org.gradle.api.GradleException
import org.gradle.api.InvalidUserDataException
import org.gradle.api.JavaVersion 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
@ -54,6 +55,9 @@ class BuildPlugin implements Plugin<Project> {
@Override @Override
void apply(Project project) { void apply(Project project) {
if (project.pluginManager.hasPlugin('elasticsearch.standalone-test')) {
throw new InvalidUserDataException('elasticsearch.standalone-test and elasticsearch.build are mutually exclusive')
}
project.pluginManager.apply('java') project.pluginManager.apply('java')
project.pluginManager.apply('carrotsearch.randomized-testing') project.pluginManager.apply('carrotsearch.randomized-testing')
// these plugins add lots of info to our jars // these plugins add lots of info to our jars

View File

@ -30,6 +30,7 @@ public class DocsTestPlugin extends RestTestPlugin {
@Override @Override
public void apply(Project project) { public void apply(Project project) {
project.pluginManager.apply('elasticsearch.standalone-test')
super.apply(project) super.apply(project)
Map<String, String> defaultSubstitutions = [ Map<String, String> defaultSubstitutions = [
/* These match up with the asciidoc syntax for substitutions but /* These match up with the asciidoc syntax for substitutions but

View File

@ -18,15 +18,29 @@
*/ */
package org.elasticsearch.gradle.test package org.elasticsearch.gradle.test
import org.elasticsearch.gradle.BuildPlugin
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
/** A plugin to add rest integration tests. Used for qa projects. */ /**
* Adds support for starting an Elasticsearch cluster before running integration
* tests. Used in conjunction with {@link StandaloneTestBasePlugin} for qa
* projects and in conjunction with {@link BuildPlugin} for testing the rest
* client.
*/
public class RestTestPlugin implements Plugin<Project> { public class RestTestPlugin implements Plugin<Project> {
List REQUIRED_PLUGINS = [
'elasticsearch.build',
'elasticsearch.standalone-test']
@Override @Override
public void apply(Project project) { public void apply(Project project) {
project.pluginManager.apply(StandaloneTestBasePlugin) if (false == REQUIRED_PLUGINS.any {project.pluginManager.hasPlugin(it)}) {
throw new InvalidUserDataException('elasticsearch.rest-test '
+ 'requires either elasticsearch.build or '
+ 'elasticsearch.standalone-test')
}
RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class) RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class)
integTest.cluster.distribution = 'zip' // rest tests should run with the real zip integTest.cluster.distribution = 'zip' // rest tests should run with the real zip

View File

@ -24,6 +24,7 @@ import com.carrotsearch.gradle.junit4.RandomizedTestingPlugin
import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.BuildPlugin
import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.Task import org.gradle.api.Task
@ -34,6 +35,9 @@ public class StandaloneTestBasePlugin implements Plugin<Project> {
@Override @Override
public void apply(Project project) { public void apply(Project project) {
if (project.pluginManager.hasPlugin('elasticsearch.build')) {
throw new InvalidUserDataException('elasticsearch.standalone-test and elasticsearch.build are mutually exclusive')
}
project.pluginManager.apply(JavaBasePlugin) project.pluginManager.apply(JavaBasePlugin)
project.pluginManager.apply(RandomizedTestingPlugin) project.pluginManager.apply(RandomizedTestingPlugin)
@ -41,7 +45,7 @@ public class StandaloneTestBasePlugin implements Plugin<Project> {
BuildPlugin.configureRepositories(project) BuildPlugin.configureRepositories(project)
// only setup tests to build // only setup tests to build
project.sourceSets.maybeCreate('test') project.sourceSets.create('test')
project.dependencies.add('testCompile', "org.elasticsearch.test:framework:${VersionProperties.elasticsearch}") project.dependencies.add('testCompile', "org.elasticsearch.test:framework:${VersionProperties.elasticsearch}")
project.eclipse.classpath.sourceSets = [project.sourceSets.test] project.eclipse.classpath.sourceSets = [project.sourceSets.test]
@ -49,10 +53,7 @@ public class StandaloneTestBasePlugin implements Plugin<Project> {
project.idea.module.testSourceDirs += project.sourceSets.test.java.srcDirs project.idea.module.testSourceDirs += project.sourceSets.test.java.srcDirs
project.idea.module.scopes['TEST'] = [plus: [project.configurations.testRuntime]] project.idea.module.scopes['TEST'] = [plus: [project.configurations.testRuntime]]
Task precommitTask = project.tasks.findByName('precommit')
if (precommitTask == null) {
PrecommitTasks.create(project, false) PrecommitTasks.create(project, false)
project.check.dependsOn(project.precommit) project.check.dependsOn(project.precommit)
} }
}
} }

View File

@ -104,6 +104,7 @@ subprojects {
/***************************************************************************** /*****************************************************************************
* Rest test config * * Rest test config *
*****************************************************************************/ *****************************************************************************/
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
project.integTest { project.integTest {
dependsOn project.assemble dependsOn project.assemble

View File

@ -1,3 +1,23 @@
/*
* 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.
*/
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
/* This project runs the core REST tests against a 2 node cluster where one of the nodes has a different minor. /* This project runs the core REST tests against a 2 node cluster where one of the nodes has a different minor.

View File

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
// TODO: this test works, but it isn't really a rest test...should we have another plugin for "non rest test that just needs N clusters?" // TODO: this test works, but it isn't really a rest test...should we have another plugin for "non rest test that just needs N clusters?"

View File

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
dependencies { dependencies {

View File

@ -22,7 +22,6 @@ package org.elasticsearch.http;
import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHeader;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
@ -317,7 +316,7 @@ public class ContextAndHeaderTransportIT extends HttpSmokeTestCase {
} }
@Override @Override
protected boolean apply(String action, ActionRequest request, ActionListener listener) { protected boolean apply(String action, ActionRequest request, ActionListener<?> listener) {
requests.add(new RequestAndHeaders(threadPool.getThreadContext().getHeaders(), request)); requests.add(new RequestAndHeaders(threadPool.getThreadContext().getHeaders(), request));
return true; return true;
} }

View File

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
dependencies { dependencies {

View File

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
dependencies { dependencies {

View File

@ -1,4 +1,23 @@
/*
* 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.
*/
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
integTest { integTest {

View File

@ -19,6 +19,7 @@
import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.MavenFilteringHack
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
ext.pluginsCount = 0 ext.pluginsCount = 0
@ -40,4 +41,3 @@ processTestResources {
inputs.properties(expansions) inputs.properties(expansions)
MavenFilteringHack.filter(it, expansions) MavenFilteringHack.filter(it, expansions)
} }

View File

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
integTest { integTest {

View File

@ -21,6 +21,7 @@ import org.elasticsearch.gradle.test.ClusterConfiguration
import org.elasticsearch.gradle.test.ClusterFormationTasks import org.elasticsearch.gradle.test.ClusterFormationTasks
import org.elasticsearch.gradle.test.NodeInfo import org.elasticsearch.gradle.test.NodeInfo
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
List<NodeInfo> oneNodes List<NodeInfo> oneNodes