2019-10-31 11:21:36 -04:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
apply plugin: 'elasticsearch.build'
|
2020-01-08 10:33:36 -05:00
|
|
|
apply plugin: 'elasticsearch.test.fixtures'
|
2019-10-31 11:21:36 -04:00
|
|
|
|
|
|
|
dependencies {
|
2019-11-14 06:01:23 -05:00
|
|
|
compile project(":plugins:repository-s3")
|
|
|
|
testCompile project(":test:framework")
|
|
|
|
testCompile project(':x-pack:snapshot-tool')
|
|
|
|
testCompile files(project(':x-pack:snapshot-tool').sourceSets.test.output)
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
test.enabled = false
|
|
|
|
|
|
|
|
task s3ThirdPartyTests {
|
2019-11-14 06:01:23 -05:00
|
|
|
dependsOn check
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean useS3Fixture = false
|
|
|
|
|
|
|
|
String s3PermanentAccessKey = System.getenv("amazon_s3_access_key")
|
|
|
|
String s3PermanentSecretKey = System.getenv("amazon_s3_secret_key")
|
|
|
|
String s3PermanentBucket = System.getenv("amazon_s3_bucket")
|
|
|
|
String s3PermanentBasePath = System.getenv("amazon_s3_base_path")
|
|
|
|
|
|
|
|
if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3PermanentBasePath) {
|
2020-01-08 10:33:36 -05:00
|
|
|
s3PermanentAccessKey = 'sn_tool_access_key'
|
|
|
|
s3PermanentSecretKey = 'sn_tool_secret_key'
|
|
|
|
s3PermanentBucket = 'bucket'
|
2019-11-14 06:01:23 -05:00
|
|
|
s3PermanentBasePath = 'integration_test'
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
useS3Fixture = true
|
2019-10-31 11:21:36 -04:00
|
|
|
} else if (!s3PermanentAccessKey || !s3PermanentSecretKey || !s3PermanentBucket || !s3PermanentBasePath) {
|
2019-11-14 06:01:23 -05:00
|
|
|
throw new IllegalArgumentException("not all options specified to run against external S3 service as permanent credentials are present")
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
task thirdPartyTest(type: Test) {
|
|
|
|
include '**/*.class'
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
systemProperty 'tests.security.manager', false
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
systemProperty 'test.s3.account', s3PermanentAccessKey
|
|
|
|
systemProperty 'test.s3.key', s3PermanentSecretKey
|
|
|
|
systemProperty 'test.s3.bucket', s3PermanentBucket
|
|
|
|
systemProperty 'test.s3.base', s3PermanentBasePath
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (useS3Fixture) {
|
2019-11-14 06:01:23 -05:00
|
|
|
testingConventions.enabled = false;
|
2020-01-08 10:33:36 -05:00
|
|
|
testFixtures.useFixture(':test:fixtures:minio-fixture', "minio-fixture-for-snapshot-tool")
|
2019-11-14 06:01:23 -05:00
|
|
|
|
|
|
|
def minioAddress = {
|
2020-01-08 10:33:36 -05:00
|
|
|
int minioPort = project(':test:fixtures:minio-fixture').postProcessFixture.ext."test.fixtures.minio-fixture-for-snapshot-tool.tcp.9000"
|
|
|
|
assert minioPort > 0
|
|
|
|
'http://127.0.0.1:' + minioPort
|
2019-11-14 06:01:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
thirdPartyTest {
|
2020-01-08 10:33:36 -05:00
|
|
|
dependsOn project(':test:fixtures:minio-fixture').postProcessFixture
|
|
|
|
nonInputProperties.systemProperty 'test.s3.endpoint', "${-> minioAddress.call()}"
|
2019-11-14 06:01:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
gradle.taskGraph.whenReady {
|
2020-01-08 10:33:36 -05:00
|
|
|
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.");
|
|
|
|
}
|
|
|
|
}
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
check.dependsOn(thirdPartyTest)
|