I am writing unit tests for ES5.2, and am having some issues. I need to create a client which connects to a local node for running tests, so I use
esClient = new PreBuiltTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
This causes problems
java.lang.IllegalStateException: running tests but failed to invoke RandomizedContext#getRandom
So then I used an annotation on my unit test classes as
@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
but this gave me an error
SEVERE: 2 threads leaked from TEST scope at {method_name}):
1) Thread[id=36, name={project_name}writer-thread-0, state=WAITING, group={project_name}-writer]
And the unit tests threw errors as
org.mockito.exceptions.misusing.WrongTypeOfReturnValue
I tried to use the annotation as below on the unit test class
@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
That got rid of some error messages, but there were still concurrency issues in the code. Anyone knows how to handle this? Is there some explicit thread safety methods I should use?