diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/src/main/java/org/elasticsearch/client/transport/TransportClient.java index 6dd30b02af3..f99be431f14 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -103,14 +103,6 @@ public class TransportClient extends AbstractClient { private final TransportClientNodesService nodesService; private final InternalTransportClient internalClient; - /** - * Constructs a new transport client with settings loaded either from the classpath or the file system (the - * elasticsearch.(yml|json) files optionally prefixed with config/). - */ - public TransportClient() { - this(ImmutableSettings.Builder.EMPTY_SETTINGS, true); - } - /** * Constructs a new transport client with explicit settings and settings loaded either from the classpath or the file * system (the elasticsearch.(yml|json) files optionally prefixed with config/). diff --git a/src/test/java/org/elasticsearch/action/bulk/BulkProcessorTests.java b/src/test/java/org/elasticsearch/action/bulk/BulkProcessorTests.java index e357206bc38..68a11b0b8e5 100644 --- a/src/test/java/org/elasticsearch/action/bulk/BulkProcessorTests.java +++ b/src/test/java/org/elasticsearch/action/bulk/BulkProcessorTests.java @@ -29,6 +29,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; @@ -157,7 +158,10 @@ public class BulkProcessorTests extends ElasticsearchIntegrationTest { //https://github.com/elasticsearch/elasticsearch/issues/5038 public void testBulkProcessorConcurrentRequestsNoNodeAvailableException() throws Exception { //we create a transport client with no nodes to make sure it throws NoNodeAvailableException - Client transportClient = new TransportClient(); + Settings settings = ImmutableSettings.builder() + .put("path.home", createTempDir().toString()) + .build(); + Client transportClient = new TransportClient(settings); int bulkActions = randomIntBetween(10, 100); int numDocs = randomIntBetween(bulkActions, bulkActions + 100); diff --git a/src/test/java/org/elasticsearch/action/count/CountRequestBuilderTests.java b/src/test/java/org/elasticsearch/action/count/CountRequestBuilderTests.java index 22387d277e8..85bb2a384cc 100644 --- a/src/test/java/org/elasticsearch/action/count/CountRequestBuilderTests.java +++ b/src/test/java/org/elasticsearch/action/count/CountRequestBuilderTests.java @@ -23,6 +23,8 @@ import org.elasticsearch.action.support.QuerySourceBuilder; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.bytes.BytesArray; +import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; @@ -46,7 +48,10 @@ public class CountRequestBuilderTests extends ElasticsearchTestCase { public static void initClient() { //this client will not be hit by any request, but it needs to be a non null proper client //that is why we create it but we don't add any transport address to it - client = new TransportClient(); + Settings settings = ImmutableSettings.builder() + .put("path.home", createTempDir().toString()) + .build(); + client = new TransportClient(settings); } @AfterClass diff --git a/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java b/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java index 57a48bbbcc0..9b4b8bc77b8 100644 --- a/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java +++ b/src/test/java/org/elasticsearch/action/search/SearchRequestBuilderTests.java @@ -21,6 +21,8 @@ package org.elasticsearch.action.search; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; @@ -45,7 +47,10 @@ public class SearchRequestBuilderTests extends ElasticsearchTestCase { public static void initClient() { //this client will not be hit by any request, but it needs to be a non null proper client //that is why we create it but we don't add any transport address to it - client = new TransportClient(); + Settings settings = ImmutableSettings.builder() + .put("path.home", createTempDir().toString()) + .build(); + client = new TransportClient(settings); } @AfterClass diff --git a/src/test/java/org/elasticsearch/client/AbstractClientHeadersTests.java b/src/test/java/org/elasticsearch/client/AbstractClientHeadersTests.java index 05561a9dec0..304853543ad 100644 --- a/src/test/java/org/elasticsearch/client/AbstractClientHeadersTests.java +++ b/src/test/java/org/elasticsearch/client/AbstractClientHeadersTests.java @@ -88,7 +88,11 @@ public abstract class AbstractClientHeadersTests extends ElasticsearchTestCase { @Before public void initClient() { - client = buildClient(HEADER_SETTINGS, ACTIONS); + Settings settings = ImmutableSettings.builder() + .put(HEADER_SETTINGS) + .put("path.home", createTempDir().toString()) + .build(); + client = buildClient(settings, ACTIONS); } @After diff --git a/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java b/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java index c744c3cd7ee..07dd7f9c73d 100644 --- a/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java +++ b/src/test/java/org/elasticsearch/client/transport/TransportClientHeadersTests.java @@ -59,7 +59,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTests { .put("client.transport.sniff", false) .put("node.name", "transport_client_" + this.getTestName()) .put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, InternalTransportService.class.getName()) - .put(HEADER_SETTINGS) + .put(headersSettings) .build()); client.addTransportAddress(address); @@ -75,6 +75,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTests { .put("client.transport.nodes_sampler_interval", "1s") .put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, InternalTransportService.class.getName()) .put(HEADER_SETTINGS) + .put("path.home", createTempDir().toString()) .build()); try { client.addTransportAddress(address); diff --git a/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java b/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java index 112d8969433..0d131af78ae 100644 --- a/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java +++ b/src/test/java/org/elasticsearch/common/cli/CheckFileCommandTests.java @@ -54,73 +54,73 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { @Test public void testThatCommandLogsErrorMessageOnFail() throws Exception { - executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(captureOutputTerminal, Mode.CHANGE)); + executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.CHANGE)); assertThat(captureOutputTerminal.getTerminalOutput(), hasItem(containsString("Please ensure that the user account running Elasticsearch has read access to this file"))); } @Test public void testThatCommandLogsNothingWhenPermissionRemains() throws Exception { - executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(captureOutputTerminal, Mode.KEEP)); + executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.KEEP)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsNothingWhenDisabled() throws Exception { - executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(captureOutputTerminal, Mode.DISABLED)); + executeCommand(jimFsConfiguration, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsNothingIfFilesystemDoesNotSupportPermissions() throws Exception { - executeCommand(jimFsConfigurationWithoutPermissions, new PermissionCheckFileCommand(captureOutputTerminal, Mode.DISABLED)); + executeCommand(jimFsConfigurationWithoutPermissions, new PermissionCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsOwnerChange() throws Exception { - executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(captureOutputTerminal, Mode.CHANGE)); + executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.CHANGE)); assertThat(captureOutputTerminal.getTerminalOutput(), hasItem(allOf(containsString("Owner of file ["), containsString("] used to be ["), containsString("], but now is [")))); } @Test public void testThatCommandLogsNothingIfOwnerRemainsSame() throws Exception { - executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(captureOutputTerminal, Mode.KEEP)); + executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.KEEP)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsNothingIfOwnerIsDisabled() throws Exception { - executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(captureOutputTerminal, Mode.DISABLED)); + executeCommand(jimFsConfiguration, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsNothingIfFileSystemDoesNotSupportOwners() throws Exception { - executeCommand(jimFsConfigurationWithoutPermissions, new OwnerCheckFileCommand(captureOutputTerminal, Mode.DISABLED)); + executeCommand(jimFsConfigurationWithoutPermissions, new OwnerCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsIfGroupChanges() throws Exception { - executeCommand(jimFsConfiguration, new GroupCheckFileCommand(captureOutputTerminal, Mode.CHANGE)); + executeCommand(jimFsConfiguration, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.CHANGE)); assertThat(captureOutputTerminal.getTerminalOutput(), hasItem(allOf(containsString("Group of file ["), containsString("] used to be ["), containsString("], but now is [")))); } @Test public void testThatCommandLogsNothingIfGroupRemainsSame() throws Exception { - executeCommand(jimFsConfiguration, new GroupCheckFileCommand(captureOutputTerminal, Mode.KEEP)); + executeCommand(jimFsConfiguration, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.KEEP)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsNothingIfGroupIsDisabled() throws Exception { - executeCommand(jimFsConfiguration, new GroupCheckFileCommand(captureOutputTerminal, Mode.DISABLED)); + executeCommand(jimFsConfiguration, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @Test public void testThatCommandLogsNothingIfFileSystemDoesNotSupportGroups() throws Exception { - executeCommand(jimFsConfigurationWithoutPermissions, new GroupCheckFileCommand(captureOutputTerminal, Mode.DISABLED)); + executeCommand(jimFsConfigurationWithoutPermissions, new GroupCheckFileCommand(createTempDir(), captureOutputTerminal, Mode.DISABLED)); assertThat(captureOutputTerminal.getTerminalOutput(), hasSize(0)); } @@ -130,7 +130,10 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { try (FileSystem fs = Jimfs.newFileSystem(configuration)) { Path path = fs.getPath(randomAsciiOfLength(10)); - new CreateFileCommand(captureOutputTerminal, path).execute(ImmutableSettings.EMPTY, new Environment(ImmutableSettings.EMPTY)); + Settings settings = ImmutableSettings.builder() + .put("path.home", createTempDir().toString()) + .build(); + new CreateFileCommand(captureOutputTerminal, path).execute(settings, new Environment(settings)); assertThat(Files.exists(path), is(true)); } @@ -145,7 +148,10 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { Path path = fs.getPath(randomAsciiOfLength(10)); Files.write(path, "anything".getBytes(Charsets.UTF_8)); - new DeleteFileCommand(captureOutputTerminal, path).execute(ImmutableSettings.EMPTY, new Environment(ImmutableSettings.EMPTY)); + Settings settings = ImmutableSettings.builder() + .put("path.home", createTempDir().toString()) + .build(); + new DeleteFileCommand(captureOutputTerminal, path).execute(settings, new Environment(settings)); assertThat(Files.exists(path), is(false)); } @@ -163,16 +169,21 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { protected final Mode mode; protected FileSystem fs; protected Path[] paths; + final Path baseDir; - public AbstractTestCheckFileCommand(Terminal terminal, Mode mode) throws IOException { + public AbstractTestCheckFileCommand(Path baseDir, Terminal terminal, Mode mode) throws IOException { super(terminal); this.mode = mode; + this.baseDir = baseDir; } public CliTool.ExitStatus execute(FileSystem fs) throws Exception { this.fs = fs; this.paths = new Path[] { writePath(fs, "p1", "anything"), writePath(fs, "p2", "anything"), writePath(fs, "p3", "anything") }; - return super.execute(ImmutableSettings.EMPTY, new Environment(ImmutableSettings.EMPTY)); + Settings settings = ImmutableSettings.settingsBuilder() + .put("path.home", baseDir.toString()) + .build(); + return super.execute(ImmutableSettings.EMPTY, new Environment(settings)); } private Path writePath(FileSystem fs, String name, String content) throws IOException { @@ -192,8 +203,8 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { */ class PermissionCheckFileCommand extends AbstractTestCheckFileCommand { - public PermissionCheckFileCommand(Terminal terminal, Mode mode) throws IOException { - super(terminal, mode); + public PermissionCheckFileCommand(Path baseDir, Terminal terminal, Mode mode) throws IOException { + super(baseDir, terminal, mode); } @Override @@ -221,8 +232,8 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { */ class OwnerCheckFileCommand extends AbstractTestCheckFileCommand { - public OwnerCheckFileCommand(Terminal terminal, Mode mode) throws IOException { - super(terminal, mode); + public OwnerCheckFileCommand(Path baseDir, Terminal terminal, Mode mode) throws IOException { + super(baseDir, terminal, mode); } @Override @@ -251,8 +262,8 @@ public class CheckFileCommandTests extends ElasticsearchTestCase { */ class GroupCheckFileCommand extends AbstractTestCheckFileCommand { - public GroupCheckFileCommand(Terminal terminal, Mode mode) throws IOException { - super(terminal, mode); + public GroupCheckFileCommand(Path baseDir, Terminal terminal, Mode mode) throws IOException { + super(baseDir, terminal, mode); } @Override diff --git a/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java b/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java index c39c8a5b90f..24df66c77e8 100644 --- a/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java +++ b/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java @@ -56,6 +56,7 @@ public class Log4jESLoggerTests extends ElasticsearchTestCase { // Need to set custom path.conf so we can use a custom logging.yml file for the test Settings settings = ImmutableSettings.builder() .put("path.conf", configDir.toAbsolutePath()) + .put("path.home", createTempDir().toString()) .build(); LogConfigurator.configure(settings); diff --git a/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java b/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java index b53b434a492..1010ea734b3 100644 --- a/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java +++ b/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java @@ -59,6 +59,7 @@ public class LoggingConfigurationTests extends ElasticsearchTestCase { Path configDir = getDataPath("config"); Settings settings = ImmutableSettings.builder() .put("path.conf", configDir.toAbsolutePath()) + .put("path.home", createTempDir().toString()) .build(); LogConfigurator.configure(settings); @@ -87,7 +88,10 @@ public class LoggingConfigurationTests extends ElasticsearchTestCase { Path loggingConf = tmpDir.resolve(loggingConfiguration("json")); Files.write(loggingConf, "{\"json\": \"foo\"}".getBytes(StandardCharsets.UTF_8)); Environment environment = new Environment( - ImmutableSettings.builder().put("path.conf", tmpDir.toAbsolutePath()).build()); + ImmutableSettings.builder() + .put("path.conf", tmpDir.toAbsolutePath()) + .put("path.home", createTempDir().toString()) + .build()); ImmutableSettings.Builder builder = ImmutableSettings.builder(); LogConfigurator.resolveConfig(environment, builder); @@ -102,7 +106,10 @@ public class LoggingConfigurationTests extends ElasticsearchTestCase { Path loggingConf = tmpDir.resolve(loggingConfiguration("properties")); Files.write(loggingConf, "key: value".getBytes(StandardCharsets.UTF_8)); Environment environment = new Environment( - ImmutableSettings.builder().put("path.conf", tmpDir.toAbsolutePath()).build()); + ImmutableSettings.builder() + .put("path.conf", tmpDir.toAbsolutePath()) + .put("path.home", createTempDir().toString()) + .build()); ImmutableSettings.Builder builder = ImmutableSettings.builder(); LogConfigurator.resolveConfig(environment, builder); @@ -119,7 +126,10 @@ public class LoggingConfigurationTests extends ElasticsearchTestCase { Files.write(loggingConf1, "yml: bar".getBytes(StandardCharsets.UTF_8)); Files.write(loggingConf2, "yaml: bar".getBytes(StandardCharsets.UTF_8)); Environment environment = new Environment( - ImmutableSettings.builder().put("path.conf", tmpDir.toAbsolutePath()).build()); + ImmutableSettings.builder() + .put("path.conf", tmpDir.toAbsolutePath()) + .put("path.home", createTempDir().toString()) + .build()); ImmutableSettings.Builder builder = ImmutableSettings.builder(); LogConfigurator.resolveConfig(environment, builder); @@ -135,7 +145,10 @@ public class LoggingConfigurationTests extends ElasticsearchTestCase { Path invalidSuffix = tmpDir.resolve(loggingConfiguration(randomFrom(LogConfigurator.ALLOWED_SUFFIXES)) + randomInvalidSuffix()); Files.write(invalidSuffix, "yml: bar".getBytes(StandardCharsets.UTF_8)); Environment environment = new Environment( - ImmutableSettings.builder().put("path.conf", invalidSuffix.toAbsolutePath()).build()); + ImmutableSettings.builder() + .put("path.conf", invalidSuffix.toAbsolutePath()) + .put("path.home", createTempDir().toString()) + .build()); ImmutableSettings.Builder builder = ImmutableSettings.builder(); LogConfigurator.resolveConfig(environment, builder); diff --git a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java index fb9024a460d..8fb9a29488f 100644 --- a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java @@ -77,8 +77,11 @@ public class AnalysisModuleTests extends ElasticsearchTestCase { return injector.getInstance(AnalysisService.class); } - private static Settings loadFromClasspath(String path) { - return settingsBuilder().loadFromClasspath(path).put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + private Settings loadFromClasspath(String path) { + return settingsBuilder().loadFromClasspath(path) + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("path.home", createTempDir().toString()) + .build(); } @@ -103,8 +106,11 @@ public class AnalysisModuleTests extends ElasticsearchTestCase { @Test public void testVersionedAnalyzers() throws Exception { - Settings settings2 = settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.yml") - .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0).build(); + Settings settings2 = settingsBuilder() + .loadFromClasspath("org/elasticsearch/index/analysis/test1.yml") + .put("path.home", createTempDir().toString()) + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0) + .build(); AnalysisService analysisService2 = getAnalysisService(settings2); // indicesanalysisservice always has the current version @@ -202,11 +208,14 @@ public class AnalysisModuleTests extends ElasticsearchTestCase { @Test public void testWordListPath() throws Exception { - Environment env = new Environment(ImmutableSettings.Builder.EMPTY_SETTINGS); + Settings settings = ImmutableSettings.builder() + .put("path.home", createTempDir().toString()) + .build(); + Environment env = new Environment(settings); String[] words = new String[]{"donau", "dampf", "schiff", "spargel", "creme", "suppe"}; Path wordListFile = generateWordList(words); - Settings settings = settingsBuilder().loadFromSource("index: \n word_list_path: " + wordListFile.toAbsolutePath()).build(); + settings = settingsBuilder().loadFromSource("index: \n word_list_path: " + wordListFile.toAbsolutePath()).build(); Set wordList = Analysis.getWordSet(env, settings, "index.word_list"); MatcherAssert.assertThat(wordList.size(), equalTo(6)); diff --git a/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java b/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java index e2715f690c8..c592579c801 100644 --- a/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; +import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; @@ -49,6 +50,7 @@ public class CharFilterTests extends ElasticsearchTokenStreamTestCase { .putArray("index.analysis.char_filter.my_mapping.mappings", "ph=>f", "qu=>q") .put("index.analysis.analyzer.custom_with_char_filter.tokenizer", "standard") .putArray("index.analysis.analyzer.custom_with_char_filter.char_filter", "my_mapping") + .put("path.home", createTempDir().toString()) .build(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector(); Injector injector = new ModulesBuilder().add( @@ -74,6 +76,7 @@ public class CharFilterTests extends ElasticsearchTokenStreamTestCase { .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put("index.analysis.analyzer.custom_with_char_filter.tokenizer", "standard") .putArray("index.analysis.analyzer.custom_with_char_filter.char_filter", "html_strip") + .put("path.home", createTempDir().toString()) .build(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector(); Injector injector = new ModulesBuilder().add( diff --git a/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java b/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java index a3e7552f50b..37b3bfc21a7 100644 --- a/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java @@ -110,10 +110,18 @@ public class CompoundAnalysisTests extends ElasticsearchTestCase { } private Settings getJsonSettings() { - return settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.json").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + return settingsBuilder() + .loadFromClasspath("org/elasticsearch/index/analysis/test1.json") + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("path.home", createTempDir().toString()) + .build(); } private Settings getYamlSettings() { - return settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.yml").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + return settingsBuilder() + .loadFromClasspath("org/elasticsearch/index/analysis/test1.yml") + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("path.home", createTempDir().toString()) + .build(); } } diff --git a/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java b/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java index 996471a205c..eaab794e500 100644 --- a/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java @@ -42,7 +42,11 @@ public class PatternCaptureTokenFilterTests extends ElasticsearchTokenStreamTest @Test public void testPatternCaptureTokenFilter() throws Exception { Index index = new Index("test"); - Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/pattern_capture.json").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings settings = settingsBuilder() + .put("path.home", createTempDir()) + .loadFromClasspath("org/elasticsearch/index/analysis/pattern_capture.json") + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .build(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector(); Injector injector = new ModulesBuilder().add( new IndexSettingsModule(index, settings), diff --git a/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java b/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java index 134b2cd5e3e..00e59547a69 100644 --- a/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java @@ -42,7 +42,11 @@ public class StopAnalyzerTests extends ElasticsearchTokenStreamTestCase { @Test public void testDefaultsCompoundAnalysis() throws Exception { Index index = new Index("test"); - Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/stop.json").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings settings = settingsBuilder() + .loadFromClasspath("org/elasticsearch/index/analysis/stop.json") + .put("path.home", createTempDir().toString()) + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .build(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector(); Injector injector = new ModulesBuilder().add( new IndexSettingsModule(index, settings), diff --git a/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java b/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java index 654a377a4f1..15872851d45 100644 --- a/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java +++ b/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java @@ -67,6 +67,7 @@ public class TemplateQueryParserTest extends ElasticsearchTestCase { @Before public void setup() throws IOException { Settings settings = ImmutableSettings.settingsBuilder() + .put("path.home", createTempDir().toString()) .put("path.conf", this.getDataPath("config")) .put("name", getClass().getName()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) diff --git a/src/test/java/org/elasticsearch/node/internal/InternalSettingsPreparerTests.java b/src/test/java/org/elasticsearch/node/internal/InternalSettingsPreparerTests.java index 8db6fd4e5c0..25cc99820b6 100644 --- a/src/test/java/org/elasticsearch/node/internal/InternalSettingsPreparerTests.java +++ b/src/test/java/org/elasticsearch/node/internal/InternalSettingsPreparerTests.java @@ -44,11 +44,20 @@ public class InternalSettingsPreparerTests extends ElasticsearchTestCase { @Test public void testIgnoreSystemProperties() { - Tuple tuple = InternalSettingsPreparer.prepareSettings(settingsBuilder().put("node.zone", "bar").build(), true); + Settings settings = settingsBuilder() + .put("node.zone", "bar") + .put("path.home", createTempDir().toString()) + .build(); + Tuple tuple = InternalSettingsPreparer.prepareSettings(settings, true); // Should use setting from the system property assertThat(tuple.v1().get("node.zone"), equalTo("foo")); - tuple = InternalSettingsPreparer.prepareSettings(settingsBuilder().put("config.ignore_system_properties", true).put("node.zone", "bar").build(), true); + settings = settingsBuilder() + .put("config.ignore_system_properties", true) + .put("node.zone", "bar") + .put("path.home", createTempDir().toString()) + .build(); + tuple = InternalSettingsPreparer.prepareSettings(settings, true); // Should use setting from the system property assertThat(tuple.v1().get("node.zone"), equalTo("bar")); } diff --git a/src/test/java/org/elasticsearch/script/ScriptServiceTests.java b/src/test/java/org/elasticsearch/script/ScriptServiceTests.java index 69aa8685835..c3f164ab25f 100644 --- a/src/test/java/org/elasticsearch/script/ScriptServiceTests.java +++ b/src/test/java/org/elasticsearch/script/ScriptServiceTests.java @@ -69,6 +69,7 @@ public class ScriptServiceTests extends ElasticsearchTestCase { public void setup() throws IOException { Path genericConfigFolder = createTempDir(); baseSettings = settingsBuilder() + .put("path.home", createTempDir().toString()) .put("path.conf", genericConfigFolder) .build(); resourceWatcherService = new ResourceWatcherService(baseSettings, null); diff --git a/src/test/java/org/elasticsearch/stresstest/client/ClientFailover.java b/src/test/java/org/elasticsearch/stresstest/client/ClientFailover.java index 86ae03992e2..c00ceec27b3 100644 --- a/src/test/java/org/elasticsearch/stresstest/client/ClientFailover.java +++ b/src/test/java/org/elasticsearch/stresstest/client/ClientFailover.java @@ -21,6 +21,7 @@ package org.elasticsearch.stresstest.client; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; @@ -38,8 +39,10 @@ public class ClientFailover { for (int i = 0; i < nodes.length; i++) { nodes[i] = NodeBuilder.nodeBuilder().node(); } + + // TODO: what is this? a public static void main test?!?! - final TransportClient client = new TransportClient() + final TransportClient client = new TransportClient(ImmutableSettings.EMPTY) .addTransportAddress(new InetSocketTransportAddress("localhost", 9300)) .addTransportAddress(new InetSocketTransportAddress("localhost", 9301)) .addTransportAddress(new InetSocketTransportAddress("localhost", 9302)); diff --git a/src/test/java/org/elasticsearch/stresstest/manyindices/ManyIndicesRemoteStressTest.java b/src/test/java/org/elasticsearch/stresstest/manyindices/ManyIndicesRemoteStressTest.java index 66239f34347..fb113a604b7 100644 --- a/src/test/java/org/elasticsearch/stresstest/manyindices/ManyIndicesRemoteStressTest.java +++ b/src/test/java/org/elasticsearch/stresstest/manyindices/ManyIndicesRemoteStressTest.java @@ -47,8 +47,9 @@ public class ManyIndicesRemoteStressTest { Client client; Node node = null; + // TODO: what is this? a public static void main test?!?!?! if (true) { - client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300)); + client = new TransportClient(ImmutableSettings.EMPTY).addTransportAddress(new InetSocketTransportAddress("localhost", 9300)); } else { node = NodeBuilder.nodeBuilder().client(true).node(); client = node.client(); diff --git a/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationTests.java b/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationTests.java index 10b7fa91ac0..53919f8a718 100644 --- a/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationTests.java +++ b/src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationTests.java @@ -66,6 +66,7 @@ public class NettyTransportMultiPortIntegrationTests extends ElasticsearchIntegr Settings settings = settingsBuilder() .put("cluster.name", internalCluster().getClusterName()) .put(TransportModule.TRANSPORT_TYPE_KEY, NettyTransport.class.getName()) + .put("path.home", createTempDir().toString()) .build(); try (TransportClient transportClient = new TransportClient(settings, false)) { transportClient.addTransportAddress(new InetSocketTransportAddress("127.0.0.1", randomPort));