# ES 5.1 and Local transport for embedded node

**URL:** <https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035>\
**Category:** Elasticsearch\
**Created:** [February 14, 2017, 1:03pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035 "2017-02-14T13:03:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jammann](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jammann](https://discuss.elastic.co/u/jammann)\
**Post date:** [February 14, 2017, 1:03pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/1 "2017-02-14T13:03:22Z")

</div>

Hi

with ES 2.x we have made extensive use of an embedded node with local transport for unit and integration tests (not using the ESIntegTestCase but our own). With something like

```
masterNode = nodeBuilder().local(local).settings(settings.build()).node();

```

With the new ES 5.1.1 Java API, I was not immediately able to implement something similar. And also didn't find any reference to the local transport.

Does this feature still exist or should I use a regular Node with a TransportClient in my tests?

CU, Joe

---

<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:** [February 14, 2017, 1:16pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/2 "2017-02-14T13:16:44Z")

</div>

To do integration tests, start a real external elasticsearch node and then use your real client, whatever it is.

---

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [February 14, 2017, 2:04pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/3 "2017-02-14T14:04:46Z")

</div>

With the warning that this feels like a bit of a hack, it does work. This is the way I do "integration" tests in one of my projects. I do have some issues with running the unit tests without doing a clean before the test start.

```
public abstract class ElasticTestCase {
    private static Node node = null;

    @BeforeClass
    public static void setupOnce() throws NodeValidationException {
        Settings settings = Settings.builder()
                .put("path.home", "target/elasticsearch")
                .put("transport.type", "local")
                .put("http.enabled", true)
                .build();

        Collection plugins = Collections.singletonList(Netty4Plugin.class);
        node = new PluginConfigurableNode(settings, plugins).start();
    }

    @AfterClass
    public static void teardownOnce() throws IOException {
        node.close();
    }

    private static class PluginConfigurableNode extends Node {
        PluginConfigurableNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
            super(InternalSettingsPreparer.prepareEnvironment(settings, null), classpathPlugins);
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![jammann](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jammann](https://discuss.elastic.co/u/jammann)\
**Post date:** [February 14, 2017, 2:07pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/4 "2017-02-14T14:07:34Z")

</div>

Hi Jettro

thanks, exactly what I was looking for! We already made our share of experiences with having to clean stuff before/after unit tests with ES2.

Thanks, I will give it a try and report how it goes

CU, Joe

---

<div class="post-metadata">

**Author:** ![jammann](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jammann](https://discuss.elastic.co/u/jammann)\
**Post date:** [February 14, 2017, 9:10pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/5 "2017-02-14T21:10:38Z")

</div>

Yep, that worked, thanks! Now I'm fighting a bit to get a decent logging setup during my tests. My stuff used slf4j/logback and the embedded Elastic server really insists on Log4j2 🙂 But I'll get there

Thanks and CU, Joe

---

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [February 17, 2017, 7:39pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/6 "2017-02-17T19:39:39Z")

</div>

There is an slf4j-log4j2 library that you could use with the test dependency, that might work

---

<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:** [March 17, 2017, 7:39pm UTC](https://discuss.elastic.co/t/es-5-1-and-local-transport-for-embedded-node/75035/7 "2017-03-17T19:39:47Z")

</div>

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