|
@@ -32,11 +32,8 @@ import static org.hamcrest.CoreMatchers.endsWith;
|
|
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
|
|
import static org.hamcrest.CoreMatchers.nullValue;
|
|
|
import static org.hamcrest.CoreMatchers.startsWith;
|
|
|
-import static org.hamcrest.Matchers.arrayWithSize;
|
|
|
-import static org.hamcrest.Matchers.containsString;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
import static org.hamcrest.Matchers.hasSize;
|
|
|
-import static org.hamcrest.Matchers.hasToString;
|
|
|
|
|
|
/**
|
|
|
* Simple unit-tests for Environment.java
|
|
@@ -124,37 +121,11 @@ public class EnvironmentTests extends ESTestCase {
|
|
|
assertThat(environment.configFile(), equalTo(pathHome.resolve("config")));
|
|
|
}
|
|
|
|
|
|
- public void testNodeDoesNotRequireLocalStorage() {
|
|
|
- final Path pathHome = createTempDir().toAbsolutePath();
|
|
|
- final Settings settings =
|
|
|
- Settings.builder()
|
|
|
- .put("path.home", pathHome)
|
|
|
- .put("node.master", false)
|
|
|
- .put("node.data", false)
|
|
|
- .build();
|
|
|
- final Environment environment = new Environment(settings, null, false);
|
|
|
- assertThat(environment.dataFiles(), arrayWithSize(0));
|
|
|
- }
|
|
|
-
|
|
|
- public void testNodeDoesNotRequireLocalStorageButHasPathData() {
|
|
|
- final Path pathHome = createTempDir().toAbsolutePath();
|
|
|
- final Path pathData = pathHome.resolve("data");
|
|
|
- final Settings settings =
|
|
|
- Settings.builder()
|
|
|
- .put("path.home", pathHome)
|
|
|
- .put("path.data", pathData)
|
|
|
- .put("node.master", false)
|
|
|
- .put("node.data", false)
|
|
|
- .build();
|
|
|
- final IllegalStateException e = expectThrows(IllegalStateException.class, () -> new Environment(settings, null, false));
|
|
|
- assertThat(e, hasToString(containsString("node does not require local storage yet path.data is set to [" + pathData + "]")));
|
|
|
- }
|
|
|
-
|
|
|
public void testNonExistentTempPathValidation() {
|
|
|
Settings build = Settings.builder()
|
|
|
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
|
|
.build();
|
|
|
- Environment environment = new Environment(build, null, true, createTempDir().resolve("this_does_not_exist"));
|
|
|
+ Environment environment = new Environment(build, null, createTempDir().resolve("this_does_not_exist"));
|
|
|
FileNotFoundException e = expectThrows(FileNotFoundException.class, environment::validateTmpFile);
|
|
|
assertThat(e.getMessage(), startsWith("Temporary file directory ["));
|
|
|
assertThat(e.getMessage(), endsWith("this_does_not_exist] does not exist or is not accessible"));
|
|
@@ -164,7 +135,7 @@ public class EnvironmentTests extends ESTestCase {
|
|
|
Settings build = Settings.builder()
|
|
|
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
|
|
.build();
|
|
|
- Environment environment = new Environment(build, null, true, createTempFile("something", ".test"));
|
|
|
+ Environment environment = new Environment(build, null, createTempFile("something", ".test"));
|
|
|
IOException e = expectThrows(IOException.class, environment::validateTmpFile);
|
|
|
assertThat(e.getMessage(), startsWith("Configured temporary file directory ["));
|
|
|
assertThat(e.getMessage(), endsWith(".test] is not a directory"));
|
|
@@ -184,7 +155,7 @@ public class EnvironmentTests extends ESTestCase {
|
|
|
// the above paths will be treated as relative to the working directory
|
|
|
final Path workingDirectory = PathUtils.get(System.getProperty("user.dir"));
|
|
|
|
|
|
- final Environment environment = new Environment(settings, null, true, createTempDir());
|
|
|
+ final Environment environment = new Environment(settings, null, createTempDir());
|
|
|
final String homePath = Environment.PATH_HOME_SETTING.get(environment.settings());
|
|
|
assertPath(homePath, workingDirectory.resolve("home"));
|
|
|
|