|
@@ -22,8 +22,6 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
|
|
* specific language governing permissions and limitations
|
|
|
* under the License.
|
|
|
*/
|
|
|
-apply plugin: 'elasticsearch.test.fixtures'
|
|
|
-
|
|
|
esplugin {
|
|
|
description 'The S3 repository plugin adds S3 repositories'
|
|
|
classname 'org.elasticsearch.repositories.s3.S3RepositoryPlugin'
|
|
@@ -68,13 +66,15 @@ bundlePlugin {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-test {
|
|
|
- // this is tested explicitly in separate test tasks
|
|
|
- exclude '**/S3RepositoryThirdPartyTests.class'
|
|
|
-}
|
|
|
-
|
|
|
boolean useFixture = false
|
|
|
|
|
|
+def fixtureAddress = { fixture, name, port ->
|
|
|
+ assert useFixture: 'closure should not be used without a fixture'
|
|
|
+ int ephemeralPort = project(":test:fixtures:${fixture}").postProcessFixture.ext."test.fixtures.${name}.tcp.${port}"
|
|
|
+ assert ephemeralPort > 0
|
|
|
+ 'http://127.0.0.1:' + ephemeralPort
|
|
|
+}
|
|
|
+
|
|
|
// We test against two repositories, one which uses the usual two-part "permanent" credentials and
|
|
|
// the other which uses three-part "temporary" or "session" credentials.
|
|
|
|
|
@@ -106,6 +106,7 @@ if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3P
|
|
|
s3PermanentBucket = 'bucket'
|
|
|
s3PermanentBasePath = 'base_path'
|
|
|
|
|
|
+ apply plugin: 'elasticsearch.test.fixtures'
|
|
|
useFixture = true
|
|
|
|
|
|
} else if (!s3PermanentAccessKey || !s3PermanentSecretKey || !s3PermanentBucket || !s3PermanentBasePath) {
|
|
@@ -132,72 +133,6 @@ if (!s3EC2Bucket && !s3EC2BasePath && !s3ECSBucket && !s3ECSBasePath) {
|
|
|
throw new IllegalArgumentException("not all options specified to run EC2/ECS tests are present")
|
|
|
}
|
|
|
|
|
|
-task thirdPartyTest(type: Test) {
|
|
|
- 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) {
|
|
|
- testFixtures.useFixture(':test:fixtures:minio-fixture', 'minio-fixture')
|
|
|
-
|
|
|
- def minioAddress = {
|
|
|
- int minioPort = project(':test:fixtures:minio-fixture').postProcessFixture.ext."test.fixtures.minio-fixture.tcp.9000"
|
|
|
- assert minioPort > 0
|
|
|
- 'http://127.0.0.1:' + minioPort
|
|
|
- }
|
|
|
-
|
|
|
- normalization {
|
|
|
- runtimeClasspath {
|
|
|
- // ignore generated address file for the purposes of build avoidance
|
|
|
- ignore 's3Fixture.address'
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- thirdPartyTest {
|
|
|
- dependsOn tasks.bundlePlugin
|
|
|
- nonInputProperties.systemProperty 'test.s3.endpoint', "${ -> minioAddress.call() }"
|
|
|
- }
|
|
|
-
|
|
|
- task integTestMinio(type: RestIntegTestTask) {
|
|
|
- description = "Runs REST tests using the Minio repository."
|
|
|
- dependsOn tasks.bundlePlugin
|
|
|
- runner {
|
|
|
- // 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/*',
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
- 'repository_s3/50_repository_ecs_credentials/*'
|
|
|
- ].join(",")
|
|
|
- }
|
|
|
- }
|
|
|
- check.dependsOn(integTestMinio)
|
|
|
-
|
|
|
- testClusters.integTestMinio {
|
|
|
- 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', minioAddress, IGNORE_VALUE
|
|
|
- plugin tasks.bundlePlugin.archiveFile
|
|
|
- }
|
|
|
-
|
|
|
- integTest.runner {
|
|
|
- systemProperty 'tests.rest.blacklist', 'repository_s3/50_repository_ecs_credentials/*'
|
|
|
- }
|
|
|
-} else {
|
|
|
- integTest.runner {
|
|
|
- systemProperty 'tests.rest.blacklist',
|
|
|
- [
|
|
|
- 'repository_s3/30_repository_temporary_credentials/*',
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
- 'repository_s3/50_repository_ecs_credentials/*'
|
|
|
- ].join(",")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-check.dependsOn(thirdPartyTest)
|
|
|
-
|
|
|
processTestResources {
|
|
|
Map<String, Object> expansions = [
|
|
|
'permanent_bucket' : s3PermanentBucket,
|
|
@@ -214,18 +149,25 @@ processTestResources {
|
|
|
MavenFilteringHack.filter(it, expansions)
|
|
|
}
|
|
|
|
|
|
-[
|
|
|
- 's3-fixture',
|
|
|
- 's3-fixture-with-session-token',
|
|
|
- 's3-fixture-with-ec2',
|
|
|
- 's3-fixture-with-ecs',
|
|
|
-].forEach { fixture -> testFixtures.useFixture(':test:fixtures:s3-fixture', fixture) }
|
|
|
+test {
|
|
|
+ // this is tested explicitly in a separate test task
|
|
|
+ exclude '**/S3RepositoryThirdPartyTests.class'
|
|
|
+}
|
|
|
|
|
|
-def fixtureAddress = { fixture ->
|
|
|
- assert useFixture: 'closure should not be used without a fixture'
|
|
|
- int ephemeralPort = project(':test:fixtures:s3-fixture').postProcessFixture.ext."test.fixtures.${fixture}.tcp.80"
|
|
|
- assert ephemeralPort > 0
|
|
|
- 'http://127.0.0.1:' + ephemeralPort
|
|
|
+// IntegTest
|
|
|
+integTest {
|
|
|
+ runner {
|
|
|
+ systemProperty 'tests.rest.blacklist', (
|
|
|
+ useFixture ?
|
|
|
+ ['repository_s3/50_repository_ecs_credentials/*']
|
|
|
+ :
|
|
|
+ [
|
|
|
+ 'repository_s3/30_repository_temporary_credentials/*',
|
|
|
+ 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
+ 'repository_s3/50_repository_ecs_credentials/*'
|
|
|
+ ]
|
|
|
+ ).join(",")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
testClusters.integTest {
|
|
@@ -237,22 +179,58 @@ testClusters.integTest {
|
|
|
keystore 's3.client.integration_test_temporary.session_token', s3TemporarySessionToken
|
|
|
|
|
|
if (useFixture) {
|
|
|
- setting 's3.client.integration_test_permanent.endpoint', { "${-> fixtureAddress('s3-fixture')}" }, IGNORE_VALUE
|
|
|
- setting 's3.client.integration_test_temporary.endpoint', { "${-> fixtureAddress('s3-fixture-with-session-token')}" }, IGNORE_VALUE
|
|
|
- setting 's3.client.integration_test_ec2.endpoint', { "${-> fixtureAddress('s3-fixture-with-ec2')}" }, IGNORE_VALUE
|
|
|
+ testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture')
|
|
|
+ testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-with-session-token')
|
|
|
+ testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-with-ec2')
|
|
|
+
|
|
|
+ normalization {
|
|
|
+ runtimeClasspath {
|
|
|
+ // ignore generated address file for the purposes of build avoidance
|
|
|
+ ignore 's3Fixture.address'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ setting 's3.client.integration_test_permanent.endpoint', { "${-> fixtureAddress('s3-fixture', 's3-fixture', '80')}" }, IGNORE_VALUE
|
|
|
+ setting 's3.client.integration_test_temporary.endpoint', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-session-token', '80')}" }, IGNORE_VALUE
|
|
|
+ setting 's3.client.integration_test_ec2.endpoint', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ec2', '80')}" }, IGNORE_VALUE
|
|
|
|
|
|
// to redirect InstanceProfileCredentialsProvider to custom auth point
|
|
|
- systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", { "${-> fixtureAddress('s3-fixture-with-ec2')}" }, IGNORE_VALUE
|
|
|
+ systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ec2', '80')}" }, IGNORE_VALUE
|
|
|
} else {
|
|
|
println "Using an external service to test the repository-s3 plugin"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-task s3ThirdPartyTests {
|
|
|
- dependsOn check
|
|
|
+// MinIO
|
|
|
+if (useFixture) {
|
|
|
+ testFixtures.useFixture(':test:fixtures:minio-fixture', 'minio-fixture')
|
|
|
+
|
|
|
+ task integTestMinio(type: RestIntegTestTask) {
|
|
|
+ description = "Runs REST tests using the Minio repository."
|
|
|
+ dependsOn tasks.bundlePlugin
|
|
|
+ runner {
|
|
|
+ // 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/*',
|
|
|
+ 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
+ 'repository_s3/50_repository_ecs_credentials/*'
|
|
|
+ ].join(",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ check.dependsOn(integTestMinio)
|
|
|
+
|
|
|
+ testClusters.integTestMinio {
|
|
|
+ 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
|
|
|
+ plugin tasks.bundlePlugin.archiveFile
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+// ECS
|
|
|
if (useFixture) {
|
|
|
+ testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-with-ecs')
|
|
|
+
|
|
|
task integTestECS(type: RestIntegTestTask.class) {
|
|
|
description = "Runs tests using the ECS repository."
|
|
|
dependsOn('bundlePlugin')
|
|
@@ -268,18 +246,27 @@ if (useFixture) {
|
|
|
check.dependsOn(integTestECS)
|
|
|
|
|
|
testClusters.integTestECS {
|
|
|
- setting 's3.client.integration_test_ecs.endpoint', { "${-> fixtureAddress('s3-fixture-with-ecs')}" }, IGNORE_VALUE
|
|
|
+ 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-with-ecs')}/ecs_credentials_endpoint" }, IGNORE_VALUE
|
|
|
+ environment 'AWS_CONTAINER_CREDENTIALS_FULL_URI', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ecs', '80')}/ecs_credentials_endpoint" }, IGNORE_VALUE
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- gradle.taskGraph.whenReady {
|
|
|
- if (it.hasTask(s3ThirdPartyTests)) {
|
|
|
- throw new IllegalStateException("Tried to run third party tests but not all of the necessary environment variables 'amazon_s3_access_key', " +
|
|
|
- "'amazon_s3_secret_key', 'amazon_s3_bucket', and 'amazon_s3_base_path' are set.");
|
|
|
- }
|
|
|
+// 3rd Party Tests
|
|
|
+task s3ThirdPartyTest(type: Test) {
|
|
|
+ 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)
|
|
|
|
|
|
thirdPartyAudit.ignoreMissingClasses(
|
|
|
// classes are missing
|