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,
// build.gradle
dependencies {
testImplementation "org.elasticsearch.plugin:transport-netty4-client:7.17.0"
// ...
}
// 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.