fix some tests, all fast tests now pass

This commit is contained in:
Ryan Ernst 2015-04-29 16:32:54 -07:00
parent 9dec558ea1
commit 5236a3d226
8 changed files with 41 additions and 8 deletions

View File

@ -127,6 +127,7 @@ public class TribeService extends AbstractLifecycleComponent<TribeService> {
for (Map.Entry<String, Settings> entry : nodesSettings.entrySet()) { for (Map.Entry<String, Settings> entry : nodesSettings.entrySet()) {
ImmutableSettings.Builder sb = ImmutableSettings.builder().put(entry.getValue()); ImmutableSettings.Builder sb = ImmutableSettings.builder().put(entry.getValue());
sb.put("node.name", settings.get("name") + "/" + entry.getKey()); sb.put("node.name", settings.get("name") + "/" + entry.getKey());
sb.put("path.home", settings.get("path.home")); // pass through ES home dir
sb.put(TRIBE_NAME, entry.getKey()); sb.put(TRIBE_NAME, entry.getKey());
sb.put("config.ignore_system_properties", true); sb.put("config.ignore_system_properties", true);
if (sb.get("http.enabled") == null) { if (sb.get("http.enabled") == null) {

View File

@ -62,7 +62,8 @@ public class TransportClientRetryTests extends ElasticsearchIntegrationTest {
.put("node.mode", InternalTestCluster.nodeMode()) .put("node.mode", InternalTestCluster.nodeMode())
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, false) .put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, false)
.put(ClusterName.SETTING, internalCluster().getClusterName()) .put(ClusterName.SETTING, internalCluster().getClusterName())
.put("config.ignore_system_properties", true); .put("config.ignore_system_properties", true)
.put("path.home", createTempDir());
try (TransportClient transportClient = new TransportClient(builder.build())) { try (TransportClient transportClient = new TransportClient(builder.build())) {
transportClient.addTransportAddresses(addresses); transportClient.addTransportAddresses(addresses);

View File

@ -25,7 +25,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.index.store.IndexStoreModule;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
@ -35,7 +34,10 @@ import org.junit.Test;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder; import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope; import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 1.0) @ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 1.0)
public class TransportClientTests extends ElasticsearchIntegrationTest { public class TransportClientTests extends ElasticsearchIntegrationTest {
@ -92,7 +94,8 @@ public class TransportClientTests extends ElasticsearchIntegrationTest {
@Test @Test
public void testThatTransportClientSettingCannotBeChanged() { public void testThatTransportClientSettingCannotBeChanged() {
try (TransportClient client = new TransportClient(settingsBuilder().put(Client.CLIENT_TYPE_SETTING, "anything"))) { Settings baseSettings = settingsBuilder().put(Client.CLIENT_TYPE_SETTING, "anything").put("path.home", createTempDir()).build();
try (TransportClient client = new TransportClient(baseSettings)) {
Settings settings = client.injector.getInstance(Settings.class); Settings settings = client.injector.getInstance(Settings.class);
assertThat(settings.get(Client.CLIENT_TYPE_SETTING), is("transport")); assertThat(settings.get(Client.CLIENT_TYPE_SETTING), is("transport"));
} }

View File

@ -22,6 +22,8 @@ package org.elasticsearch.common.cli;
import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.test.ElasticsearchTestCase; import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import java.io.IOException; import java.io.IOException;
@ -37,6 +39,16 @@ import java.util.Locale;
@Ignore @Ignore
public abstract class CliToolTestCase extends ElasticsearchTestCase { public abstract class CliToolTestCase extends ElasticsearchTestCase {
@Before
public void setPathHome() {
System.setProperty("es.default.path.home", createTempDir().toString());
}
@After
public void clearPathHome() {
System.clearProperty("es.default.path.home");
}
protected static String[] args(String command) { protected static String[] args(String command) {
if (!Strings.hasLength(command)) { if (!Strings.hasLength(command)) {
return Strings.EMPTY_ARRAY; return Strings.EMPTY_ARRAY;

View File

@ -29,6 +29,8 @@ import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
import org.elasticsearch.index.Index; import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.IndexNameModule;
import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.analysis.AnalysisModule;
@ -56,7 +58,10 @@ public class IndexQueryParserPlugin2Tests extends ElasticsearchTestCase {
@Test @Test
public void testCustomInjection() throws InterruptedException { public void testCustomInjection() throws InterruptedException {
Settings settings = ImmutableSettings.builder().put("name", "testCustomInjection").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); Settings settings = ImmutableSettings.builder()
.put("name", "testCustomInjection")
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put("path.home", createTempDir()).build();
IndexQueryParserModule queryParserModule = new IndexQueryParserModule(settings); IndexQueryParserModule queryParserModule = new IndexQueryParserModule(settings);
queryParserModule.addQueryParser("my", PluginJsonQueryParser.class); queryParserModule.addQueryParser("my", PluginJsonQueryParser.class);
@ -64,6 +69,7 @@ public class IndexQueryParserPlugin2Tests extends ElasticsearchTestCase {
Index index = new Index("test"); Index index = new Index("test");
Injector injector = new ModulesBuilder().add( Injector injector = new ModulesBuilder().add(
new EnvironmentModule(new Environment(settings)),
new SettingsModule(settings), new SettingsModule(settings),
new ThreadPoolModule(settings), new ThreadPoolModule(settings),
new IndicesQueriesModule(), new IndicesQueriesModule(),

View File

@ -29,6 +29,8 @@ import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
import org.elasticsearch.index.Index; import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.IndexNameModule;
import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.analysis.AnalysisModule;
@ -56,7 +58,10 @@ public class IndexQueryParserPluginTests extends ElasticsearchTestCase {
@Test @Test
public void testCustomInjection() throws InterruptedException { public void testCustomInjection() throws InterruptedException {
Settings settings = ImmutableSettings.builder().put("name", "testCustomInjection").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); Settings settings = ImmutableSettings.builder()
.put("name", "testCustomInjection")
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put("path.home", createTempDir()).build();
IndexQueryParserModule queryParserModule = new IndexQueryParserModule(settings); IndexQueryParserModule queryParserModule = new IndexQueryParserModule(settings);
queryParserModule.addProcessor(new IndexQueryParserModule.QueryParsersProcessor() { queryParserModule.addProcessor(new IndexQueryParserModule.QueryParsersProcessor() {
@ -73,6 +78,7 @@ public class IndexQueryParserPluginTests extends ElasticsearchTestCase {
Index index = new Index("test"); Index index = new Index("test");
Injector injector = new ModulesBuilder().add( Injector injector = new ModulesBuilder().add(
new EnvironmentModule(new Environment(settings)),
new SettingsModule(settings), new SettingsModule(settings),
new ThreadPoolModule(settings), new ThreadPoolModule(settings),
new IndicesQueriesModule(), new IndicesQueriesModule(),

View File

@ -28,6 +28,7 @@ import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
import org.elasticsearch.script.ScriptService.ScriptType; import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ElasticsearchTestCase; import org.elasticsearch.test.ElasticsearchTestCase;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
@ -50,8 +51,10 @@ public class NativeScriptTests extends ElasticsearchTestCase {
Settings settings = ImmutableSettings.settingsBuilder() Settings settings = ImmutableSettings.settingsBuilder()
.put("script.native.my.type", MyNativeScriptFactory.class.getName()) .put("script.native.my.type", MyNativeScriptFactory.class.getName())
.put("name", "testNativeScript") .put("name", "testNativeScript")
.put("path.home", createTempDir())
.build(); .build();
Injector injector = new ModulesBuilder().add( Injector injector = new ModulesBuilder().add(
new EnvironmentModule(new Environment(settings)),
new ThreadPoolModule(settings), new ThreadPoolModule(settings),
new SettingsModule(settings), new SettingsModule(settings),
new ScriptModule(settings)).createInjector(); new ScriptModule(settings)).createInjector();
@ -73,7 +76,7 @@ public class NativeScriptTests extends ElasticsearchTestCase {
String scriptContext = randomFrom(ScriptContext.Standard.values()).getKey(); String scriptContext = randomFrom(ScriptContext.Standard.values()).getKey();
builder.put(ScriptModes.SCRIPT_SETTINGS_PREFIX + scriptContext, randomFrom(ScriptMode.values())); builder.put(ScriptModes.SCRIPT_SETTINGS_PREFIX + scriptContext, randomFrom(ScriptMode.values()));
} }
Settings settings = builder.build(); Settings settings = builder.put("path.home", createTempDir()).build();
Environment environment = new Environment(settings); Environment environment = new Environment(settings);
ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, null); ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, null);
Map<String, NativeScriptFactory> nativeScriptFactoryMap = new HashMap<>(); Map<String, NativeScriptFactory> nativeScriptFactoryMap = new HashMap<>();

View File

@ -95,7 +95,8 @@ public class TribeUnitTests extends ElasticsearchTestCase {
//tribe node doesn't need the node.mode setting, as it's forced local internally anyways. The tribe clients do need it to make sure //tribe node doesn't need the node.mode setting, as it's forced local internally anyways. The tribe clients do need it to make sure
//they can find their corresponding tribes using the proper transport //they can find their corresponding tribes using the proper transport
Settings settings = ImmutableSettings.builder().put("http.enabled", false).put("node.name", "tribe_node") Settings settings = ImmutableSettings.builder().put("http.enabled", false).put("node.name", "tribe_node")
.put("tribe.t1.node.mode", NODE_MODE).put("tribe.t2.node.mode", NODE_MODE).put(extraSettings).build(); .put("tribe.t1.node.mode", NODE_MODE).put("tribe.t2.node.mode", NODE_MODE)
.put("path.home", createTempDir()).put(extraSettings).build();
try (Node node = NodeBuilder.nodeBuilder().settings(settings).node()) { try (Node node = NodeBuilder.nodeBuilder().settings(settings).node()) {
try (Client client = node.client()) { try (Client client = node.client()) {