Skip to content

Commit

Permalink
[test] Avoid running the NoImds test on AWS (elastic#118675) (elastic…
Browse files Browse the repository at this point in the history
…#118688)

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 and maxhniebergall committed Dec 16, 2024
1 parent 20793ed commit 0e5810f
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 0e5810f

Please sign in to comment.