# In memory testing with RestHighLevelClient

**URL:** <https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196>\
**Category:** Elasticsearch\
**Created:** [November 2, 2017, 12:42pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196 "2017-11-02T12:42:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://discuss.elastic.co/u/kieran)\
**Post date:** [November 2, 2017, 12:42pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/1 "2017-11-02T12:42:44Z")

</div>

I'm using elasticsearch 5.6, and the brand new RestHighLevelClient.

I know that previously, with the nodebuilder, it was possible to configure elastic to run in-memory for testing (i.e. as part of a unit test after the build phase) like so: nodeBuilder().local(true)...

Is it possible to run an elastic instance in memory with the new RestHighLevelClient, or by another method in version 5.6?

Thanks.

---

<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:** [November 2, 2017, 2:22pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/2 "2017-11-02T14:22:34Z")

</div>

No. The Rest Client is only a client.

---

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://discuss.elastic.co/u/kieran)\
**Post date:** [November 2, 2017, 2:25pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/3 "2017-11-02T14:25:20Z")

</div>

Is there a reason this functionality has been removed in 5.6?

---

<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:** [November 2, 2017, 3:13pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/4 "2017-11-02T15:13:42Z")

</div>

You might want to read this: [https://www.elastic.co/blog/elasticsearch-the-server](https://www.elastic.co/blog/elasticsearch-the-server)

---

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://discuss.elastic.co/u/kieran)\
**Post date:** [November 2, 2017, 3:25pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/5 "2017-11-02T15:25:37Z")

</div>

From the referenced post it seems that the reason you no longer support embedded is that it's unsafe for production. It's a common use case to want to unit / integration test ES code outside of a production environment; many of your clients currently do this. This is similar to in memory relational database testing, which can also be useful.

May I suggest that you consider providing some kind of support for embedded testing in a future release. This will be impacting my choice as I decide which search tool our company will use going forward, as will the quality and tone of responses I receive here.

Regards  
Kieran

---

<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:** [November 2, 2017, 3:45pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/6 "2017-11-02T15:45:41Z")

</div>

> [@kieran](#):
>
> May I suggest that you consider providing some kind of support for embedded testing in a future release.

This will not happen.

To do integration tests, you can:

- ~~Use the Gradle tools elasticsearch already has. You can read some information about this here: [#21119](https://github.com/elastic/elasticsearch/issues/21119). This [sample project](https://github.com/joel-costigliola/elastic-search-test) shows how to use Elasticsearch Test Classes~~
- Use the Maven plugin: [GitHub - alexcojocaru/elasticsearch-maven-plugin: A Maven plugin to run a single node Elasticsearch cluster during the integration test phase of a build](https://github.com/alexcojocaru/elasticsearch-maven-plugin)
- Use Ant scripts like [https://david.pilato.fr/blog/2016-07-29-elasticsearch-real-integration-tests/](http://david.pilato.fr/blog/2016/10/18/elasticsearch-real-integration-tests-updated-for-ga/)
- Using Docker and TestContainers: [Elasticsearch container - Testcontainers for Java](https://www.testcontainers.org/modules/elasticsearch/)
- Using Docker from maven: [https://github.com/dadoonet/fscrawler/blob/e15dddf72b1ed094dad279d492e4e0314f73683f/pom.xml#L241-L289](https://github.com/dadoonet/fscrawler/blob/e15dddf72b1ed094dad279d492e4e0314f73683f/pom.xml#L241-L289)

For sure, integration tests must be run against a real elasticsearch instance.  
Unit tests should not require any third party tool to run IMHO.

---

<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:** [November 30, 2017, 3:45pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/7 "2017-11-30T15:45:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PhaedrusTheGreek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phaedrusthegreek/32/4884_2.png) [@PhaedrusTheGreek](https://discuss.elastic.co/u/PhaedrusTheGreek)\
**Post date:** [April 9, 2020, 3:58pm UTC](https://discuss.elastic.co/t/in-memory-testing-with-resthighlevelclient/106196/8 "2020-04-09T15:58:02Z")

</div>

I have confirm [the solution posted here](https://discuss.elastic.co/t/is-the-highlevelrestclient-no-supported-in-the-java-testing-framework/218083/2) works for High Level Rest Client Integration Tests with single node embedded in 7.6.
