Avoid loading plugin in tests

Hi,

I have an ES plugin that basically intercepts POST requests on a specific
path and builds ES queries depending on the post data before executing
these and returning a result.
I have some unit tests that create a local node to tests the queries. My
problem is that it loads my plugin which I do not want.

Is there any way I can avoid that ? Perhaps with some specific settings ?

Here's how I'm currently getting the test es client:

NodeBuilder.nodeBuilder().local(true).node().client()

The reason I do not want it to load the plugin is that it creates two
instances of the plugin: one in the tests and one in the local node.

Thanks
Regards,

Laurent

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This has been in flux a bit lately but the last time I checked you had to
intentionally load plugins by adding something like this to your test:
/**
* Enable plugin loading.
*/
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return
ImmutableSettings.builder().put(super.nodeSettings(nodeOrdinal))
.put("plugins." +
PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true).build();
}

I imagine you could always set that to false.

I believe it'd be important to add this annotation to your test though:
@ElasticsearchIntegrationTest.ClusterScope(scope =
ElasticsearchIntegrationTest.Scope.SUITE, transportClientRatio = 0.0)
so that the cluster you build without your plugin doesn't get reused for
other tests that need your plugin.

Nik

On Mon, Nov 3, 2014 at 12:50 PM, Laurent T. lau.thoulon@gmail.com wrote:

Hi,

I have an ES plugin that basically intercepts POST requests on a specific
path and builds ES queries depending on the post data before executing
these and returning a result.
I have some unit tests that create a local node to tests the queries. My
problem is that it loads my plugin which I do not want.

Is there any way I can avoid that ? Perhaps with some specific settings ?

Here's how I'm currently getting the test es client:

NodeBuilder.nodeBuilder().local(true).node().client()

The reason I do not want it to load the plugin is that it creates two
instances of the plugin: one in the tests and one in the local node.

Thanks
Regards,

Laurent

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2BeV9LOHyxLGcs2D5xP9axHh0tPE-X%2B0b%3DDTb%3D6z8_1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

You can disable loading plugins by using a custom class loader that only
points to the 'lib' folder of the ES home, or includes the Elasticsearch
jars from dependency path, respectively.

Settings clientSettings = ImmutableSettings.settingsBuilder()
.classLoader(yourcustomclassloader),
...);
NodeBuilder.nodeBuilder().local(true).settings(clientSettings).build();
...

Jörg

On Mon, Nov 3, 2014 at 6:50 PM, Laurent T. lau.thoulon@gmail.com wrote:

Hi,

I have an ES plugin that basically intercepts POST requests on a specific
path and builds ES queries depending on the post data before executing
these and returning a result.
I have some unit tests that create a local node to tests the queries. My
problem is that it loads my plugin which I do not want.

Is there any way I can avoid that ? Perhaps with some specific settings ?

Here's how I'm currently getting the test es client:

NodeBuilder.nodeBuilder().local(true).node().client()

The reason I do not want it to load the plugin is that it creates two
instances of the plugin: one in the tests and one in the local node.

Thanks
Regards,

Laurent

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoG2WyMtYtHeUh8xBCuDE7%3DoR5Xq24TWXQAY53KKQ2H_Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Exactly what I was looking for. Works like a charm :slight_smile:

BTW, i do not use ElasticsearchIntegrationTest. Maybe I should but as tests
were written in version 0.90.3 I haven't had the time to upgrade them and
use the new testing framework.
I'm not sure how much time this would take.

Anyway thanks for your help !
regards,
Laurent

On Monday, November 3, 2014 6:57:50 PM UTC+1, Nikolas Everett wrote:

This has been in flux a bit lately but the last time I checked you had to
intentionally load plugins by adding something like this to your test:
/**
* Enable plugin loading.
*/
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return
ImmutableSettings.builder().put(super.nodeSettings(nodeOrdinal))
.put("plugins." +
PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true).build();
}

I imagine you could always set that to false.

I believe it'd be important to add this annotation to your test though:
@ElasticsearchIntegrationTest.ClusterScope(scope =
ElasticsearchIntegrationTest.Scope.SUITE, transportClientRatio = 0.0)
so that the cluster you build without your plugin doesn't get reused for
other tests that need your plugin.

Nik

On Mon, Nov 3, 2014 at 12:50 PM, Laurent T. <lau.t...@gmail.com
<javascript:>> wrote:

Hi,

I have an ES plugin that basically intercepts POST requests on a specific
path and builds ES queries depending on the post data before executing
these and returning a result.
I have some unit tests that create a local node to tests the queries. My
problem is that it loads my plugin which I do not want.

Is there any way I can avoid that ? Perhaps with some specific settings ?

Here's how I'm currently getting the test es client:

NodeBuilder.nodeBuilder().local(true).node().client()

The reason I do not want it to load the plugin is that it creates two
instances of the plugin: one in the tests and one in the local node.

Thanks
Regards,

Laurent

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a4b2a6c2-68fd-4ddc-a662-b0861bae16d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.