/* * 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:discovery-ec2', configuration: 'runtime') } final int ec2NumberOfNodes = 3 File ec2DiscoveryFile = new File(project.buildDir, 'generated-resources/nodes.uri') /** A task to start the AmazonEC2Fixture which emulates an EC2 service **/ task ec2Fixture(type: AntFixture) { dependsOn compileTestJava env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }" executable = new File(project.runtimeJavaHome, 'bin/java') args 'org.elasticsearch.discovery.ec2.AmazonEC2Fixture', baseDir, ec2DiscoveryFile.absolutePath } Map expansions = [ 'expected_nodes': ec2NumberOfNodes ] processTestResources { inputs.properties(expansions) MavenFilteringHack.filter(it, expansions) } integTestCluster { dependsOn ec2Fixture numNodes = ec2NumberOfNodes plugin ':plugins:discovery-ec2' keystoreSetting 'discovery.ec2.access_key', 'ec2_integration_test_access_key' keystoreSetting 'discovery.ec2.secret_key', 'ec2_integration_test_secret_key' setting 'discovery.seed_providers', 'ec2' setting 'network.host', '_ec2_' setting 'discovery.ec2.endpoint', "http://${-> ec2Fixture.addressAndPort}" systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", "http://${-> ec2Fixture.addressAndPort}" unicastTransportUri = { seedNode, node, ant -> return null } waitCondition = { node, ant -> ec2DiscoveryFile.parentFile.mkdirs() ec2DiscoveryFile.setText(integTest.nodes.collect { n -> "${n.transportUri()}" }.join('\n'), 'UTF-8') File tmpFile = new File(node.cwd, 'wait.success') ant.get(src: "http://${node.httpUri()}/", dest: tmpFile.toString(), ignoreerrors: true, retries: 10) return tmpFile.exists() } }