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

**URL:** <https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406>\
**Category:** Elasticsearch\
**Created:** [August 21, 2018, 2:23pm UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406 "2018-08-21T14:23:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Costantini](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Marco\_Costantini](https://discuss.elastic.co/u/Marco_Costantini)\
**Post date:** [August 21, 2018, 2:23pm UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406/1 "2018-08-21T14:23:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 21, 2018, 8:52pm UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406/2 "2018-08-21T20:52:38Z")

</div>

I shared some ideas about integration testing in this thread: [In memory testing with RestHighLevelClient](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/6)

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

> **[joel-costigliola/elastic-search-test](https://github.com/joel-costigliola/elastic-search-test)**
>
> elastic-search-test - ESIntegTestCase example

---

<div class="post-metadata">

**Author:** ![Marco\_Costantini](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Marco\_Costantini](https://discuss.elastic.co/u/Marco_Costantini)\
**Post date:** [August 22, 2018, 8:00am UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406/3 "2018-08-22T08:00:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 22, 2018, 12:47pm UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406/4 "2018-08-22T12:47:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marco\_Costantini](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Marco\_Costantini](https://discuss.elastic.co/u/Marco_Costantini)\
**Post date:** [August 22, 2018, 12:49pm UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406/5 "2018-08-22T12:49:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 19, 2018, 12:49pm UTC](https://discuss.elastic.co/t/what-is-the-current-recommendation-for-creating-integration-tests-that-need-a-cluster/145406/6 "2018-09-19T12:49:53Z")

</div>

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