# Not able connect with Rest High Level Client in ESIntegTestCase of ElasticSearch 7.0.0

**URL:** <https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307>\
**Category:** Elasticsearch\
**Created:** [May 2, 2019, 8:21am UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307 "2019-05-02T08:21:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitpatil](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@rohitpatil](https://discuss.elastic.co/u/rohitpatil)\
**Post date:** [May 2, 2019, 8:21am UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307/1 "2019-05-02T08:21:29Z")

</div>

Hello,

I have written some integration tests for my project which uses ElasticSearch as database.

I was using Rest High Level Client with ElasticSearch version 6.6.0. But recently I upgraded the version to 7.0.0. Now, my Integration tests are failing to connect with ElasticSearch on Rest High Level Client. Earlier with 6.6.0, I was using `org.elasticsearch.common.network.NetworkModule.HTTP_ENABLED` setting to enable HTTP. But now it's deprecated and somehow the HTTP is not getting enabled. It seems nodes created by ESIntegTestCase do not have HTTP enabled by default.

**Error**

```auto
java.net.ConnectException: Timeout connecting to [/0.0.0.0:80]

```

**pom.xml**

```auto
<dependency>
	<groupId>org.elasticsearch</groupId>
	<artifactId>elasticsearch</artifactId>
	<version>7.0.0</version>
</dependency>
<dependency>
	<groupId>org.elasticsearch.client</groupId>
	<artifactId>elasticsearch-rest-high-level-client</artifactId>
	<version>7.0.0</version>
</dependency>
<dependency>
	<groupId>org.elasticsearch.plugin</groupId>
	<artifactId>transport-netty4-client</artifactId>
	<version>7.0.0</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>org.elasticsearch.test</groupId>
	<artifactId>framework</artifactId>
	<version>7.0.0</version>
	<scope>test</scope>
</dependency>

```

**Test class**

```auto
package com.rp;

import com.carrotsearch.randomizedtesting.RandomizedRunner;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.transport.Netty4Plugin;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import static com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope.NONE;

@ThreadLeakScope(NONE)
@ClusterScope(numDataNodes = 1)
@RunWith(RandomizedRunner.class)
public class CommonUtilTests extends ESIntegTestCase {

    private RestHighLevelClient esClient;

    @Override
    protected Settings nodeSettings(int nodeOrdinal) {
        return Settings.builder()
                .put(super.nodeSettings(nodeOrdinal))
                .build();
    }

    @Override
    protected Collection<Class<? extends Plugin>> nodePlugins() {
        final Collection<Class<? extends Plugin>> plugins = new ArrayList<>();
        plugins.add(Netty4Plugin.class);
        return plugins;
    }

    @Before
    public void initialize() {
        esClient = new RestHighLevelClient(RestClient.builder(getRestClient().getNodes().get(0)));
    }

    @Test
    public void test_createIndex() throws IOException {
        Boolean isCreated = CommonUtil.createIndex(esClient, "my-index");
        assertTrue(isCreated);
        assertTrue(indexExists("my-index"));
    }
}

```

How can I get RestHighLevelClient in ESIntegTestCase?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [May 7, 2019, 12:34am UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307/2 "2019-05-07T00:34:39Z")

</div>

`ESIntegTestCase` is meant for internal whitebox testing of Elasticsearch nodes and clustering. For users testing external behavior with Elasticsearch, we recommend standing up a real elasticsearch node and/or multi node cluster. This will allow you to then use the RestHighLevelClient, just as your normal application would.

---

<div class="post-metadata">

**Author:** ![rohitpatil](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@rohitpatil](https://discuss.elastic.co/u/rohitpatil)\
**Post date:** [May 7, 2019, 2:30am UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307/3 "2019-05-07T02:30:37Z")

</div>

Yes. But I wanted to run some unit tests with in memory or embedded ES. In previous version 6.6.0 I was able to use testing framework to start embedded cluster and run my unit tests.

I had to enable the HTTP using HTTP\_ENABLED flag.

Now is there any way to get the same thing working with this version? Because I cannot start separate cluster for these tests.

---

<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:** [May 7, 2019, 5:28am UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307/4 "2019-05-07T05:28:41Z")

</div>

You can not run elasticsearch embedded. Read this [blog post](https://www.elastic.co/blog/elasticsearch-the-server).

Note that to run integration tests (not unit tests) you would probably prefer running that in something close to a production environment, like a real elasticsearch server instance. 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)**
>
> ESIntegTestCase example. Contribute to joel-costigliola/elastic-search-test development by creating an account on GitHub.

---

<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:** [June 4, 2019, 5:28am UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307/5 "2019-06-04T05:28:48Z")

</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:57pm UTC](https://discuss.elastic.co/t/not-able-connect-with-rest-high-level-client-in-esintegtestcase-of-elasticsearch-7-0-0/179307/6 "2020-04-09T15:57:26Z")

</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.
