Testing With Delete By Query ElasticSearch Plugin

Is there anyway to have integration test for a code that makes use of the delete by query plugin using embedded elasticsearch node?

Right now I get failed to find action [org.elasticsearch.action.deletebyquery.DeleteByQueryAction

For various reasons, I can't switch to using the official ElasticSearch testing classes. Is there anyway, whatsoever, in existence, to get an integration test to work using Embedded node with code that makes use of the delete-by-query plugin?

Yes it is possible, but the elasticsearch node needs to be able to load the plugin from classpath. Which version are you on? That makes quite a difference in how you achieve what you want. In general, you can have a look at our InternalTestCluster class that is part of the test-framework, that is where a lot of magic happens.

Note also that we are trying to move away from these kinds of tests where everything happens on the same jvm as they end up not being realistic. It is much better to just start an external cluster and fire http requests to it like we do in our REST tests.

Cheers
Luca

I am running version 2.3.3. How will this be achieved then?

Yes I understand the thinking behind discouraging this kind of tests, but for now, this is the approach I would need to work with :frowning:

Thanks

In 2.3 branch, you would need to write a class that does what MockNode does in our test infra: https://github.com/elastic/elasticsearch/blob/2.3/core/src/test/java/org/elasticsearch/node/MockNode.java . It allows to call the Node super constructor providing a list of plugins, which need to be available on the classpath. Then you can simply start the node and test against it.

Even if you are not going to use our test-framework, you can still have a look at how that works to figure things out and take inspiration from it. What is possible there is possible without it as well.

Cheers
Luca

1 Like