# Access to Netty4Plugin(transport-netty4) in custom plugins to run test codes with RestClient and ESIntegTestCase in version 8.0.0

**URL:** <https://discuss.elastic.co/t/access-to-netty4plugin-transport-netty4-in-custom-plugins-to-run-test-codes-with-restclient-and-esintegtestcase-in-version-8-0-0/297288>\
**Category:** Elasticsearch\
**Created:** [February 15, 2022, 7:09pm UTC](https://discuss.elastic.co/t/access-to-netty4plugin-transport-netty4-in-custom-plugins-to-run-test-codes-with-restclient-and-esintegtestcase-in-version-8-0-0/297288 "2022-02-15T19:09:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harori](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@harori](https://discuss.elastic.co/u/harori)\
**Post date:** [February 15, 2022, 7:09pm UTC](https://discuss.elastic.co/t/access-to-netty4plugin-transport-netty4-in-custom-plugins-to-run-test-codes-with-restclient-and-esintegtestcase-in-version-8-0-0/297288/1 "2022-02-15T19:09:49Z")

</div>

Hello!

First of all, I'd like to say thank you for maintaining such great projects and communities. I'm big fan of Elasticsearch.

I wrote several custom plugins for Elasticsearch, and I have some test codes which use `ESIntegTestCase`.

As I know, `getRestClient()` in `ESIntegTestCase` use dummy `MockHttpTransport` for default, and cannot be used to perform actual REST actions for testing.

Therefore, I add `Netty4Plugin` module to the test codes like below,

```auto
// build.gradle
dependencies {
    testImplementation "org.elasticsearch.plugin:transport-netty4-client:7.17.0"
    // ...
}

```

```auto
// test code
public class HelloWorldIntegTests extends ESIntegTestCase() {
    @Override
    public Collection<Class<? extends Plugin>> nodePlugins() {
        return Arrays.asList(
            HelloWorldPlugin.class,
            Netty4Plugin.class
        );
    }

    @Override
    public Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
        final Settings defaultSettings = super.nodeSettings(nodeOrdinal, otherSettings);
        return Settings.builder()
            .put(defaultSettings)
            .put(NetworkModule.HTTP_TYPE_SETTING.key, Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
            .put("my.settings", "my-settings-value")
            .build();
    }

    @Test
    public void testSomething() {
        final RestClient restClient = getRestClient();
        // do test with RestClient ...
    }
}

```

However, after 8.0 release, `transport-netty4-client` distribution has stopped. and I lose ways to access `Netty4Plugin` module in our plugin level. Is there any other proper ways to get actual working `RestClient` in the plugin test code level?

I tried javaRestTest and yamlRestTest with `elasticsearch.java-rest-test` and `elasticsearch.yaml-rest-test` plugins. It worked, but those were little bit complex for our small plugins and If possible, I want to resuse existing `ESIntegTestCase` codes in 8.0 too.

Thank you.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 17, 2022, 9:42am UTC](https://discuss.elastic.co/t/access-to-netty4plugin-transport-netty4-in-custom-plugins-to-run-test-codes-with-restclient-and-esintegtestcase-in-version-8-0-0/297288/2 "2022-02-17T09:42:45Z")

</div>

Hey,

while this does not solve the netty issue per se, have you considered using Testcontainers instead. For an example, see this blog post [Using Testcontainers To Test Elasticsearch Plugins](https://spinscale.de/posts/2021-08-25-using-testcontainers-to-test-elasticsearch-plugins.html)

This way you can install the plugin as part of testcontainers and basically ensure, that the plugin can also be installed correctly.

IIRC the netty4 transport has been moved to a module and is no more a plugin, thus it is packaged within the Elasticsearch distribution only.

Hope this helps!

--Alex

---

<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, 2022, 9:43am UTC](https://discuss.elastic.co/t/access-to-netty4plugin-transport-netty4-in-custom-plugins-to-run-test-codes-with-restclient-and-esintegtestcase-in-version-8-0-0/297288/3 "2022-03-17T09:43:06Z")

</div>

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