|
@@ -1,11 +1,7 @@
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
import org.elasticsearch.gradle.internal.info.BuildParams
|
|
import org.elasticsearch.gradle.internal.info.BuildParams
|
|
-import org.elasticsearch.gradle.internal.test.RestIntegTestTask
|
|
|
|
-import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin
|
|
|
|
import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin
|
|
import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin
|
|
|
|
|
|
-import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -13,7 +9,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
* Side Public License, v 1.
|
|
*/
|
|
*/
|
|
-apply plugin: 'elasticsearch.legacy-yaml-rest-test'
|
|
|
|
|
|
+apply plugin: 'elasticsearch.internal-yaml-rest-test'
|
|
apply plugin: 'elasticsearch.internal-cluster-test'
|
|
apply plugin: 'elasticsearch.internal-cluster-test'
|
|
|
|
|
|
esplugin {
|
|
esplugin {
|
|
@@ -46,6 +42,12 @@ dependencies {
|
|
api 'javax.xml.bind:jaxb-api:2.2.2'
|
|
api 'javax.xml.bind:jaxb-api:2.2.2'
|
|
|
|
|
|
testImplementation project(':test:fixtures:s3-fixture')
|
|
testImplementation project(':test:fixtures:s3-fixture')
|
|
|
|
+ yamlRestTestImplementation project(":test:framework")
|
|
|
|
+ yamlRestTestImplementation project(':test:fixtures:s3-fixture')
|
|
|
|
+ yamlRestTestImplementation project(':test:fixtures:minio-fixture')
|
|
|
|
+ internalClusterTestImplementation project(':test:fixtures:minio-fixture')
|
|
|
|
+
|
|
|
|
+ yamlRestTestRuntimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}"
|
|
}
|
|
}
|
|
|
|
|
|
restResources {
|
|
restResources {
|
|
@@ -83,13 +85,6 @@ tasks.named('test').configure {
|
|
|
|
|
|
boolean useFixture = false
|
|
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
|
|
// 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.
|
|
// the other which uses three-part "temporary" or "session" credentials.
|
|
|
|
|
|
@@ -124,7 +119,6 @@ if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3P
|
|
s3PermanentBucket = 'bucket'
|
|
s3PermanentBucket = 'bucket'
|
|
s3PermanentBasePath = 'base_path'
|
|
s3PermanentBasePath = 'base_path'
|
|
|
|
|
|
- apply plugin: 'elasticsearch.test.fixtures'
|
|
|
|
useFixture = true
|
|
useFixture = true
|
|
|
|
|
|
} else if (!s3PermanentAccessKey || !s3PermanentSecretKey || !s3PermanentBucket || !s3PermanentBasePath) {
|
|
} else if (!s3PermanentAccessKey || !s3PermanentSecretKey || !s3PermanentBucket || !s3PermanentBasePath) {
|
|
@@ -159,6 +153,9 @@ if (!s3STSBucket && !s3STSBasePath) {
|
|
}
|
|
}
|
|
|
|
|
|
tasks.named("processYamlRestTestResources").configure {
|
|
tasks.named("processYamlRestTestResources").configure {
|
|
|
|
+ from("src/test/resources") {
|
|
|
|
+ include "aws-web-identity-token-file"
|
|
|
|
+ }
|
|
Map<String, Object> expansions = [
|
|
Map<String, Object> expansions = [
|
|
'permanent_bucket' : s3PermanentBucket,
|
|
'permanent_bucket' : s3PermanentBucket,
|
|
'permanent_base_path' : s3PermanentBasePath + "_integration_tests",
|
|
'permanent_base_path' : s3PermanentBasePath + "_integration_tests",
|
|
@@ -182,197 +179,35 @@ tasks.named("internalClusterTest").configure {
|
|
}
|
|
}
|
|
|
|
|
|
tasks.named("yamlRestTest").configure {
|
|
tasks.named("yamlRestTest").configure {
|
|
- systemProperty 'tests.rest.blacklist', (
|
|
|
|
- useFixture ?
|
|
|
|
- ['repository_s3/50_repository_ecs_credentials/*',
|
|
|
|
- 'repository_s3/60_repository_sts_credentials/*']
|
|
|
|
- :
|
|
|
|
- [
|
|
|
|
- 'repository_s3/30_repository_temporary_credentials/*',
|
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
|
- 'repository_s3/50_repository_ecs_credentials/*',
|
|
|
|
- 'repository_s3/60_repository_sts_credentials/*'
|
|
|
|
- ]
|
|
|
|
- ).join(",")
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-if (useFixture) {
|
|
|
|
- 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'
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-testClusters.matching { it.name == "yamlRestTest" }.configureEach {
|
|
|
|
- keystore 's3.client.integration_test_permanent.access_key', s3PermanentAccessKey
|
|
|
|
- keystore 's3.client.integration_test_permanent.secret_key', s3PermanentSecretKey
|
|
|
|
-
|
|
|
|
- keystore 's3.client.integration_test_temporary.access_key', s3TemporaryAccessKey
|
|
|
|
- keystore 's3.client.integration_test_temporary.secret_key', s3TemporarySecretKey
|
|
|
|
- keystore 's3.client.integration_test_temporary.session_token', s3TemporarySessionToken
|
|
|
|
-
|
|
|
|
- if (useFixture) {
|
|
|
|
- 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', 's3-fixture-with-ec2', '80')}" }, IGNORE_VALUE
|
|
|
|
- } else {
|
|
|
|
- println "Using an external service to test the repository-s3 plugin"
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MinIO
|
|
|
|
-if (useFixture) {
|
|
|
|
- testFixtures.useFixture(':test:fixtures:minio-fixture', 'minio-fixture')
|
|
|
|
-
|
|
|
|
- tasks.register("yamlRestTestMinio", RestIntegTestTask) {
|
|
|
|
- description = "Runs REST tests using the Minio repository."
|
|
|
|
- SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
|
|
|
- SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.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/*',
|
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
|
- 'repository_s3/50_repository_ecs_credentials/*',
|
|
|
|
- 'repository_s3/60_repository_sts_credentials/*'
|
|
|
|
- ].join(",")
|
|
|
|
- }
|
|
|
|
- tasks.named("check").configure { dependsOn("yamlRestTestMinio") }
|
|
|
|
-
|
|
|
|
- testClusters.matching { it.name == "yamlRestTestMinio" }.configureEach {
|
|
|
|
- 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
|
|
|
|
- module tasks.named("explodedBundlePlugin")
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ECS
|
|
|
|
-if (useFixture) {
|
|
|
|
- testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-with-ecs')
|
|
|
|
- tasks.register("yamlRestTestECS", RestIntegTestTask.class) {
|
|
|
|
- description = "Runs tests using the ECS repository."
|
|
|
|
- SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
|
|
|
- SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME)
|
|
|
|
- setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
|
|
|
|
- setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())
|
|
|
|
- systemProperty 'tests.rest.blacklist', [
|
|
|
|
- 'repository_s3/10_basic/*',
|
|
|
|
- 'repository_s3/20_repository_permanent_credentials/*',
|
|
|
|
- 'repository_s3/30_repository_temporary_credentials/*',
|
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
|
- 'repository_s3/60_repository_sts_credentials/*'
|
|
|
|
- ].join(",")
|
|
|
|
- }
|
|
|
|
- tasks.named("check").configure { dependsOn("yamlRestTestECS") }
|
|
|
|
-
|
|
|
|
- testClusters.matching { it.name == "yamlRestTestECS" }.configureEach {
|
|
|
|
- setting 's3.client.integration_test_ecs.endpoint', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ecs', '80')}" }, IGNORE_VALUE
|
|
|
|
- module tasks.named('explodedBundlePlugin')
|
|
|
|
- environment 'AWS_CONTAINER_CREDENTIALS_FULL_URI', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-ecs', '80')}/ecs_credentials_endpoint" }, IGNORE_VALUE
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// STS (Secure Token Service)
|
|
|
|
-if (useFixture) {
|
|
|
|
- testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-with-sts')
|
|
|
|
- tasks.register("yamlRestTestSTS", RestIntegTestTask.class) {
|
|
|
|
- description = "Runs tests with the STS (Secure Token Service)"
|
|
|
|
- SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
|
|
|
- SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME)
|
|
|
|
- setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
|
|
|
|
- setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())
|
|
|
|
- systemProperty 'tests.rest.blacklist', [
|
|
|
|
- 'repository_s3/10_basic/*',
|
|
|
|
- 'repository_s3/20_repository_permanent_credentials/*',
|
|
|
|
- 'repository_s3/30_repository_temporary_credentials/*',
|
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
|
- 'repository_s3/50_repository_ecs_credentials/*'
|
|
|
|
- ].join(",")
|
|
|
|
- }
|
|
|
|
- tasks.named("check").configure { dependsOn("yamlRestTestSTS") }
|
|
|
|
-
|
|
|
|
- testClusters.matching { it.name == "yamlRestTestSTS" }.configureEach {
|
|
|
|
- module tasks.named("explodedBundlePlugin")
|
|
|
|
-
|
|
|
|
- setting 's3.client.integration_test_sts.endpoint', { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-sts', '80')}" }, IGNORE_VALUE
|
|
|
|
- systemProperty 'com.amazonaws.sdk.stsMetadataServiceEndpointOverride',
|
|
|
|
- { "${-> fixtureAddress('s3-fixture', 's3-fixture-with-sts', '80')}/assume-role-with-web-identity" }, IGNORE_VALUE
|
|
|
|
|
|
+ systemProperty("tests.use.fixture", Boolean.toString(useFixture))
|
|
|
|
+ systemProperty("s3PermanentAccessKey", s3PermanentAccessKey)
|
|
|
|
+ systemProperty("s3PermanentSecretKey", s3PermanentSecretKey)
|
|
|
|
+ systemProperty("s3TemporaryAccessKey", s3TemporaryAccessKey)
|
|
|
|
+ systemProperty("s3TemporarySecretKey", s3TemporarySecretKey)
|
|
|
|
+ systemProperty("s3EC2AccessKey", s3PermanentAccessKey)
|
|
|
|
|
|
- File awsWebIdentityTokenExternalLocation = file('src/test/resources/aws-web-identity-token-file')
|
|
|
|
- // The web identity token can be read only from the plugin config directory because of security restrictions
|
|
|
|
- // Ideally we would create a symlink, but extraConfigFile doesn't support it
|
|
|
|
- extraConfigFile 'repository-s3/aws-web-identity-token-file', awsWebIdentityTokenExternalLocation
|
|
|
|
- environment 'AWS_WEB_IDENTITY_TOKEN_FILE', "$awsWebIdentityTokenExternalLocation"
|
|
|
|
-
|
|
|
|
- // The AWS STS SDK requires the role and session names to be set. We can verify that they are sent to S3S in the S3HttpFixtureWithSTS fixture
|
|
|
|
- environment 'AWS_ROLE_ARN', 'arn:aws:iam::123456789012:role/FederatedWebIdentityRole'
|
|
|
|
- environment 'AWS_ROLE_SESSION_NAME', 'sts-fixture-test'
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Sanity test for STS Regional Endpoints
|
|
|
|
-if (useFixture) {
|
|
|
|
- tasks.register("yamlRestTestRegionalSTS", RestIntegTestTask.class) {
|
|
|
|
- description = "Runs tests with the Regional STS Endpoint"
|
|
|
|
- SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
|
|
|
- SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME)
|
|
|
|
- setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
|
|
|
|
- setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())
|
|
|
|
- // Run just the basic sanity test to make sure ES starts up and loads the S3 repository with
|
|
|
|
- // a regional endpoint without an error. It would be great to make actual requests against
|
|
|
|
- // a test fixture, but setting the region means using a production endpoint
|
|
|
|
- systemProperty 'tests.rest.blacklist', [
|
|
|
|
- 'repository_s3/20_repository_permanent_credentials/*',
|
|
|
|
- 'repository_s3/30_repository_temporary_credentials/*',
|
|
|
|
- 'repository_s3/40_repository_ec2_credentials/*',
|
|
|
|
- 'repository_s3/50_repository_ecs_credentials/*',
|
|
|
|
- 'repository_s3/60_repository_sts_credentials/*'
|
|
|
|
- ].join(",")
|
|
|
|
- }
|
|
|
|
- tasks.named("check").configure { dependsOn("yamlRestTestRegionalSTS") }
|
|
|
|
-
|
|
|
|
- testClusters.matching { it.name == "yamlRestTestRegionalSTS" }.configureEach {
|
|
|
|
- module tasks.named("explodedBundlePlugin")
|
|
|
|
-
|
|
|
|
- File awsWebIdentityTokenExternalLocation = file('src/test/resources/aws-web-identity-token-file')
|
|
|
|
- extraConfigFile 'repository-s3/aws-web-identity-token-file', awsWebIdentityTokenExternalLocation
|
|
|
|
- environment 'AWS_WEB_IDENTITY_TOKEN_FILE', "$awsWebIdentityTokenExternalLocation"
|
|
|
|
- environment 'AWS_ROLE_ARN', 'arn:aws:iam::123456789012:role/FederatedWebIdentityRole'
|
|
|
|
- environment 'AWS_ROLE_SESSION_NAME', 'sts-fixture-test'
|
|
|
|
- // Force the repository to set a regional production endpoint
|
|
|
|
- environment 'AWS_STS_REGIONAL_ENDPOINTS', 'regional'
|
|
|
|
- environment 'AWS_REGION', 'ap-southeast-2'
|
|
|
|
- }
|
|
|
|
|
|
+ // ideally we could resolve an env path in cluster config as resource similar to configuring a config file
|
|
|
|
+ // not sure how common this is, but it would be nice to support
|
|
|
|
+ File awsWebIdentityTokenExternalLocation = file('src/test/resources/aws-web-identity-token-file')
|
|
|
|
+ // The web identity token can be read only from the plugin config directory because of security restrictions
|
|
|
|
+ // Ideally we would create a symlink, but extraConfigFile doesn't support it
|
|
|
|
+ nonInputProperties.systemProperty("awsWebIdentityTokenExternalLocation", awsWebIdentityTokenExternalLocation.getAbsolutePath())
|
|
}
|
|
}
|
|
|
|
|
|
// 3rd Party Tests
|
|
// 3rd Party Tests
|
|
-TaskProvider s3ThirdPartyTest = tasks.register("s3ThirdPartyTest", Test) {
|
|
|
|
|
|
+tasks.register("s3ThirdPartyTest", Test) {
|
|
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
|
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
|
SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME)
|
|
SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME)
|
|
setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs())
|
|
setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs())
|
|
setClasspath(internalTestSourceSet.getRuntimeClasspath())
|
|
setClasspath(internalTestSourceSet.getRuntimeClasspath())
|
|
include '**/S3RepositoryThirdPartyTests.class'
|
|
include '**/S3RepositoryThirdPartyTests.class'
|
|
|
|
+ // test container accesses ~/.testcontainers.properties read
|
|
|
|
+ systemProperty "tests.security.manager", "false"
|
|
systemProperty 'test.s3.account', s3PermanentAccessKey
|
|
systemProperty 'test.s3.account', s3PermanentAccessKey
|
|
systemProperty 'test.s3.key', s3PermanentSecretKey
|
|
systemProperty 'test.s3.key', s3PermanentSecretKey
|
|
systemProperty 'test.s3.bucket', s3PermanentBucket
|
|
systemProperty 'test.s3.bucket', s3PermanentBucket
|
|
nonInputProperties.systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + BuildParams.testSeed
|
|
nonInputProperties.systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + BuildParams.testSeed
|
|
- if (useFixture) {
|
|
|
|
- nonInputProperties.systemProperty 'test.s3.endpoint', "${-> fixtureAddress('minio-fixture', 'minio-fixture', '9000') }"
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-tasks.named("check").configure { dependsOn(s3ThirdPartyTest) }
|
|
|
|
|
|
|
|
tasks.named("thirdPartyAudit").configure {
|
|
tasks.named("thirdPartyAudit").configure {
|
|
ignoreMissingClasses(
|
|
ignoreMissingClasses(
|
|
@@ -405,3 +240,8 @@ tasks.named("thirdPartyAudit").configure {
|
|
'javax.activation.DataHandler'
|
|
'javax.activation.DataHandler'
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+tasks.named("check").configure {
|
|
|
|
+ dependsOn(tasks.withType(Test))
|
|
|
|
+}
|
|
|
|
+
|