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.
|
|
|
|
*/
|
|
|
|
import java.nio.file.Files
|
|
|
|
|
|
|
|
apply plugin: 'elasticsearch.build'
|
|
|
|
|
|
|
|
dependencies {
|
2020-06-30 09:57:41 -04:00
|
|
|
api project(":plugins:repository-gcs")
|
2020-06-14 16:30:44 -04:00
|
|
|
testImplementation project(":test:framework")
|
|
|
|
testImplementation project(':x-pack:snapshot-tool')
|
|
|
|
testImplementation files(project(':x-pack:snapshot-tool').sourceSets.test.output)
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
test.enabled = false
|
|
|
|
|
|
|
|
task gcsThirdPartyTests {
|
2019-11-14 06:01:23 -05:00
|
|
|
dependsOn check
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean useGCSFixture = false
|
|
|
|
|
|
|
|
String gcsServiceAccount = System.getenv("google_storage_service_account")
|
|
|
|
String gcsBucket = System.getenv("google_storage_bucket")
|
|
|
|
String gcsBasePath = System.getenv("google_storage_base_path")
|
|
|
|
|
|
|
|
if (!gcsServiceAccount && !gcsBucket && !gcsBasePath) {
|
2020-06-02 05:26:58 -04:00
|
|
|
gcsServiceAccount = new File(project(':plugins:repository-gcs').buildDir,
|
2019-11-14 06:01:23 -05:00
|
|
|
'generated-resources/service_account_test.json').path
|
|
|
|
gcsBucket = 'bucket_test'
|
|
|
|
gcsBasePath = 'integration_test'
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
useGCSFixture = true
|
2019-10-31 11:21:36 -04:00
|
|
|
} else if (!gcsServiceAccount || !gcsBucket || !gcsBasePath) {
|
2019-11-14 06:01:23 -05:00
|
|
|
throw new IllegalArgumentException("not all options specified to run thirdPartyTestGCS against external GCS service are present")
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def encodedCredentials = {
|
2019-11-14 06:01:23 -05:00
|
|
|
Base64.encoder.encodeToString(Files.readAllBytes(file(gcsServiceAccount).toPath()))
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
2020-06-02 05:26:58 -04:00
|
|
|
task gcsThirdPartyTest(type: Test) {
|
2019-11-14 06:01:23 -05:00
|
|
|
include '**/GCSCleanupTests.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.google.bucket', gcsBucket
|
|
|
|
systemProperty 'test.google.base', gcsBasePath
|
|
|
|
nonInputProperties.systemProperty 'test.google.account', "${-> encodedCredentials.call()}"
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (useGCSFixture) {
|
2020-06-02 05:26:58 -04:00
|
|
|
gcsThirdPartyTest.enabled = false;
|
2019-11-14 06:01:23 -05:00
|
|
|
testingConventions.enabled = false;
|
|
|
|
/*
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
See: https://github.com/elastic/elasticsearch/issues/46813 Fails with --parallel
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
thirdPartyTest.dependsOn(':plugins:repository-gcs:qa:google-cloud-storage:createServiceAccountFile',
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
':plugins:repository-gcs:qa:google-cloud-storage:googleCloudStorageFixture')
|
|
|
|
thirdPartyTest.finalizedBy(':plugins:repository-gcs:qa:google-cloud-storage:googleCloudStorageFixture#stop')
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
def fixtureEndpoint = {
|
|
|
|
"http://${project(':plugins:repository-gcs:qa:google-cloud-storage').googleCloudStorageFixture.addressAndPort}"
|
|
|
|
}
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
def tokenURI = {
|
|
|
|
"http://${project(':plugins:repository-gcs:qa:google-cloud-storage').googleCloudStorageFixture.addressAndPort}/o/oauth2/token"
|
|
|
|
}
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
thirdPartyTest {
|
|
|
|
nonInputProperties.systemProperty 'test.google.endpoint', "${-> fixtureEndpoint.call()}"
|
|
|
|
nonInputProperties.systemProperty 'test.google.tokenURI', "${-> tokenURI.call()}"
|
|
|
|
}
|
2019-10-31 11:21:36 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
gradle.taskGraph.whenReady {
|
|
|
|
if (it.hasTask(gcsThirdPartyTests)) {
|
|
|
|
throw new IllegalStateException("Tried to run third party tests but not all of the necessary environment variables 'google_storage_service_account', " +
|
|
|
|
"'google_storage_bucket', 'google_storage_base_path' are set.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2019-10-31 11:21:36 -04:00
|
|
|
}
|
|
|
|
|
2020-06-02 05:26:58 -04:00
|
|
|
check.dependsOn(gcsThirdPartyTest)
|