Search in sources :

Example 6 with Ec2NameResolver

use of org.elasticsearch.cloud.aws.network.Ec2NameResolver in project elasticsearch by elastic.

the class Ec2NetworkTests method testNetworkHostEc2PublicDns.

/**
     * Test for network.host: _ec2:publicDns_
     */
public void testNetworkHostEc2PublicDns() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:publicDns_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    // TODO we need to replace that with a mock. For now we check the URL we are supposed to reach.
    try {
        networkService.resolveBindHostAddresses(null);
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString("public-hostname"));
    }
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) IOException(java.io.IOException) Settings(org.elasticsearch.common.settings.Settings)

Example 7 with Ec2NameResolver

use of org.elasticsearch.cloud.aws.network.Ec2NameResolver in project elasticsearch by elastic.

the class Ec2NetworkTests method testNetworkHostEc2PublicIp.

/**
     * Test for network.host: _ec2:publicIp_
     */
public void testNetworkHostEc2PublicIp() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:publicIp_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    // TODO we need to replace that with a mock. For now we check the URL we are supposed to reach.
    try {
        networkService.resolveBindHostAddresses(null);
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString("public-ipv4"));
    }
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) IOException(java.io.IOException) Settings(org.elasticsearch.common.settings.Settings)

Example 8 with Ec2NameResolver

use of org.elasticsearch.cloud.aws.network.Ec2NameResolver in project elasticsearch by elastic.

the class Ec2NetworkTests method testNetworkHostEc2PrivateDns.

/**
     * Test for network.host: _ec2:privateDns_
     */
public void testNetworkHostEc2PrivateDns() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:privateDns_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    // TODO we need to replace that with a mock. For now we check the URL we are supposed to reach.
    try {
        networkService.resolveBindHostAddresses(null);
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString("local-hostname"));
    }
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) IOException(java.io.IOException) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

Ec2NameResolver (org.elasticsearch.cloud.aws.network.Ec2NameResolver)8 NetworkService (org.elasticsearch.common.network.NetworkService)8 Settings (org.elasticsearch.common.settings.Settings)8 IOException (java.io.IOException)7 InetAddress (java.net.InetAddress)1