Allow additional settings for the node in ESSingleNodeTestCase

This change adds a method that extending classes can override to provide additional settings
for the node used in a single node test case.
This commit is contained in:
jaymode 2016-03-10 07:16:37 -05:00
parent f9622f9acc
commit 9f92325587
1 changed files with 6 additions and 1 deletions

View File

@ -32,7 +32,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.lease.Releasables;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.BigArrays;
@ -160,6 +159,11 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
return Arrays.asList(plugins); return Arrays.asList(plugins);
} }
/** Additional settings to add when creating the node. Also allows overriding the default settings. */
protected Settings nodeSettings() {
return Settings.EMPTY;
}
private Node newNode() { private Node newNode() {
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", randomLong())) .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", randomLong()))
@ -177,6 +181,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
.put(Node.NODE_LOCAL_SETTING.getKey(), true) .put(Node.NODE_LOCAL_SETTING.getKey(), true)
.put(Node.NODE_DATA_SETTING.getKey(), true) .put(Node.NODE_DATA_SETTING.getKey(), true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // make sure we get what we set :) .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // make sure we get what we set :)
.put(nodeSettings()) // allow test cases to provide their own settings or override these
.build(); .build();
Node build = new MockNode(settings, getVersion(), getPlugins()); Node build = new MockNode(settings, getVersion(), getPlugins());
build.start(); build.start();