Skip to content

Convert most OSS plugins from integTest to [yaml | java]RestTest or internalClusterTest #59444

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
merged 32 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
376db42
start of migration
jakelandis Jul 11, 2020
1e56bb3
fix annoyning bug
jakelandis Jul 11, 2020
424fd5e
more conversion, ignore repository and store for now
jakelandis Jul 13, 2020
5fd84d2
Merge remote-tracking branch 'upstream/master' into yamlRestTest_plugins
jakelandis Jul 13, 2020
aa96ed8
remove temporary code
jakelandis Jul 13, 2020
dfebc85
remove unecessary todo
jakelandis Jul 13, 2020
2be2c71
remove unecessary todo
jakelandis Jul 13, 2020
c603b80
remove rouge plugin defintion
jakelandis Jul 13, 2020
bbc08f9
Merge branch 'master' into yamlRestTest_plugins
jakelandis Jul 21, 2020
a9a34d9
remove (now) unneccessary integTest.enabled=false
jakelandis Jul 21, 2020
5c75412
fix forbiden API and move test
jakelandis Jul 21, 2020
2fab21b
more migration
jakelandis Jul 22, 2020
cc09550
finish examples
jakelandis Jul 22, 2020
cd76cf4
more
jakelandis Jul 22, 2020
4a2d639
repository-azure
jakelandis Jul 22, 2020
8682017
repository-gcs
jakelandis Jul 22, 2020
4a1d8c8
repository-s3
jakelandis Jul 22, 2020
9414e3d
store-smb
jakelandis Jul 22, 2020
f2cf390
transport-nio
jakelandis Jul 22, 2020
21cc84a
Revert "repository-s3"
jakelandis Jul 22, 2020
ebb6703
Revert "repository-gcs"
jakelandis Jul 22, 2020
6147473
Revert "repository-azure"
jakelandis Jul 22, 2020
05e9421
Merge remote-tracking branch 'upstream/master' into yamlRestTest_plugins
jakelandis Jul 22, 2020
885c84a
minor
jakelandis Jul 22, 2020
4ea875a
manually rollback discovery-* changes
jakelandis Jul 22, 2020
ea705a5
white space change
jakelandis Jul 22, 2020
c89b5de
more nits
jakelandis Jul 22, 2020
849d19d
runtimeClasspath and unecessary variable
jakelandis Jul 23, 2020
ef34668
remove GradleUtils from build script
jakelandis Jul 23, 2020
7b07432
Merge branch 'master' into yamlRestTest_plugins
elasticmachine Jul 27, 2020
8058400
Merge remote-tracking branch 'upstream/master' into yamlRestTest_plugins
jakelandis Jul 27, 2020
1832e79
Merge remote-tracking branch 'upstream/master' into yamlRestTest_plugins
jakelandis Jul 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 8 additions & 5 deletions plugins/analysis-icu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ 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 {
signatures += [
"com.ibm.icu.text.Collator#getInstance() @ Don't use default locale, use getInstance(ULocale) instead"
]
List<String> forbidden_signatures = new ArrayList<>([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this of this intermediary variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it made sense when i was configuring multiple forbidden[name] ... but now not so much...will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 849d19d

"com.ibm.icu.text.Collator#getInstance() @ Don't use default locale, use getInstance(ULocale) instead"
])

forbiddenApisMain {
signatures += forbidden_signatures
}

dependencies {
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this needs to be all and not just yamlRestTest? Isn't there just one test cluster in play here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured the best example would be to use all , I think that should be the go-to configuration unless you need task specific config. (given the ease and cache behavior). Not a strong opinion however.

// 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 javaRestTestClasses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be dependsOn sourceSets.javaRestTest.runtimeClasspath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 849d19d

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
19 changes: 12 additions & 7 deletions plugins/examples/security-authorization-engine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.java-rest-test'

import org.elasticsearch.gradle.util.GradleUtils

esplugin {
name 'security-authorization-engine'
Expand All @@ -11,19 +12,24 @@ esplugin {
noticeFile rootProject.file('NOTICE.txt')
}

// let the javaRestTest see the classpath of main
GradleUtils.extendSourceSet(project, "main", "javaRestTest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary here but not done by default in the java rest test plugin?

Since this is an example project we should use idiomatic patterns as much as possible. If this is required because of some kind of nasty test implementation we should refactor this.

@rjernst thoughts? As I understand it a Java REST test should be no different than a YAML one in that the only interactions should be via the REST API, therefore there should be no need for plugin code itself to be on the test classpath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples are not exactly idomatic to start with, they could use some updating. In this case the test really does need to see the main classes, which should probably be converted to a ESSingleNodeTestCase or the tests written as pure black box ? I can log an issue, but probably outside the scope of this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't like the idea of GradleUtils being used in a plugin example. That's not intended to be "public". Worst case if the tests are structure such that they strictly need those classes, we should just extend the source set in the build script explicilty rather than leverage this utility method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case I am able to simply add the dependency to the main runtimeClasspath. ef34668

javaRestTestImplementation project.sourceSets.main.runtimeClasspath


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}"
}

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 +42,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
Loading