Search in sources :

Example 1 with Ec2NameResolver

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

the class Ec2NetworkTests method testNetworkHostEc2.

/**
     * Test for network.host: _ec2_
     */
public void testNetworkHostEc2() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2_").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-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 2 with Ec2NameResolver

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

the class Ec2NetworkTests method testNetworkHostEc2PrivateIp.

/**
     * Test for network.host: _ec2:privateIp_
     */
public void testNetworkHostEc2PrivateIp() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:privateIp_").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-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 3 with Ec2NameResolver

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

the class Ec2NetworkTests method testNetworkHostEc2PublicIpv4.

/**
     * Test for network.host: _ec2:publicIpv4_
     */
public void testNetworkHostEc2PublicIpv4() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:publicIpv4_").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 4 with Ec2NameResolver

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

the class Ec2NetworkTests method testNetworkHostCoreLocal.

/**
     * Test that we don't have any regression with network host core settings such as
     * network.host: _local_
     */
public void testNetworkHostCoreLocal() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_local_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    InetAddress[] addresses = networkService.resolveBindHostAddresses(null);
    assertThat(addresses, arrayContaining(networkService.resolveBindHostAddresses(new String[] { "_local_" })));
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) InetAddress(java.net.InetAddress) Settings(org.elasticsearch.common.settings.Settings)

Example 5 with Ec2NameResolver

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

the class Ec2NetworkTests method testNetworkHostEc2PrivateIpv4.

/**
     * Test for network.host: _ec2:privateIpv4_
     */
public void testNetworkHostEc2PrivateIpv4() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:privateIpv4_").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-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)

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