nuke more cwd usage
This commit is contained in:
parent
c0587cb244
commit
9dec558ea1
|
@ -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
|
||||
* <tt>elasticsearch.(yml|json)</tt> files optionally prefixed with <tt>config/</tt>).
|
||||
*/
|
||||
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 <tt>elasticsearch.(yml|json)</tt> files optionally prefixed with <tt>config/</tt>).
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -44,11 +44,20 @@ public class InternalSettingsPreparerTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testIgnoreSystemProperties() {
|
||||
Tuple<Settings, Environment> tuple = InternalSettingsPreparer.prepareSettings(settingsBuilder().put("node.zone", "bar").build(), true);
|
||||
Settings settings = settingsBuilder()
|
||||
.put("node.zone", "bar")
|
||||
.put("path.home", createTempDir().toString())
|
||||
.build();
|
||||
Tuple<Settings, Environment> 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"));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue