Hi!
I am upgrading opensource project code from 1.5.1 to 2.3.5 of Elasticsearch.
I've faced with integration tests failing.
I've tried to fix them some ways, and understood a lack of knowledge of elasticsearch kitchen.
There is breaking changes between this versions, and they are huge between v1 and v2 of elasticsearch.
I've used all my google-fu, but there is no useful page explaining actions to upgrade code of plugin tests from 1 to 2.
There is some info about "we changed here this and this", but here is a HUGE lack of explanation with examples, what should be done to integration tests.
So, my question:
ElasticsearchIntegrationTest was refactored to ESIntegTestCase.
There is method org.elasticsearch.test.ESIntegTestCase#httpClient (which is protected, so can be used, maybe, in extending classes?).
If I comment out my own httpClient() in my class and trying to use method ESIntegTestCase#httpClient, there is NullPointerException.
Can't figure out how to fix this issue correctly.
So, NPE:
java.lang.NullPointerException
at __randomizedtesting.SeedInfo.seed([F85BE188096FD4CF:E74E6E5A4454A696]:0)
at org.elasticsearch.test.ESIntegTestCase.httpClient(ESIntegTestCase.java:2070) <==
at com.asquera.elasticsearch.plugins.http.auth.integration.DefaultConfigurationIntegrationTest.testHealthCheck(DefaultConfigurationIntegrationTest.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1764)
ESIntegTestCase#httpClient:
protected HttpRequestBuilder httpClient() {
final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
final NodeInfo[] nodes = nodeInfos.getNodes();
assertTrue(nodes.length > 0);
TransportAddress publishAddress = randomFrom(nodes).getHttp().address().publishAddress(); <== here it fails (line 2070).
assertEquals(1, publishAddress.uniqueAddressTypeId());
InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address();
return new HttpRequestBuilder(HttpClients.createDefault()).host(NetworkAddress.formatAddress(address.getAddress())).port(address.getPort());
}
Debug says there is node returned from randomFrom(nodes), but it's http field is null.
.getHttp() returns null, and next method called (.address()) against null value, causing NPE.
Maybe there is misconfigured something?
How can I create HTTP-transport port correctly?
Here is also our own httpClient() code from "v1" of plugin:
public static HttpRequestBuilder httpClient() {
HttpServerTransport httpServerTransport = internalCluster().getDataNodeInstance(HttpServerTransport.class);
InetSocketAddress address = ((InetSocketTransportAddress) httpServerTransport.boundAddress().publishAddress()).address();
return new HttpRequestBuilder(HttpClients.createDefault()).host(address.getHostName()).port(address.getPort());
}
Any help would be appreciated.