What is the current recommendation for creating integration tests that need a cluster?

We are using ES versoin 5.5. We have a very simple program that transforms some data and writes it to ES. I want to create some integration tests but am having much trouble. My trouble is that nothing is working or working ideally.

I've read the short doc about ES Integration Tests. I've also found a maven plugin that some people recommend (elasticsearch-maven-plugin by alexcojocaru).

My program creates a transport client so I thought this would work well with the cluster created by ESIntegTestCase. However, I only get an error about none of the configured nodes being found (despite using the "correct" clustername, host and port).

I tried using the maven plugin, and it works great, but I can't get it to run only before the verify phase. I'm still playing with the phases and goals though so I hope to solve that.

My question is: For such a simple case, what is the officially recommended way to create an integration test for it? And is there a HelloWorld example of one?

I shared some ideas about integration testing in this thread: In memory testing with RestHighLevelClient

Also this sample project shows how to use Elasticsearch Test Classes:

Thank you. I've read the thread and analysed the project somewhat. It appears to me that the Maven plugin approach is best suited for true integration tests (and for our situation).

All the examples I've seen of uses of ESIntegTestCase strictly use the provided client to interact with the cluster, whereas my application creates it's own transport client.

If possible, would you shed light on the following, please?

  1. My program creates a transport client. Do you think it's possible to connect that client to the cluster created by ESIntegTestCase? I've tried this by passing the live cluster information to my program, but that didn't work. I am wondering if there is some unknown (to me) technical limitation preventing this.

You should not use anymore the TransportClient anyway. Switch to the REST client.

Also consider docker if you have it. Might be even easier than Maven plugin.

That change is on our roadmap, but I can only work with what I have today.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.