Hi, I want to write an integration test against and embedded ES test cluster.
I read about ESIntegTestCase and managed to successfully implement a FooTest extends ESIntegTestCase. Cluster started (as expected), and I was able to index and search. All is good.
However, I have an issue with needing to extend ESIntegTestCase as I also need to extend my own BaseTestCase class. To give some more context, I have an interface (let's call it Foo) with several implementations, one of which is ElasticClientFoo which implements the Foo API by communicating with an ES cluster via Client. I intend to write a FooTestBase with the test methods, with actual extensions providing the specific Foo implementation. So for example, I would have FooElasticClientTest extends FooTestBase which will override say one method which initializes the ElasticClientFoo with the client() provided by InternalTestCluster.
I tried implementing a MiniElasticTestCluster which initializes an InternalTestCluster, and I even managed to get it working. However when I added indexing and search to my tests, they started to fail on ThreadLeakage errors. Since I'm familiar with Lucene's randomized test framework, I can partially explain it -- since I do not extend ESIntegTestCase, my test does not hook properly with RandomizedRunner, causing its @After to get called before my @AfterClass (which shuts down the cluster), and that causes RandomizedRunner to report the threads leakage, even though the cluster is shut down properly afterwards.
Is there a way to initialize InternalTestCluster, or any other instance, for test purposes, even though I don't care about randomizing the tests? I am looking for something similar to Solr's MiniSolrCloudCluster or ZooKeeper's (actually curator's) TestingServer, which will allow me to fire up an ES cluster, embedded for testing purposes?
If not, how difficult do you think it would be to adapt InternalTestCluster to do that, without tying to the randomization framework?
P.S. I do not rule out a problem with my implementation which wraps InternalTestCluster that causes these thread leaks, so if anyone has already done something like this outside of ES, I'd love to get some pointers / suggestions.