# Avoid loading plugin in tests

**URL:** <https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544>\
**Category:** Elasticsearch\
**Created:** [November 3, 2014, 5:50pm UTC](https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544 "2014-11-03T17:50:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laurent\_T](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/laurent_t/32/1133_2.png) [@Laurent\_T](https://discuss.elastic.co/u/Laurent_T)\
**Post date:** [November 3, 2014, 5:50pm UTC](https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544/1 "2014-11-03T17:50:14Z")

</div>

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](mailto: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).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 3, 2014, 5:57pm UTC](https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544/2 "2014-11-03T17:57:15Z")

</div>

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](mailto: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](mailto: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)  
> [https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](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](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [November 3, 2014, 6:07pm UTC](https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544/3 "2014-11-03T18:07:17Z")

</div>

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](mailto: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](mailto: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)  
> [https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoG2WyMtYtHeUh8xBCuDE7%3DoR5Xq24TWXQAY53KKQ2H_Bg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Laurent\_T](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/laurent_t/32/1133_2.png) [@Laurent\_T](https://discuss.elastic.co/u/Laurent_T)\
**Post date:** [November 4, 2014, 8:24am UTC](https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544/4 "2014-11-04T08:24:24Z")

</div>

Exactly what I was looking for. Works like a charm 🙂

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](mailto: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](mailto: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)  
> > [https://groups.google.com/d/msgid/elasticsearch/57bbfb19-341c-4d39-9c90-218596406b75%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/a4b2a6c2-68fd-4ddc-a662-b0861bae16d7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:52am UTC](https://discuss.elastic.co/t/avoid-loading-plugin-in-tests/20544/5 "2017-07-06T00:52:21Z")

</div>


