Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions plugins/repository-azure/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.elasticsearch.gradle.MavenFilteringHack
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.InternalClusterTestPlugin

import static org.elasticsearch.gradle.PropertyNormalization.DEFAULT
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
Expand All @@ -22,7 +23,8 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
* 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 Azure Repository plugin adds support for Azure storage repositories.'
Expand Down Expand Up @@ -106,18 +108,18 @@ Map<String, Object> expansions = [
'base_path': azureBasePath + "_integration_tests"
]

processTestResources {
processYamlRestTestResources {
inputs.properties(expansions)
MavenFilteringHack.filter(it, expansions)
}

test {
internalClusterTest {
// this is tested explicitly in a separate test task
exclude '**/AzureStorageCleanupThirdPartyTests.class'
}

testClusters {
integTest {
yamlRestTest {
keystore 'azure.client.integration_test.account', azureAccount
if (azureKey != null && azureKey.isEmpty() == false) {
keystore 'azure.client.integration_test.key', azureKey
Expand All @@ -134,7 +136,11 @@ testClusters {
}

task azureThirdPartyTest(type: Test) {
dependsOn tasks.integTest
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME)
setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs())
setClasspath(internalTestSourceSet.getRuntimeClasspath())
dependsOn tasks.internalClusterTest
include '**/AzureStorageCleanupThirdPartyTests.class'
systemProperty 'test.azure.account', azureAccount ? azureAccount : ""
systemProperty 'test.azure.key', azureKey ? azureKey : ""
Expand Down
34 changes: 22 additions & 12 deletions plugins/repository-gcs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import java.security.KeyPairGenerator
import org.elasticsearch.gradle.MavenFilteringHack
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.test.rest.YamlRestTestPlugin
import org.elasticsearch.gradle.test.InternalClusterTestPlugin

import java.nio.file.Files
import java.security.KeyPair
Expand All @@ -28,7 +30,8 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
* 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 GCS repository plugin adds Google Cloud Storage support for repositories.'
Expand Down Expand Up @@ -254,12 +257,12 @@ Map<String, Object> expansions = [
'base_path': gcsBasePath + "_integration_tests"
]

processTestResources {
processYamlRestTestResources {
inputs.properties(expansions)
MavenFilteringHack.filter(it, expansions)
}

test {
internalClusterTest {
// this is tested explicitly in a separate test task
exclude '**/GoogleCloudStorageThirdPartyTests.class'
}
Expand All @@ -276,33 +279,37 @@ final Closure testClustersConfiguration = {
}
}

integTest {
yamlRestTest {
if (useFixture) {
dependsOn createServiceAccountFile
}
}
check.dependsOn integTest

testClusters {
integTest testClustersConfiguration
all testClustersConfiguration
}

/*
* We only use a small amount of data in these tests, which means that the resumable upload path is not tested. We add
* an additional test that forces the large blob threshold to be small to exercise the resumable upload path.
*/
task largeBlobIntegTest(type: RestIntegTestTask) {
mustRunAfter integTest
task largeBlobYamlRestTest(type: RestIntegTestTask) {
dependsOn project(':plugins:repository-gcs').bundlePlugin
if (useFixture) {
dependsOn createServiceAccountFile
}
runner {
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet yamlRestTestSourceSet = sourceSets.getByName(YamlRestTestPlugin.SOURCE_SET_NAME)
setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())
}
}
check.dependsOn largeBlobIntegTest

testClusters.largeBlobIntegTest testClustersConfiguration
check.dependsOn largeBlobYamlRestTest

testClusters {
largeBlobIntegTest {
largeBlobYamlRestTest {
plugin project(':plugins:repository-gcs').bundlePlugin.archiveFile

// force large blob uploads by setting the threshold small, forcing this code path to be tested
Expand All @@ -311,7 +318,10 @@ testClusters {
}

task gcsThirdPartyTest(type: Test) {
dependsOn integTest,largeBlobIntegTest
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should think about building up some kind of convenience around this sort of thing.

Copy link
Member

Choose a reason for hiding this comment

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

Why isn't the yaml-rest-test plugin doing this setup?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not that simple. By default the java plugin wires up all tasks of type Test with the test source set. What happens when we have a project with multiple test source sets, and then we manually create a Test task? Which source set should it default to?

Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry, I misread this as the main yaml test, but i realize now this is another test task also utilizing the new source set. I agree then a helper or something to do this would be good, as it seems used several times in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed , I will take a look (in a future PR) for any way to simplify this boiler plate.

SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME)
setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs())
setClasspath(internalTestSourceSet.getRuntimeClasspath())
include '**/GoogleCloudStorageThirdPartyTests.class'
systemProperty 'tests.security.manager', false
systemProperty 'test.google.bucket', gcsBucket
Expand Down
49 changes: 33 additions & 16 deletions plugins/repository-s3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.elasticsearch.gradle.MavenFilteringHack
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.test.rest.YamlRestTestPlugin
import org.elasticsearch.gradle.test.InternalClusterTestPlugin

import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

Expand All @@ -22,7 +24,8 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
* 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 S3 repository plugin adds S3 repositories'
Expand Down Expand Up @@ -55,6 +58,12 @@ dependencies {
testImplementation project(':test:fixtures:s3-fixture')
}

restResources {
restApi {
includeCore '_common', 'cluster', 'nodes', 'snapshot','indices', 'index', 'bulk', 'count'
}
}

tasks.named("dependencyLicenses").configure {
mapping from: /aws-java-sdk-.*/, to: 'aws-java-sdk'
mapping from: /jmespath-java.*/, to: 'aws-java-sdk'
Expand Down Expand Up @@ -135,7 +144,7 @@ if (!s3EC2Bucket && !s3EC2BasePath && !s3ECSBucket && !s3ECSBasePath) {
throw new IllegalArgumentException("not all options specified to run EC2/ECS tests are present")
}

processTestResources {
processYamlRestTestResources {
Map<String, Object> expansions = [
'permanent_bucket' : s3PermanentBucket,
'permanent_base_path' : s3PermanentBasePath + "_integration_tests",
Expand All @@ -151,13 +160,12 @@ processTestResources {
MavenFilteringHack.filter(it, expansions)
}

test {
internalClusterTest {
// this is tested explicitly in a separate test task
exclude '**/S3RepositoryThirdPartyTests.class'
}

// IntegTest
integTest {
yamlRestTest {
runner {
systemProperty 'tests.rest.blacklist', (
useFixture ?
Expand All @@ -172,7 +180,7 @@ integTest {
}
}

testClusters.integTest {
testClusters.yamlRestTest {
keystore 's3.client.integration_test_permanent.access_key', s3PermanentAccessKey
keystore 's3.client.integration_test_permanent.secret_key', s3PermanentSecretKey

Expand Down Expand Up @@ -207,10 +215,15 @@ testClusters.integTest {
if (useFixture) {
testFixtures.useFixture(':test:fixtures:minio-fixture', 'minio-fixture')

task integTestMinio(type: RestIntegTestTask) {
task yamlRestTestMinio(type: RestIntegTestTask) {
description = "Runs REST tests using the Minio repository."
dependsOn tasks.bundlePlugin
runner {
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet yamlRestTestSourceSet = sourceSets.getByName(YamlRestTestPlugin.SOURCE_SET_NAME)
setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())

// Minio only supports a single access key, see https://github.com/minio/minio/pull/5968
systemProperty 'tests.rest.blacklist', [
'repository_s3/30_repository_temporary_credentials/*',
Expand All @@ -219,9 +232,9 @@ if (useFixture) {
].join(",")
}
}
check.dependsOn(integTestMinio)
check.dependsOn(yamlRestTestMinio)

testClusters.integTestMinio {
testClusters.yamlRestTestMinio {
keystore 's3.client.integration_test_permanent.access_key', s3PermanentAccessKey
keystore 's3.client.integration_test_permanent.secret_key', s3PermanentSecretKey
setting 's3.client.integration_test_permanent.endpoint', { "${-> fixtureAddress('minio-fixture', 'minio-fixture', '9000')}" }, IGNORE_VALUE
Expand All @@ -232,11 +245,14 @@ if (useFixture) {
// ECS
if (useFixture) {
testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-with-ecs')

task integTestECS(type: RestIntegTestTask.class) {
task yamlRestTestECS(type: RestIntegTestTask.class) {
description = "Runs tests using the ECS repository."
dependsOn('bundlePlugin')
runner {
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet yamlRestTestSourceSet = sourceSets.getByName(YamlRestTestPlugin.SOURCE_SET_NAME)
setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())
systemProperty 'tests.rest.blacklist', [
'repository_s3/10_basic/*',
'repository_s3/20_repository_permanent_credentials/*',
Expand All @@ -245,9 +261,9 @@ if (useFixture) {
].join(",")
}
}
check.dependsOn(integTestECS)
check.dependsOn(yamlRestTestECS)

testClusters.integTestECS {
testClusters.yamlRestTestECS {
setting 's3.client.integration_test_ecs.endpoint', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ecs', '80')}" }, IGNORE_VALUE
plugin tasks.bundlePlugin.archiveFile
environment 'AWS_CONTAINER_CREDENTIALS_FULL_URI', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ecs', '80')}/ecs_credentials_endpoint" }, IGNORE_VALUE
Expand All @@ -256,16 +272,17 @@ if (useFixture) {

// 3rd Party Tests
task s3ThirdPartyTest(type: Test) {
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME)
setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs())
setClasspath(internalTestSourceSet.getRuntimeClasspath())
include '**/S3RepositoryThirdPartyTests.class'
systemProperty 'test.s3.account', s3PermanentAccessKey
systemProperty 'test.s3.key', s3PermanentSecretKey
systemProperty 'test.s3.bucket', s3PermanentBucket
nonInputProperties.systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + BuildParams.testSeed
if (useFixture) {
dependsOn tasks.integTestMinio
nonInputProperties.systemProperty 'test.s3.endpoint', "${-> fixtureAddress('minio-fixture', 'minio-fixture', '9000') }"
} else {
dependsOn tasks.integTest
}
}
check.dependsOn(s3ThirdPartyTest)
Expand Down
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 Down Expand Up @@ -304,3 +304,4 @@ private boolean isMultiPartUpload(String request) {
}
}
}