Skip to content

Commit

Permalink
[test] Avoid running the NoImds test on AWS (elastic#118675)
Browse files Browse the repository at this point in the history
Disabled the NoImds test on AWS EC2 instance where it fails because the
AWS metadata are available, which is not expected by this test.
  • Loading branch information
jozala authored Dec 13, 2024
1 parent a68269b commit 950db57
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package org.elasticsearch.discovery.ec2;

import com.amazonaws.util.EC2MetadataUtils;

import org.elasticsearch.client.Request;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.ESRestTestCase;
Expand All @@ -29,6 +31,8 @@ protected String getTestRestCluster() {
}

public void testAvailabilityZoneAttribute() throws IOException {
assumeTrue("test only in non-AWS environment", EC2MetadataUtils.getInstanceId() == null);

final var nodesInfoResponse = assertOKAndCreateObjectPath(client().performRequest(new Request("GET", "/_nodes/_all/_none")));
for (final var nodeId : nodesInfoResponse.evaluateMapKeys("nodes")) {
assertNull(nodesInfoResponse.evaluateExact("nodes", nodeId, "attributes", "aws_availability_zone"));
Expand Down

0 comments on commit 950db57

Please sign in to comment.