I am using Elasticsearch 2.2.0 where I am trying to run the following test case:
package com.animesh.elasticsearch.plugin;
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
import org.apache.commons.io.IOUtils;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0)
public class NewPluginTest extends ESIntegTestCase {
private final static String indexName = "new_index";
private final static String templateJson = "template.json";
private final static String templateName = "F:\\ESPluginTest\\src\\test\\resources\\template.json";
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(NewSimilarityPlugin.class);
}
@Test
public void IndexExists() throws IOException {
try {
String currentTemplate = IOUtils.toString(getClass().getResourceAsStream(templateJson));
assertNotNull("The template should not be null", currentTemplate);
PutIndexTemplateResponse response = client().admin()
.indices()
.preparePutTemplate(templateName)
.setSource(currentTemplate)
.execute()
.actionGet();
if (!response.isAcknowledged())
Assert.fail("Could not create the template");
assertNotNull(getResponse.getIndexTemplates());
assertThat(getResponse.getIndexTemplates(), hasSize(1));
} catch (Exception e) {
Assert.fail("There was some error in defining the template");
}
}
}
Here NewSimilarityPlugin
is a plugin that I designed for customizing default scoring.
Following is the error stack trace that I get:
févr. 07, 2016 7:03:58 PM org.elasticsearch.test.ESIntegTestCase printTestMessage
INFOS: [NewPluginTest#IndexExists]: setup test
févr. 07, 2016 7:03:58 PM org.elasticsearch.test.InternalTestCluster <init>
INFOS: Setup InternalTestCluster [SUITE-CHILD_VM=[0]-CLUSTER_SEED=[-4798790696630023454]-HASH=[13D1DB516FD4]-cluster] with seed [BD67454957EB0AE2] using [0] data nodes and [0] client nodes
hello
févr. 07, 2016 7:03:58 PM org.elasticsearch.test.ESIntegTestCase printTestMessage
INFOS: [NewPluginTest#IndexExists]: starting test
févr. 07, 2016 7:03:58 PM org.elasticsearch.test.ESIntegTestCase printTestMessage
INFOS: [NewPluginTest#IndexExists]: finished test
févr. 07, 2016 7:03:58 PM org.elasticsearch.test.ESIntegTestCase printTestMessage
INFOS: [NewPluginTest#IndexExists]: cleaning up after test
févr. 07, 2016 7:03:58 PM org.elasticsearch.node.Node <init>
INFOS: [node_s0] version[2.2.0], pid[5612], build[8ff36d1/2016-01-27T13:32:39Z]
févr. 07, 2016 7:03:58 PM org.elasticsearch.node.Node <init>
INFOS: [node_s0] initializing ...
java.lang.NullPointerException
at __randomizedtesting.SeedInfo.seed([61AFD1CE4299DDF4:312F64C6F6D6BBA8]:0)
at org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules$1.compare(PluginsAndModules.java:56)
at org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules$1.compare(PluginsAndModules.java:53)
at java.util.TimSort.binarySort(TimSort.java:292)
at java.util.TimSort.sort(TimSort.java:217)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules.getPluginInfos(PluginsAndModules.java:53)
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:176)
at org.elasticsearch.node.Node.<init>(Node.java:146)
at org.elasticsearch.node.MockNode.<init>(MockNode.java:43)
at org.elasticsearch.test.InternalTestCluster.buildNode(InternalTestCluster.java:606) ...
Process finished with exit code -1
UPDATE:
I noticed that client()
's value is null which is causing this issue.