|
9 | 9 |
|
10 | 10 | package org.elasticsearch.discovery.ec2; |
11 | 11 |
|
12 | | -import com.amazonaws.util.EC2MetadataUtils; |
13 | | - |
14 | 12 | import org.elasticsearch.client.Request; |
15 | 13 | import org.elasticsearch.test.cluster.ElasticsearchCluster; |
16 | | -import org.elasticsearch.test.rest.ESRestTestCase; |
17 | 14 | import org.junit.ClassRule; |
18 | 15 |
|
19 | 16 | import java.io.IOException; |
20 | 17 |
|
21 | | -public class DiscoveryEc2AvailabilityZoneAttributeNoImdsIT extends ESRestTestCase { |
| 18 | +public class DiscoveryEc2AvailabilityZoneAttributeNoImdsIT extends DiscoveryEc2AvailabilityZoneAttributeTestCase { |
22 | 19 | @ClassRule |
23 | | - public static ElasticsearchCluster cluster = ElasticsearchCluster.local() |
24 | | - .plugin("discovery-ec2") |
25 | | - .setting(AwsEc2Service.AUTO_ATTRIBUTE_SETTING.getKey(), "true") |
26 | | - .build(); |
| 20 | + // use an address which definitely isn't running an IMDS, just in case we're running these tests in EC2 |
| 21 | + public static ElasticsearchCluster cluster = DiscoveryEc2AvailabilityZoneAttributeTestCase.buildCluster(() -> "http://127.0.0.1:1"); |
27 | 22 |
|
28 | 23 | @Override |
29 | 24 | protected String getTestRestCluster() { |
30 | 25 | return cluster.getHttpAddresses(); |
31 | 26 | } |
32 | 27 |
|
| 28 | + @Override // the base class asserts that the attribute is set, but we don't want that here |
33 | 29 | public void testAvailabilityZoneAttribute() throws IOException { |
34 | | - assumeTrue("test only in non-AWS environment", EC2MetadataUtils.getInstanceId() == null); |
35 | | - |
36 | 30 | final var nodesInfoResponse = assertOKAndCreateObjectPath(client().performRequest(new Request("GET", "/_nodes/_all/_none"))); |
37 | 31 | for (final var nodeId : nodesInfoResponse.evaluateMapKeys("nodes")) { |
38 | 32 | assertNull(nodesInfoResponse.evaluateExact("nodes", nodeId, "attributes", "aws_availability_zone")); |
|
0 commit comments