# ElasticsearchIntegrationTest issue

**URL:** <https://discuss.elastic.co/t/elasticsearchintegrationtest-issue/19673>\
**Category:** Elasticsearch\
**Created:** [September 9, 2014, 5:46am UTC](https://discuss.elastic.co/t/elasticsearchintegrationtest-issue/19673 "2014-09-09T05:46:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gouketsu](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gouketsu](https://discuss.elastic.co/u/gouketsu)\
**Post date:** [September 9, 2014, 5:46am UTC](https://discuss.elastic.co/t/elasticsearchintegrationtest-issue/19673/1 "2014-09-09T05:46:45Z")

</div>

Hello,

```
 I'm encountered an issue when Elasticsearch 1.3.2 and the test.

```

The test suite is configure like this:  
@ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE,  
numDataNodes = 2)  
public abstract class AbstractRestActionTest extends  
ElasticsearchIntegrationTest {

```
@Override
protected Settings nodeSettings(int nodeOrdinal) {
    Settings settings = ImmutableSettings.settingsBuilder()
            .put(super.nodeSettings(nodeOrdinal))
            .put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, 

```

true)  
.put("plugin.types", InOutPlugin.class.getName())  
.put("index.number\_of\_shards", defaultShardCount())  
.put("index.number\_of\_replicas", 0)  
.put("http.enabled", false)  
.build();  
return settings;  
}

```
@Override
public Settings indexSettings() {
    return settingsBuilder().put("index.number_of_shards", 

```

defaultShardCount()).put("index.number\_of\_replicas", 0).build();  
}

public void setupTestIndexLikeUsers(String indexName, int shards, boolean  
loadTestData) throws IOException {  
System.out.println("CreateIndex "+ indexName);  
assertAcked(prepareCreate(indexName).setSettings(settingsBuilder().  
put("index.number\_of\_shards", shards).put("index.number\_of\_replicas", 0))  
.addMapping("d", jsonBuilder().startObject()  
.startObject("d")  
.startObject("properties")  
.startObject("name")  
.field("type", "string")  
.field("index", "not\_analyzed")  
.field("store", "yes")  
.endObject()  
.endObject()  
.endObject()));  
ensureGreen(indexName);

```
    if (loadTestData) {
        index(indexName, "d", "1", "name", "car");
        index(indexName, "d", "2", "name", "bike");
        index(indexName, "d", "3", "name", "train");
        index(indexName, "d", "4", "name", "bus");
    }
    refresh();
    waitForRelocation();
}

```

The plugins register RestModule and ActionModule like this:

```
public void onModule(RestModule restModule) {
    restModule.addRestAction(RestExportAction.class);
    restModule.addRestAction(RestImportAction.class);
    restModule.addRestAction(RestSearchIntoAction.class);
    restModule.addRestAction(RestDumpAction.class);
    restModule.addRestAction(RestRestoreAction.class);
    restModule.addRestAction(RestReindexAction.class);
}
public void onModule(ActionModule module) {
    if (!settings.getAsBoolean("node.client", false)) {
            module.registerAction(ExportAction.INSTANCE, 

```

TransportExportAction.class);  
module.registerAction(ImportAction.INSTANCE,  
TransportImportAction.class);  
module.registerAction(SearchIntoAction.INSTANCE,  
TransportSearchIntoAction.class);  
module.registerAction(DumpAction.INSTANCE,  
TransportDumpAction.class);  
module.registerAction(RestoreAction.INSTANCE,  
TransportRestoreAction.class);  
module.registerAction(ReindexAction.INSTANCE,  
TransportReindexAction.class);  
}  
}

Another module is registered for map binding like this in the code of  
plugin:

```
@Override
public Collection<Class<? extends Module>> modules() {
    Collection<Class<? extends Module>> modules = Lists.newArrayList();
    if (!settings.getAsBoolean("node.client", false)) {
            modules.add(SearchIntoModule.class);
    }
    return modules;
}

```

The configure in the SearchIntoModule class is like this:  
@Override  
protected void configure() {

```
    MapBinder<String, WriterCollectorFactory> collectorBinder
            = MapBinder.newMapBinder(binder(),
                    String.class, WriterCollectorFactory.class);

    collectorBinder.addBinding(BulkWriterCollector.NAME).toProvider(
                    FactoryProvider
                    .newFactory(WriterCollectorFactory.class,
                                    BulkWriterCollector.class)).in(

```

Scopes.SINGLETON);  
}

The BulkWriterCollector.NAME is index in the code.

Everything is working correctly when I register the plugins to my  
elasticsearch instance.  
But When I try to launch the test suite I have this error:

Map injection failed due to duplicated key "index"

> at  
> org.elasticsearch.common.inject.multibindings.MapBinder$RealMapBinder$1.initialize(Unknown  
> Source)  
> at  
> crate.elasticsearch.module.searchinto.SearchIntoModule.configure(SearchIntoModule.java:24

I put a trace in the configure method, and it's called 4 times during the  
test, but only one time when the plugins is used by an elasticsearch.

Is it another way to create a new MapBinder in Elasticsearch ?

Regards,  
JB damiano

--  
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/e3a002a1-6e25-4391-8bd9-edc18c0e9323%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e3a002a1-6e25-4391-8bd9-edc18c0e9323%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![gouketsu](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gouketsu](https://discuss.elastic.co/u/gouketsu)\
**Post date:** [September 11, 2014, 4:31pm UTC](https://discuss.elastic.co/t/elasticsearchintegrationtest-issue/19673/2 "2014-09-11T16:31:10Z")

</div>

I found the problem with the code.  
Is a test configuration issue.

The pluginsService class loads plugin from plugin.types information, but it  
calls another method,  
tupleBuilder.addAll(loadPluginsFromClasspath(settings));

The loadPluginsFromClasspath, in my case it find my plugin another time.  
It's for this reason that we have encountered the specified error.

Regards,

Le mardi 9 septembre 2014 07:46:45 UTC+2, Jean-Bernard Damiano a écrit :

> Hello,
> 
> ```
> I'm encountered an issue when Elasticsearch 1.3.2 and the test.
> 
> ```
> 
> The test suite is configure like this:  
> @ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE,  
> numDataNodes = 2)  
> public abstract class AbstractRestActionTest extends  
> ElasticsearchIntegrationTest {
> 
> ```
> @Override
> protected Settings nodeSettings(int nodeOrdinal) {
> Settings settings = ImmutableSettings.settingsBuilder()
> .put(super.nodeSettings(nodeOrdinal))
> .put("plugins." + PluginsService.
> 
> ```
> 
> LOAD\_PLUGIN\_FROM\_CLASSPATH, true)  
> .put("plugin.types", InOutPlugin.class.getName())  
> .put("index.number\_of\_shards", defaultShardCount())  
> .put("index.number\_of\_replicas", 0)  
> .put("http.enabled", false)  
> .build();  
> return settings;  
> }
> 
> ```
> @Override
> public Settings indexSettings() {
> return settingsBuilder().put("index.number_of_shards", 
> 
> ```
> 
> defaultShardCount()).put("index.number\_of\_replicas", 0).build();  
> }
> 
> public void setupTestIndexLikeUsers(String indexName, int shards,  
> boolean loadTestData) throws IOException {  
> System.out.println("CreateIndex "+ indexName);  
> assertAcked(prepareCreate(indexName).setSettings(settingsBuilder  
> ().put("index.number\_of\_shards", shards).put("index.number\_of\_replicas", 0  
> ))  
> .addMapping("d", jsonBuilder().startObject()  
> .startObject("d")  
> .startObject("properties")  
> .startObject("name")  
> .field("type", "string")  
> .field("index", "not\_analyzed")  
> .field("store", "yes")  
> .endObject()  
> .endObject()  
> .endObject()));  
> ensureGreen(indexName);
> 
> ```
> if (loadTestData) {
> index(indexName, "d", "1", "name", "car");
> index(indexName, "d", "2", "name", "bike");
> index(indexName, "d", "3", "name", "train");
> index(indexName, "d", "4", "name", "bus");
> }
> refresh();
> waitForRelocation();
> }
> 
> ```
> 
> The plugins register RestModule and ActionModule like this:
> 
> ```
> public void onModule(RestModule restModule) {
> restModule.addRestAction(RestExportAction.class);
> restModule.addRestAction(RestImportAction.class);
> restModule.addRestAction(RestSearchIntoAction.class);
> restModule.addRestAction(RestDumpAction.class);
> restModule.addRestAction(RestRestoreAction.class);
> restModule.addRestAction(RestReindexAction.class);
> }
> public void onModule(ActionModule module) {
> if (!settings.getAsBoolean("node.client", false)) {
> module.registerAction(ExportAction.INSTANCE, 
> 
> ```
> 
> TransportExportAction.class);  
> module.registerAction(ImportAction.INSTANCE,  
> TransportImportAction.class);  
> module.registerAction(SearchIntoAction.INSTANCE,  
> TransportSearchIntoAction.class);  
> module.registerAction(DumpAction.INSTANCE,  
> TransportDumpAction.class);  
> module.registerAction(RestoreAction.INSTANCE,  
> TransportRestoreAction.class);  
> module.registerAction(ReindexAction.INSTANCE,  
> TransportReindexAction.class);  
> }  
> }
> 
> Another module is registered for map binding like this in the code of  
> plugin:
> 
> ```
> @Override
> public Collection<Class<? extends Module<span style="color: #660;" 
> 
> ```
> 
> class="sty  
> ...

--  
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/0f093ce6-cfe2-48f1-a5ba-f6a0aad63bf8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f093ce6-cfe2-48f1-a5ba-f6a0aad63bf8%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, 1:03am UTC](https://discuss.elastic.co/t/elasticsearchintegrationtest-issue/19673/3 "2017-07-06T01:03:04Z")

</div>

Closed on July 6, 2017, 1:03am UTC


