I'm using gradle to test a small program to index and search documents. The program works fine but I wanted to add some unit tests using ESIntegTestCase (Before 5.0 I was creating a Node with the NodeBuilder which worked fine but I think that is no longer supported).
I originally started off without log4j but had to add it because it complained of class not found. After adding log4j it then failed with a security manager error and had to add -Dtests.security.manager=false. The next error is:
Thanks David, your answer was much appreciated. I thought overriding of the nodePlugins() method to include the Netty4Plugin would have solved my issue but it is still complaining. This only happens if I have a test that contains the following lines:
InetSocketAddress[] inetSocketAddresses = cluster().httpAddresses();
for (InetSocketAddress s : inetSocketAddresses) {
System.out.println(">" + s);
}
The reason I need to get hold of the httpAddresses is because I want to test some REST calls (not the binary API).
The Log4j dependencies for Elasticsearch 5.0.0 should be 2.6.2, not 2.7 otherwise you will see NoClassDefFoundError for org.apache.logging.log4j.core.async.DaemonThreadFactory and possibly other issues.
I get the idea that running a full fledged external cluster is more realistic, and I'd like to set that up for our continuous build stream where we have maven running tests in a segregated environment. But, I'm interested in being able to run unit tests from an IDE that use the JestClient without having to start up an external ES cluster. I see in your article the tests are effectively skipped if run from the IDE...
ESIntegTestCase seems so tantalizingly close to being able to do this, and the Jest guys even have this test class which is nearly exactly what I want to do:
They seem to be running an older version of ES though, 2.4 maybe. Back when nodes weren't set to local by default maybe? When I try to do something similar I get the below error when calling cluster().httpAddresses(). Obviously because the node is set to local... doing something simple like setting "NetworkModule.HTTP_ENABLED.getKey(), true" in the NodeSettings just gives a different error about binding types, so one would guess there's more to setting up the network stuff... Have you been able to get that to work within the context of ESIntegTestCase?
No implementation for org.elasticsearch.http.HttpServerTransport was bound.
while locating org.elasticsearch.http.HttpServerTransport
1 error
at __randomizedtesting.SeedInfo.seed([957850041CAE7925:3A6E197C03FB967E]:0)
at org.elasticsearch.common.inject.InjectorImpl.getProvider(InjectorImpl.java:790)
at org.elasticsearch.common.inject.InjectorImpl.getProvider(InjectorImpl.java:729)
at org.elasticsearch.common.inject.InjectorImpl.getInstance(InjectorImpl.java:801)
at org.elasticsearch.test.InternalTestCluster.getInstanceFromNode(InternalTestCluster.java:1205)
at org.elasticsearch.test.InternalTestCluster.getInstances(InternalTestCluster.java:1151)
at org.elasticsearch.test.InternalTestCluster.httpAddresses(InternalTestCluster.java:1216)
Sorry for the lengthy delay, but wanted to thank you for the response. I ended up switching to use the native client rather than JEST. The API ends up being nearly the same between native and JEST, but just one less part to worry about... and works much better with ESIntegTestCase...
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.