[7.x] Convert most OSS plugins from integTest to [yaml | java]RestTest or internalClusterTest (#59444) (#60343)

For all OSS plugins (except repository-* and discovery-*) integTest
task is now a no-op and all of the tests are now executed via a test,
yamlRestTest, javaRestTest, or internalClusterTest.

This commit does NOT convert the discovery-* and repository-* since they
are bit more complex then the rest of tests and this PR is large enough.
Those plugins will be addressed in a future PR(s).

This commit also fixes a minor issue that did not copy the rest api
for projects that only had YAML TEST tests.

related: #56841
This commit is contained in:
Jake Landis 2020-07-29 13:06:13 -05:00 committed by GitHub
parent 39fa1c4df0
commit 6ce30bea08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
98 changed files with 58 additions and 55 deletions

View File

@ -198,7 +198,7 @@ public class CopyRestApiTask extends DefaultTask {
Set<File> resourceDir = testSources.getResources() Set<File> resourceDir = testSources.getResources()
.getSrcDirs() .getSrcDirs()
.stream() .stream()
.filter(f -> f.isDirectory() && f.getParentFile().getName().equals("test") && f.getName().equals("resources")) .filter(f -> f.isDirectory() && f.getParentFile().getName().equals(getSourceSetName()) && f.getName().equals("resources"))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
assert resourceDir.size() <= 1; assert resourceDir.size() <= 1;
if (resourceDir.size() == 0) { if (resourceDir.size() == 0) {

View File

@ -18,7 +18,8 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin { esplugin {
description 'The ICU Analysis plugin integrates the Lucene ICU module into Elasticsearch, adding ICU-related analysis components.' description 'The ICU Analysis plugin integrates the Lucene ICU module into Elasticsearch, adding ICU-related analysis components.'
@ -26,7 +27,7 @@ esplugin {
hasClientJar = true hasClientJar = true
} }
tasks.withType(CheckForbiddenApis).configureEach { forbiddenApisMain {
signatures += [ signatures += [
"com.ibm.icu.text.Collator#getInstance() @ Don't use default locale, use getInstance(ULocale) instead" "com.ibm.icu.text.Collator#getInstance() @ Don't use default locale, use getInstance(ULocale) instead"
] ]

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.' description 'The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.'
@ -32,7 +32,6 @@ restResources {
includeCore '_common', 'indices', 'index', 'search' includeCore '_common', 'indices', 'index', 'search'
} }
} }
tasks.named("dependencyLicenses").configure { tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene' mapping from: /lucene-.*/, to: 'lucene'
} }

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch.' description 'The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch.'
@ -32,6 +32,7 @@ restResources {
includeCore '_common', 'indices', 'index', 'search' includeCore '_common', 'indices', 'index', 'search'
} }
} }
tasks.named("dependencyLicenses").configure { tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene' mapping from: /lucene-.*/, to: 'lucene'
} }

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch.' description 'The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch.'

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch.' description 'Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch.'

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch.' description 'The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch.'

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch.' description 'The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch.'

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
name 'custom-settings' name 'custom-settings'
@ -28,7 +27,8 @@ esplugin {
noticeFile rootProject.file('NOTICE.txt') noticeFile rootProject.file('NOTICE.txt')
} }
testClusters.integTest { testClusters.all {
// Adds a setting in the Elasticsearch keystore before running the integration tests // Adds a setting in the Elasticsearch keystore before running the integration tests
keystore 'custom.secured', 'password' keystore 'custom.secured', 'password'
} }

View File

@ -7,7 +7,7 @@
* not use this file except in compliance with the License. * not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -26,11 +26,11 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
/** /**
* {@link ExampleCustomSettingsClientYamlTestSuiteIT} executes the plugin's REST API integration tests. * {@link ExampleCustomSettingsClientYamlTestSuiteIT} executes the plugin's REST API integration tests.
* <p> * <p>
* The tests can be executed using the command: ./gradlew :example-plugins:custom-settings:check * The tests can be executed using the command: ./gradlew :example-plugins:custom-settings:yamlRestTest
* <p> * <p>
* This class extends {@link ESClientYamlSuiteTestCase}, which takes care of parsing the YAML files * This class extends {@link ESClientYamlSuiteTestCase}, which takes care of parsing the YAML files
* located in the src/test/resources/rest-api-spec/test/ directory and validates them against the * located in the src/yamlRestTest/resources/rest-api-spec/test/ directory and validates them against the
* custom REST API definition files located in src/test/resources/rest-api-spec/api/. * custom REST API definition files located in src/yamlRestTest/resources/rest-api-spec/api/.
* <p> * <p>
* Once validated, {@link ESClientYamlSuiteTestCase} executes the REST tests against a single node * Once validated, {@link ESClientYamlSuiteTestCase} executes the REST tests against a single node
* integration cluster which has the plugin already installed by the Gradle build script. * integration cluster which has the plugin already installed by the Gradle build script.

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
name 'custom-significance-heuristic' name 'custom-significance-heuristic'

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
name 'custom-suggester' name 'custom-suggester'
@ -28,7 +27,7 @@ esplugin {
noticeFile rootProject.file('NOTICE.txt') noticeFile rootProject.file('NOTICE.txt')
} }
testClusters.integTest { testClusters.all {
numberOfNodes = 2 numberOfNodes = 2
} }

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
name 'painless-whitelist' name 'painless-whitelist'
@ -33,7 +32,7 @@ dependencies {
compileOnly "org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${versions.elasticsearch}" compileOnly "org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${versions.elasticsearch}"
} }
testClusters.integTest { testClusters.all {
testDistribution = 'oss' testDistribution = 'oss'
} }

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
name 'example-rescore' name 'example-rescore'
@ -27,4 +26,3 @@ esplugin {
licenseFile rootProject.file('licenses/APACHE-LICENSE-2.0.txt') licenseFile rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
noticeFile rootProject.file('NOTICE.txt') noticeFile rootProject.file('NOTICE.txt')
} }

View File

@ -18,9 +18,9 @@ import org.elasticsearch.gradle.info.BuildParams
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.java-rest-test'
esplugin { esplugin {
name 'rest-handler' name 'rest-handler'
@ -34,21 +34,16 @@ esplugin {
test.enabled = false test.enabled = false
tasks.register("exampleFixture", org.elasticsearch.gradle.test.AntFixture) { tasks.register("exampleFixture", org.elasticsearch.gradle.test.AntFixture) {
dependsOn testClasses dependsOn sourceSets.javaRestTest.runtimeClasspath
env 'CLASSPATH', "${-> project.sourceSets.test.runtimeClasspath.asPath}" env 'CLASSPATH', "${-> project.sourceSets.javaRestTest.runtimeClasspath.asPath}"
executable = "${BuildParams.runtimeJavaHome}/bin/java" executable = "${BuildParams.runtimeJavaHome}/bin/java"
args 'org.elasticsearch.example.resthandler.ExampleFixture', baseDir, 'TEST' args 'org.elasticsearch.example.resthandler.ExampleFixture', baseDir, 'TEST'
} }
integTest { javaRestTest {
dependsOn exampleFixture dependsOn exampleFixture
runner { runner {
nonInputProperties.systemProperty 'external.address', "${-> exampleFixture.addressAndPort}" nonInputProperties.systemProperty 'external.address', "${-> exampleFixture.addressAndPort}"
} }
} }
testingConventions.naming {
IT {
baseClass 'org.elasticsearch.test.ESTestCase'
}
}

View File

@ -26,11 +26,11 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
/** /**
* {@link ExampleRestHandlerClientYamlTestSuiteIT} executes the plugin's REST API integration tests. * {@link ExampleRestHandlerClientYamlTestSuiteIT} executes the plugin's REST API integration tests.
* <p> * <p>
* The tests can be executed using the command: ./gradlew :example-plugins:rest-handler:check * The tests can be executed using the command: ./gradlew :example-plugins:rest-handler:yamlRestTest
* <p> * <p>
* This class extends {@link ESClientYamlSuiteTestCase}, which takes care of parsing the YAML files * This class extends {@link ESClientYamlSuiteTestCase}, which takes care of parsing the YAML files
* located in the src/test/resources/rest-api-spec/test/ directory and validates them against the * located in the src/yamlRestTest/resources/rest-api-spec/test/ directory and validates them against the
* custom REST API definition files located in src/test/resources/rest-api-spec/api/. * custom REST API definition files located in src/yamlRestTest/resources/rest-api-spec/api/.
* <p> * <p>
* Once validated, {@link ESClientYamlSuiteTestCase} executes the REST tests against a single node * Once validated, {@link ESClientYamlSuiteTestCase} executes the REST tests against a single node
* integration cluster which has the plugin already installed by the Gradle build script. * integration cluster which has the plugin already installed by the Gradle build script.

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
name 'script-expert-scoring' name 'script-expert-scoring'

View File

@ -1,6 +1,5 @@
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.java-rest-test'
esplugin { esplugin {
name 'security-authorization-engine' name 'security-authorization-engine'
@ -13,17 +12,21 @@ esplugin {
dependencies { dependencies {
compileOnly "org.elasticsearch.plugin:x-pack-core:${versions.elasticsearch}" compileOnly "org.elasticsearch.plugin:x-pack-core:${versions.elasticsearch}"
testImplementation "org.elasticsearch.client:x-pack-transport:${versions.elasticsearch}" javaRestTestImplementation "org.elasticsearch.client:x-pack-transport:${versions.elasticsearch}"
javaRestTestImplementation "org.elasticsearch.plugin:x-pack-core:${versions.elasticsearch}"
// let the javaRestTest see the classpath of main
javaRestTestImplementation project.sourceSets.main.runtimeClasspath
} }
//no unit tests
integTest { test.enabled = false
javaRestTest {
dependsOn buildZip dependsOn buildZip
runner { runner {
systemProperty 'tests.security.manager', 'false' systemProperty 'tests.security.manager', 'false'
} }
} }
testClusters.integTest { testClusters.javaRestTest {
setting 'xpack.security.enabled', 'true' setting 'xpack.security.enabled', 'true'
setting 'xpack.ml.enabled', 'false' setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.license.self_generated.type', 'trial'
@ -36,4 +39,3 @@ testClusters.integTest {
user role: 'custom_superuser' user role: 'custom_superuser'
} }
check.dependsOn integTest

View File

@ -18,7 +18,7 @@ import org.elasticsearch.gradle.info.BuildParams
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
esplugin { esplugin {
description 'Ingest processor that uses Apache Tika to extract contents' description 'Ingest processor that uses Apache Tika to extract contents'

View File

@ -16,7 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin { esplugin {
description 'The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index.' description 'The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index.'

View File

@ -16,7 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin { esplugin {
description 'The Mapper Murmur3 plugin allows to compute hashes of a field\'s values at index-time and to store them in the index.' description 'The Mapper Murmur3 plugin allows to compute hashes of a field\'s values at index-time and to store them in the index.'
@ -28,3 +29,5 @@ restResources {
includeCore '_common', 'indices', 'index', 'search' includeCore '_common', 'indices', 'index', 'search'
} }
} }
// no unit tests
test.enabled = false

View File

@ -16,7 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin { esplugin {
description 'The Mapper Size plugin allows document to record their uncompressed size at index time.' description 'The Mapper Size plugin allows document to record their uncompressed size at index time.'
@ -28,3 +29,5 @@ restResources {
includeCore '_common', 'indices', 'index', 'get' includeCore '_common', 'indices', 'index', 'get'
} }
} }
// no unit tests
test.enabled = false

View File

@ -16,7 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin { esplugin {
description 'The Store SMB plugin adds support for SMB stores.' description 'The Store SMB plugin adds support for SMB stores.'

View File

@ -19,6 +19,7 @@ import org.elasticsearch.gradle.info.BuildParams
* under the License. * under the License.
*/ */
apply plugin: "elasticsearch.publish" apply plugin: "elasticsearch.publish"
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin { esplugin {
description 'The nio transport.' description 'The nio transport.'
@ -26,6 +27,8 @@ esplugin {
hasClientJar = true hasClientJar = true
} }
// integTest have been converted to internalClusterTest
integTest.enabled = false
dependencies { dependencies {
api project(':libs:elasticsearch-nio') api project(':libs:elasticsearch-nio')