Skip to content

Commit

Permalink
Convert most OSS plugins from integTest to [yaml | java]RestTest or i…
Browse files Browse the repository at this point in the history
…nternalClusterTest (#59444)

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
  • Loading branch information
jakelandis authored Jul 28, 2020
1 parent cb0f8e1 commit 10be5d4
Show file tree
Hide file tree
Showing 98 changed files with 58 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private File getTestSourceResourceDir() {
Set<File> resourceDir = testSources.getResources()
.getSrcDirs()
.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());
assert resourceDir.size() <= 1;
if (resourceDir.size() == 0) {
Expand Down
5 changes: 3 additions & 2 deletions plugins/analysis-icu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
description 'The ICU Analysis plugin integrates the Lucene ICU module into Elasticsearch, adding ICU-related analysis components.'
classname 'org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin'
}

tasks.withType(CheckForbiddenApis).configureEach {
forbiddenApisMain {
signatures += [
"com.ibm.icu.text.Collator#getInstance() @ Don't use default locale, use getInstance(ULocale) instead"
]
Expand Down
3 changes: 1 addition & 2 deletions plugins/analysis-kuromoji/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.'
Expand All @@ -32,7 +32,6 @@ restResources {
includeCore '_common', 'indices', 'index', 'search'
}
}

tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene'
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/analysis-nori/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch.'
Expand All @@ -32,6 +32,7 @@ restResources {
includeCore '_common', 'indices', 'index', 'search'
}
}

tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene'
}
2 changes: 1 addition & 1 deletion plugins/analysis-phonetic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch.'
Expand Down
2 changes: 1 addition & 1 deletion plugins/analysis-smartcn/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch.'
Expand Down
2 changes: 1 addition & 1 deletion plugins/analysis-stempel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch.'
Expand Down
2 changes: 1 addition & 1 deletion plugins/analysis-ukrainian/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch.'
Expand Down
6 changes: 3 additions & 3 deletions plugins/examples/custom-settings/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
name 'custom-settings'
Expand All @@ -28,7 +27,8 @@ esplugin {
noticeFile rootProject.file('NOTICE.txt')
}

testClusters.integTest {
testClusters.all {
// Adds a setting in the Elasticsearch keystore before running the integration tests
keystore 'custom.secured', 'password'
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* 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
* 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
Expand All @@ -26,11 +26,11 @@
/**
* {@link ExampleCustomSettingsClientYamlTestSuiteIT} executes the plugin's REST API integration tests.
* <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>
* 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
* custom REST API definition files located in src/test/resources/rest-api-spec/api/.
* located in the src/yamlRestTest/resources/rest-api-spec/test/ directory and validates them against the
* custom REST API definition files located in src/yamlRestTest/resources/rest-api-spec/api/.
* <p>
* 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.
Expand Down
3 changes: 1 addition & 2 deletions plugins/examples/custom-significance-heuristic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
name 'custom-significance-heuristic'
Expand Down
5 changes: 2 additions & 3 deletions plugins/examples/custom-suggester/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
name 'custom-suggester'
Expand All @@ -28,7 +27,7 @@ esplugin {
noticeFile rootProject.file('NOTICE.txt')
}

testClusters.integTest {
testClusters.all {
numberOfNodes = 2
}

Expand Down
6 changes: 2 additions & 4 deletions plugins/examples/painless-whitelist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/

apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
name 'painless-whitelist'
Expand All @@ -34,7 +32,7 @@ dependencies {
compileOnly "org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${versions.elasticsearch}"
}

testClusters.integTest {
testClusters.all {
testDistribution = 'OSS'
}

Expand Down
4 changes: 1 addition & 3 deletions plugins/examples/rescore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
name 'example-rescore'
Expand All @@ -27,4 +26,3 @@ esplugin {
licenseFile rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
noticeFile rootProject.file('NOTICE.txt')
}

15 changes: 5 additions & 10 deletions plugins/examples/rest-handler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import org.elasticsearch.gradle.info.BuildParams
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.java-rest-test'

esplugin {
name 'rest-handler'
Expand All @@ -34,21 +34,16 @@ esplugin {
test.enabled = false

tasks.register("exampleFixture", org.elasticsearch.gradle.test.AntFixture) {
dependsOn testClasses
env 'CLASSPATH', "${-> project.sourceSets.test.runtimeClasspath.asPath}"
dependsOn sourceSets.javaRestTest.runtimeClasspath
env 'CLASSPATH', "${-> project.sourceSets.javaRestTest.runtimeClasspath.asPath}"
executable = "${BuildParams.runtimeJavaHome}/bin/java"
args 'org.elasticsearch.example.resthandler.ExampleFixture', baseDir, 'TEST'
}

integTest {
javaRestTest {
dependsOn exampleFixture
runner {
nonInputProperties.systemProperty 'external.address', "${-> exampleFixture.addressAndPort}"
}
}

testingConventions.naming {
IT {
baseClass 'org.elasticsearch.test.ESTestCase'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
/**
* {@link ExampleRestHandlerClientYamlTestSuiteIT} executes the plugin's REST API integration tests.
* <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>
* 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
* custom REST API definition files located in src/test/resources/rest-api-spec/api/.
* located in the src/yamlRestTest/resources/rest-api-spec/test/ directory and validates them against the
* custom REST API definition files located in src/yamlRestTest/resources/rest-api-spec/api/.
* <p>
* 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.
Expand Down
3 changes: 1 addition & 2 deletions plugins/examples/script-expert-scoring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
name 'script-expert-scoring'
Expand Down
16 changes: 9 additions & 7 deletions plugins/examples/security-authorization-engine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.java-rest-test'

esplugin {
name 'security-authorization-engine'
Expand All @@ -13,17 +12,21 @@ esplugin {

dependencies {
compileOnly "org.elasticsearch.plugin:x-pack-core:${versions.elasticsearch}"
testImplementation "org.elasticsearch.client:elasticsearch-rest-high-level-client:${versions.elasticsearch}"
javaRestTestImplementation "org.elasticsearch.plugin:x-pack-core:${versions.elasticsearch}"
javaRestTestImplementation "org.elasticsearch.client:elasticsearch-rest-high-level-client:${versions.elasticsearch}"
// let the javaRestTest see the classpath of main
javaRestTestImplementation project.sourceSets.main.runtimeClasspath
}

integTest {
//no unit tests
test.enabled = false
javaRestTest {
dependsOn buildZip
runner {
systemProperty 'tests.security.manager', 'false'
}
}

testClusters.integTest {
testClusters.javaRestTest {
setting 'xpack.security.enabled', 'true'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
Expand All @@ -36,4 +39,3 @@ testClusters.integTest {
user role: 'custom_superuser'
}

check.dependsOn integTest
2 changes: 1 addition & 1 deletion plugins/ingest-attachment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.elasticsearch.gradle.info.BuildParams
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'Ingest processor that uses Apache Tika to extract contents'
Expand Down
3 changes: 2 additions & 1 deletion plugins/mapper-annotated-text/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
description 'The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index.'
Expand Down
5 changes: 4 additions & 1 deletion plugins/mapper-murmur3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

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.'
Expand All @@ -28,3 +29,5 @@ restResources {
includeCore '_common', 'indices', 'index', 'search'
}
}
// no unit tests
test.enabled = false
5 changes: 4 additions & 1 deletion plugins/mapper-size/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
description 'The Mapper Size plugin allows document to record their uncompressed size at index time.'
Expand All @@ -28,3 +29,5 @@ restResources {
includeCore '_common', 'indices', 'index', 'get'
}
}
// no unit tests
test.enabled = false
3 changes: 2 additions & 1 deletion plugins/store-smb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
description 'The Store SMB plugin adds support for SMB stores.'
Expand Down
3 changes: 3 additions & 0 deletions plugins/transport-nio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ import org.elasticsearch.gradle.info.BuildParams
* under the License.
*/
apply plugin: "elasticsearch.publish"
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
description 'The nio transport.'
classname 'org.elasticsearch.transport.nio.NioTransportPlugin'
}

// integTest have been converted to internalClusterTest
integTest.enabled = false
dependencies {
api project(':libs:elasticsearch-nio')

Expand Down

0 comments on commit 10be5d4

Please sign in to comment.