/* * 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' dependencies { 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) } test.enabled = false task s3ThirdPartyTests { dependsOn check } 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) { s3PermanentAccessKey = 'sn_tool_access_key' s3PermanentSecretKey = 'sn_tool_secret_key' s3PermanentBucket = 'bucket' s3PermanentBasePath = 'integration_test' useS3Fixture = true } else if (!s3PermanentAccessKey || !s3PermanentSecretKey || !s3PermanentBucket || !s3PermanentBasePath) { throw new IllegalArgumentException("not all options specified to run against external S3 service as permanent credentials are present") } task thirdPartyTest(type: Test) { include '**/*.class' systemProperty 'tests.security.manager', false systemProperty 'test.s3.account', s3PermanentAccessKey systemProperty 'test.s3.key', s3PermanentSecretKey systemProperty 'test.s3.bucket', s3PermanentBucket systemProperty 'test.s3.base', s3PermanentBasePath } if (useS3Fixture) { apply plugin: 'elasticsearch.test.fixtures' testingConventions.enabled = false; testFixtures.useFixture(':test:fixtures:minio-fixture', "minio-fixture-for-snapshot-tool") def minioAddress = { 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 } thirdPartyTest { dependsOn project(':test:fixtures:minio-fixture').postProcessFixture nonInputProperties.systemProperty 'test.s3.endpoint', "${-> minioAddress.call()}" } 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."); } } } check.dependsOn(thirdPartyTest)