From 9c209e46be3b00e1500285f259d0554a5306bcfc Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 6 Apr 2015 23:25:53 -0700 Subject: [PATCH] Test: make httpClient() helper not rely on internalCluster (which may be read only) --- .../elasticsearch/test/ElasticsearchIntegrationTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 333564f1e70..28f92be21ef 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -1947,7 +1947,13 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase } protected HttpRequestBuilder httpClient() { - return new HttpRequestBuilder(HttpClients.createDefault()).httpTransport(internalCluster().getDataNodeInstance(HttpServerTransport.class)); + final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); + final NodeInfo[] nodes = nodeInfos.getNodes(); + assertTrue(nodes.length > 0); + TransportAddress publishAddress = randomFrom(nodes).getHttp().address().publishAddress(); + assertEquals(1, publishAddress.uniqueAddressTypeId()); + InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address(); + return new HttpRequestBuilder(HttpClients.createDefault()).host(address.getHostName()).port(address.getPort()); } /**