Skip to content

Commit

Permalink
Convert modules to use yamlRestTest (#59089)
Browse files Browse the repository at this point in the history
This commit moves the modules REST tests to the
newly introduced yamlRestTest source set. A few
tests have also been re-named to include the correct
IT suffix. Without changing the names, the testing
conventions task would fail since now that the YAML
tests are no longer present pacify the convention.
These tests have moved to the internalClusterTest
source set.

related: #56841
  • Loading branch information
jakelandis authored Jul 13, 2020
1 parent 69899dc commit ddd882b
Show file tree
Hide file tree
Showing 168 changed files with 61 additions and 59 deletions.
4 changes: 3 additions & 1 deletion modules/aggs-matrix-stats/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 'Adds aggregations whose input are a list of numeric fields and output includes a matrix.'
Expand All @@ -28,3 +28,5 @@ restResources {
includeCore '_common', 'indices', 'cluster', 'index', 'search', 'nodes'
}
}

integTest.enabled = false
2 changes: 1 addition & 1 deletion modules/analysis-common/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 'Adds "built in" analyzers to Elasticsearch.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;

public class QueryStringWithAnalyzersTests extends ESIntegTestCase {
public class QueryStringWithAnalyzersIT extends ESIntegTestCase {
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(CommonAnalysisPlugin.class);
Expand Down
12 changes: 10 additions & 2 deletions modules/geo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'Placeholder plugin for geospatial features in ES. only registers geo_shape field mapper for now'
classname 'org.elasticsearch.geo.GeoPlugin'
}

restResources {
restApi {
includeCore '_common', 'indices', 'index', 'search'
}
}
artifacts {
restTests(new File(projectDir, "src/test/resources/rest-api-spec/test"))
restTests(project.file('src/yamlRestTest/resources/rest-api-spec/test'))
}

integTest.enabled = false
test.enabled = false
28 changes: 0 additions & 28 deletions modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java

This file was deleted.

4 changes: 2 additions & 2 deletions modules/ingest-common/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 'Module for ingest processors that do not require additional security permissions or have large dependencies and resources'
Expand All @@ -36,7 +36,7 @@ restResources {
}
}

testClusters.integTest {
testClusters.all {
// Needed in order to test ingest pipeline templating:
// (this is because the integTest node is not using default distribution, but only the minimal number of required modules)
module project(':modules:lang-mustache').tasks.bundlePlugin.archiveFile
Expand Down
5 changes: 4 additions & 1 deletion modules/ingest-geoip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
description 'Ingest processor that uses lookup geo data based on IP adresses using the MaxMind geo database'
Expand All @@ -42,6 +43,8 @@ restResources {
}
}

integTest.enabled = false

task copyDefaultGeoIp2DatabaseFiles(type: Copy) {
from { zipTree(configurations.testCompileClasspath.files.find { it.name.contains('geolite2-databases') }) }
into "${project.buildDir}/ingest-geoip"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;

public class GeoIpProcessorNonIngestNodeTests extends ESIntegTestCase {
public class GeoIpProcessorNonIngestNodeIT extends ESIntegTestCase {

public static class IngestGeoIpSettingsPlugin extends Plugin {

Expand Down
6 changes: 4 additions & 2 deletions modules/ingest-user-agent/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 'Ingest processor that extracts information from a user agent'
Expand All @@ -29,6 +29,8 @@ restResources {
}
}

testClusters.integTest {
testClusters.all {
extraConfigFile 'ingest-user-agent/test-regexes.yml', file('src/test/test-regexes.yml')
}

integTest.enabled = false
5 changes: 4 additions & 1 deletion modules/lang-expression/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 'Lucene expressions integration for Elasticsearch'
Expand All @@ -36,6 +37,8 @@ restResources {
}
}

integTest.enabled = false

tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene'
mapping from: /asm-.*/, to: 'asm'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import static org.hamcrest.Matchers.notNullValue;

// TODO: please convert to unit tests!
public class MoreExpressionTests extends ESIntegTestCase {
public class MoreExpressionIT extends ESIntegTestCase {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import static org.hamcrest.Matchers.containsString;

//TODO: please convert to unit tests!
public class StoredExpressionTests extends ESIntegTestCase {
public class StoredExpressionIT extends ESIntegTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal));
Expand Down
2 changes: 1 addition & 1 deletion modules/lang-mustache/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 'Mustache scripting integration for Elasticsearch'
Expand Down
6 changes: 4 additions & 2 deletions modules/lang-painless/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/

import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask;
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.validate-rest-spec'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'An easy, safe and fast scripting language for Elasticsearch'
classname 'org.elasticsearch.painless.PainlessPlugin'
}

testClusters.integTest {
testClusters.all {
module project(':modules:mapper-extras').tasks.bundlePlugin.archiveFile
systemProperty 'es.scripting.update.ctx_in_params', 'false'
// TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
Expand Down Expand Up @@ -54,6 +54,8 @@ restResources {
}
}

integTest.enabled = false

test {
// in WhenThingsGoWrongTests we intentionally generate an out of memory error, this prevents the heap from being dumped to disk
jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError'
Expand Down
2 changes: 1 addition & 1 deletion modules/mapper-extras/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 'Adds advanced field mappers'
Expand Down
2 changes: 1 addition & 1 deletion modules/parent-join/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 'This module adds the support parent-child queries and aggregations'
Expand Down
4 changes: 3 additions & 1 deletion modules/percolator/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 'Percolator module adds capability to index queries and query these queries by specifying documents'
Expand Down Expand Up @@ -45,3 +45,5 @@ restResources {
includeCore '_common', 'indices', 'index', 'search', 'msearch'
}
}

integTest.enabled = false
4 changes: 2 additions & 2 deletions modules/rank-eval/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 Rank Eval module adds APIs to evaluate ranking quality.'
Expand All @@ -29,7 +29,7 @@ restResources {
}
}

testClusters.integTest {
testClusters.all {
// Modules who's integration is explicitly tested in integration tests
module project(':modules:lang-mustache').tasks.bundlePlugin.archiveFile
}
4 changes: 2 additions & 2 deletions modules/reindex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import org.elasticsearch.gradle.info.BuildParams

apply plugin: 'elasticsearch.test-with-dependencies'
apply plugin: 'elasticsearch.jdk-download'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'

esplugin {
description 'The Reindex module adds APIs to reindex from one index to another or update documents in place.'
classname 'org.elasticsearch.index.reindex.ReindexPlugin'
}

testClusters.integTest {
testClusters.all {
// Modules who's integration is explicitly tested in integration tests
module project(':modules:parent-join').tasks.bundlePlugin.archiveFile
module project(':modules:lang-painless').tasks.bundlePlugin.archiveFile
Expand Down
14 changes: 11 additions & 3 deletions modules/repository-url/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import org.elasticsearch.gradle.PropertyNormalization
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.AntFixture

apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'


esplugin {
description 'Module for URL repository'
Expand All @@ -34,6 +36,8 @@ restResources {
}
}

integTest.enabled = false

// This directory is shared between two URL repositories and one FS repository in YAML integration tests
File repositoryDir = new File(project.buildDir, "shared-repository")

Expand All @@ -47,15 +51,19 @@ task urlFixture(type: AntFixture) {
executable = "${BuildParams.runtimeJavaHome}/bin/java"
args 'org.elasticsearch.repositories.url.URLFixture', baseDir, "${repositoryDir.absolutePath}"
}
yamlRestTest {
dependsOn urlFixture
}

integTest {
internalClusterTest {
dependsOn urlFixture
}
testClusters.integTest {
testClusters.all {
// repositoryDir is used by a FS repository to create snapshots
setting 'path.repo', "${repositoryDir.absolutePath}", PropertyNormalization.IGNORE_VALUE
// repositoryDir is used by two URL repositories to restore snapshots
setting 'repositories.url.allowed_urls', {
"http://snapshot.test*,http://${urlFixture.addressAndPort}"
}, PropertyNormalization.IGNORE_VALUE
}

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import static org.hamcrest.Matchers.notNullValue;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class URLSnapshotRestoreTests extends ESIntegTestCase {
public class URLSnapshotRestoreIT extends ESIntegTestCase {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void registerRepositories() throws IOException {

// Create a URL repository using the file://{path.repo} URL
Request createFileRepositoryRequest = new Request("PUT", "/_snapshot/repository-file");
createFileRepositoryRequest.setEntity(buildRepositorySettings(URLRepository.TYPE,
createFileRepositoryRequest.setEntity(buildRepositorySettings("url",
Settings.builder().put("url", pathRepoUri.toString()).build()));
Response createFileRepositoryResponse = client().performRequest(createFileRepositoryRequest);
assertThat(createFileRepositoryResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
Expand All @@ -106,7 +106,7 @@ public void registerRepositories() throws IOException {
InetAddress inetAddress = InetAddress.getByName(new URL(allowedUrl).getHost());
if (inetAddress.isAnyLocalAddress() || inetAddress.isLoopbackAddress()) {
Request createUrlRepositoryRequest = new Request("PUT", "/_snapshot/repository-url");
createUrlRepositoryRequest.setEntity(buildRepositorySettings(URLRepository.TYPE,
createUrlRepositoryRequest.setEntity(buildRepositorySettings("url",
Settings.builder().put("url", allowedUrl).build()));
Response createUrlRepositoryResponse = client().performRequest(createUrlRepositoryRequest);
assertThat(createUrlRepositoryResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
Expand Down
2 changes: 1 addition & 1 deletion modules/transport-netty4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.RestIntegTestTask

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

/*
TODOs:
Expand Down

0 comments on commit ddd882b

Please sign in to comment.