/* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.test.AntFixture apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: ':plugins:repository-s3', configuration: 'runtime') } integTestCluster { plugin ':plugins:repository-s3' } boolean useFixture = false String s3AccessKey = System.getenv("amazon_s3_access_key") String s3SecretKey = System.getenv("amazon_s3_secret_key") String s3Bucket = System.getenv("amazon_s3_bucket") String s3BasePath = System.getenv("amazon_s3_base_path") if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) { s3AccessKey = 's3_integration_test_access_key' s3SecretKey = 's3_integration_test_secret_key' s3Bucket = 'bucket_test' s3BasePath = 'integration_test' useFixture = true } /** A task to start the AmazonS3Fixture which emulates a S3 service **/ task s3Fixture(type: AntFixture) { dependsOn testClasses env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }" executable = new File(project.runtimeJavaHome, 'bin/java') args 'org.elasticsearch.repositories.s3.AmazonS3Fixture', baseDir, s3Bucket } Map expansions = [ 'bucket': s3Bucket, 'base_path': s3BasePath ] processTestResources { inputs.properties(expansions) MavenFilteringHack.filter(it, expansions) } integTestCluster { keystoreSetting 's3.client.integration_test.access_key', s3AccessKey keystoreSetting 's3.client.integration_test.secret_key', s3SecretKey if (useFixture) { dependsOn s3Fixture /* Use a closure on the string to delay evaluation until tests are executed */ setting 's3.client.integration_test.endpoint', "http://${-> s3Fixture.addressAndPort}" } else { println "Using an external service to test the repository-s3 plugin" } }