|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | + |
| 21 | +import org.elasticsearch.gradle.MavenFilteringHack |
| 22 | +import org.elasticsearch.gradle.test.AntFixture |
| 23 | + |
| 24 | +apply plugin: 'elasticsearch.standalone-rest-test' |
| 25 | +apply plugin: 'elasticsearch.rest-test' |
| 26 | + |
| 27 | +dependencies { |
| 28 | + testCompile project(path: ':plugins:discovery-ec2', configuration: 'runtime') |
| 29 | +} |
| 30 | + |
| 31 | +forbiddenApisTest { |
| 32 | + // we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage |
| 33 | + bundledSignatures -= 'jdk-non-portable' |
| 34 | + bundledSignatures += 'jdk-internal' |
| 35 | +} |
| 36 | + |
| 37 | +final int ec2NumberOfNodes = 3 |
| 38 | +File ec2DiscoveryFile = new File(project.buildDir, 'generated-resources/nodes.uri') |
| 39 | + |
| 40 | +/** A task to start the AmazonEC2Fixture which emulates an EC2 service **/ |
| 41 | +task ec2Fixture(type: AntFixture) { |
| 42 | + dependsOn compileTestJava |
| 43 | + env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }" |
| 44 | + executable = new File(project.runtimeJavaHome, 'bin/java') |
| 45 | + args 'org.elasticsearch.discovery.ec2.AmazonEC2Fixture', baseDir, ec2DiscoveryFile.absolutePath |
| 46 | +} |
| 47 | + |
| 48 | +Map<String, Object> expansions = [ |
| 49 | + 'expected_nodes': ec2NumberOfNodes |
| 50 | +] |
| 51 | + |
| 52 | +processTestResources { |
| 53 | + inputs.properties(expansions) |
| 54 | + MavenFilteringHack.filter(it, expansions) |
| 55 | +} |
| 56 | + |
| 57 | +integTestCluster { |
| 58 | + dependsOn ec2Fixture |
| 59 | + numNodes = ec2NumberOfNodes |
| 60 | + plugin ':plugins:discovery-ec2' |
| 61 | + keystoreSetting 'discovery.ec2.access_key', 'ec2_integration_test_access_key' |
| 62 | + keystoreSetting 'discovery.ec2.secret_key', 'ec2_integration_test_secret_key' |
| 63 | + setting 'discovery.zen.hosts_provider', 'ec2' |
| 64 | + setting 'discovery.ec2.endpoint', "http://${-> ec2Fixture.addressAndPort}" |
| 65 | + unicastTransportUri = { seedNode, node, ant -> return null } |
| 66 | + |
| 67 | + waitCondition = { node, ant -> |
| 68 | + ec2DiscoveryFile.parentFile.mkdirs() |
| 69 | + ec2DiscoveryFile.setText(integTest.nodes.collect { n -> "${n.transportUri()}" }.join('\n'), 'UTF-8') |
| 70 | + |
| 71 | + File tmpFile = new File(node.cwd, 'wait.success') |
| 72 | + ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${ec2NumberOfNodes}&wait_for_status=yellow", |
| 73 | + dest: tmpFile.toString(), |
| 74 | + ignoreerrors: true, |
| 75 | + retries: 10) |
| 76 | + return tmpFile.exists() |
| 77 | + } |
| 78 | +} |
0 commit comments