Search in sources :

Example 1 with Network

use of org.elasticsearch.test.junit.annotations.Network in project elasticsearch by elastic.

the class Netty4TransportMultiPortIntegrationIT method testThatInfosAreExposed.

@Network
public void testThatInfosAreExposed() throws Exception {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setTransport(true).get();
    for (NodeInfo nodeInfo : response.getNodes()) {
        assertThat(nodeInfo.getTransport().getProfileAddresses().keySet(), hasSize(1));
        assertThat(nodeInfo.getTransport().getProfileAddresses(), hasKey("client1"));
        BoundTransportAddress boundTransportAddress = nodeInfo.getTransport().getProfileAddresses().get("client1");
        for (TransportAddress transportAddress : boundTransportAddress.boundAddresses()) {
            assertThat(transportAddress, instanceOf(TransportAddress.class));
        }
        // bound addresses
        for (TransportAddress transportAddress : boundTransportAddress.boundAddresses()) {
            assertThat(transportAddress, instanceOf(TransportAddress.class));
            assertThat(transportAddress.address().getPort(), is(allOf(greaterThanOrEqualTo(randomPort), lessThanOrEqualTo(randomPort + 10))));
        }
        // publish address
        assertThat(boundTransportAddress.publishAddress(), instanceOf(TransportAddress.class));
        TransportAddress publishAddress = boundTransportAddress.publishAddress();
        assertThat(NetworkAddress.format(publishAddress.address().getAddress()), is("127.0.0.7"));
        assertThat(publishAddress.address().getPort(), is(4321));
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) TransportAddress(org.elasticsearch.common.transport.TransportAddress) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) Network(org.elasticsearch.test.junit.annotations.Network)

Aggregations

NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)1 NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)1 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)1 TransportAddress (org.elasticsearch.common.transport.TransportAddress)1 Network (org.elasticsearch.test.junit.annotations.Network)1