|
@@ -62,7 +62,7 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
|
|
|
public void test30MissingBundledJdk() throws Exception {
|
|
|
final Installation.Executables bin = installation.executables();
|
|
|
- sh.getEnv().remove("JAVA_HOME");
|
|
|
+ sh.getEnv().remove("ES_JAVA_HOME");
|
|
|
|
|
|
final Path relocatedJdk = installation.bundledJdk.getParent().resolve("jdk.relocated");
|
|
|
|
|
@@ -73,7 +73,7 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
// ask for elasticsearch version to quickly exit if java is actually found (ie test failure)
|
|
|
final Result runResult = sh.runIgnoreExitCode(bin.elasticsearch.toString() + " -v");
|
|
|
assertThat(runResult.exitCode, is(1));
|
|
|
- assertThat(runResult.stderr, containsString("could not find java in bundled jdk"));
|
|
|
+ assertThat(runResult.stderr, containsString("could not find java in bundled JDK"));
|
|
|
} finally {
|
|
|
if (distribution().hasJdk) {
|
|
|
mv(relocatedJdk, installation.bundledJdk);
|
|
@@ -83,13 +83,12 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
|
|
|
public void test31BadJavaHome() throws Exception {
|
|
|
final Installation.Executables bin = installation.executables();
|
|
|
- sh.getEnv().put("JAVA_HOME", "doesnotexist");
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", "doesnotexist");
|
|
|
|
|
|
// ask for elasticsearch version to quickly exit if java is actually found (ie test failure)
|
|
|
final Result runResult = sh.runIgnoreExitCode(bin.elasticsearch.toString() + " -V");
|
|
|
assertThat(runResult.exitCode, is(1));
|
|
|
- assertThat(runResult.stderr, containsString("could not find java in JAVA_HOME"));
|
|
|
-
|
|
|
+ assertThat(runResult.stderr, containsString("could not find java in ES_JAVA_HOME"));
|
|
|
}
|
|
|
|
|
|
public void test32SpecialCharactersInJdkPath() throws Exception {
|
|
@@ -97,7 +96,7 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
assumeTrue("Only run this test when we know where the JDK is.", distribution().hasJdk);
|
|
|
|
|
|
final Path relocatedJdk = installation.bundledJdk.getParent().resolve("a (special) path");
|
|
|
- sh.getEnv().put("JAVA_HOME", relocatedJdk.toString());
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", relocatedJdk.toString());
|
|
|
|
|
|
try {
|
|
|
mv(installation.bundledJdk, relocatedJdk);
|
|
@@ -130,16 +129,42 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
stopElasticsearch();
|
|
|
}
|
|
|
|
|
|
+ public void test51EsJavaHomeOverride() throws Exception {
|
|
|
+ Platforms.onLinux(() -> {
|
|
|
+ String systemJavaHome1 = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", systemJavaHome1);
|
|
|
+ });
|
|
|
+ Platforms.onWindows(() -> {
|
|
|
+ final String systemJavaHome1 = sh.run("$Env:SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", systemJavaHome1);
|
|
|
+ });
|
|
|
+
|
|
|
+ startElasticsearch();
|
|
|
+ ServerUtils.runElasticsearchTests();
|
|
|
+ stopElasticsearch();
|
|
|
+
|
|
|
+ String systemJavaHome1 = sh.getEnv().get("ES_JAVA_HOME");
|
|
|
+ assertThat(FileUtils.slurpAllLogs(installation.logs, "elasticsearch.log", "*.log.gz"), containsString(systemJavaHome1));
|
|
|
+ }
|
|
|
+
|
|
|
public void test51JavaHomeOverride() throws Exception {
|
|
|
Platforms.onLinux(() -> {
|
|
|
String systemJavaHome1 = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
sh.getEnv().put("JAVA_HOME", systemJavaHome1);
|
|
|
+ // ensure that ES_JAVA_HOME is not set for the test
|
|
|
+ sh.getEnv().remove("ES_JAVA_HOME");
|
|
|
});
|
|
|
Platforms.onWindows(() -> {
|
|
|
final String systemJavaHome1 = sh.run("$Env:SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
sh.getEnv().put("JAVA_HOME", systemJavaHome1);
|
|
|
+ // ensure that ES_JAVA_HOME is not set for the test
|
|
|
+ sh.getEnv().remove("ES_JAVA_HOME");
|
|
|
});
|
|
|
|
|
|
+ final Installation.Executables bin = installation.executables();
|
|
|
+ final Result runResult = sh.run(bin.elasticsearch.toString() + " -V");
|
|
|
+ assertThat(runResult.stderr, containsString("warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME"));
|
|
|
+
|
|
|
startElasticsearch();
|
|
|
ServerUtils.runElasticsearchTests();
|
|
|
stopElasticsearch();
|
|
@@ -148,6 +173,32 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
assertThat(FileUtils.slurpAllLogs(installation.logs, "elasticsearch.log", "*.log.gz"), containsString(systemJavaHome1));
|
|
|
}
|
|
|
|
|
|
+ public void test51EsJavaHomeOverrideOverridesJavaHome() throws Exception {
|
|
|
+ Platforms.onLinux(() -> {
|
|
|
+ String systemJavaHome1 = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", systemJavaHome1);
|
|
|
+ // deliberately set to a location that does not exist, if ES_JAVA_HOME takes precedence this is ignored
|
|
|
+ sh.getEnv().put("JAVA_HOME", "doesnotexist");
|
|
|
+ });
|
|
|
+ Platforms.onWindows(() -> {
|
|
|
+ final String systemJavaHome1 = sh.run("$Env:SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", systemJavaHome1);
|
|
|
+ // deliberately set to a location that does not exist, if ES_JAVA_HOME takes precedence this is ignored
|
|
|
+ sh.getEnv().put("JAVA_HOME", "doesnotexist");
|
|
|
+ });
|
|
|
+
|
|
|
+ final Installation.Executables bin = installation.executables();
|
|
|
+ final Result runResult = sh.run(bin.elasticsearch.toString() + " -V");
|
|
|
+ assertThat(runResult.stderr, not(containsString("warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME")));
|
|
|
+
|
|
|
+ startElasticsearch();
|
|
|
+ ServerUtils.runElasticsearchTests();
|
|
|
+ stopElasticsearch();
|
|
|
+
|
|
|
+ String systemJavaHome1 = sh.getEnv().get("ES_JAVA_HOME");
|
|
|
+ assertThat(FileUtils.slurpAllLogs(installation.logs, "elasticsearch.log", "*.log.gz"), containsString(systemJavaHome1));
|
|
|
+ }
|
|
|
+
|
|
|
public void test52BundledJdkRemoved() throws Exception {
|
|
|
assumeThat(distribution().hasJdk, is(true));
|
|
|
|
|
@@ -156,18 +207,18 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
mv(installation.bundledJdk, relocatedJdk);
|
|
|
Platforms.onLinux(() -> {
|
|
|
String systemJavaHome1 = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
- sh.getEnv().put("JAVA_HOME", systemJavaHome1);
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", systemJavaHome1);
|
|
|
});
|
|
|
Platforms.onWindows(() -> {
|
|
|
final String systemJavaHome1 = sh.run("$Env:SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
- sh.getEnv().put("JAVA_HOME", systemJavaHome1);
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", systemJavaHome1);
|
|
|
});
|
|
|
|
|
|
startElasticsearch();
|
|
|
ServerUtils.runElasticsearchTests();
|
|
|
stopElasticsearch();
|
|
|
|
|
|
- String systemJavaHome1 = sh.getEnv().get("JAVA_HOME");
|
|
|
+ String systemJavaHome1 = sh.getEnv().get("ES_JAVA_HOME");
|
|
|
assertThat(FileUtils.slurpAllLogs(installation.logs, "elasticsearch.log", "*.log.gz"), containsString(systemJavaHome1));
|
|
|
} finally {
|
|
|
mv(relocatedJdk, installation.bundledJdk);
|
|
@@ -181,7 +232,7 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
// once windows 2012 is no longer supported and powershell 5.0 is always available we can change this command
|
|
|
sh.run("cmd /c mklink /D '" + javaPath + "' $Env:SYSTEM_JAVA_HOME");
|
|
|
|
|
|
- sh.getEnv().put("JAVA_HOME", "C:\\Program Files (x86)\\java");
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", "C:\\Program Files (x86)\\java");
|
|
|
|
|
|
// verify ES can start, stop and run plugin list
|
|
|
startElasticsearch();
|
|
@@ -206,7 +257,7 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
try {
|
|
|
final String systemJavaHome = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim();
|
|
|
sh.run("ln -s \"" + systemJavaHome + "\" \"" + testJavaHome + "\"");
|
|
|
- sh.getEnv().put("JAVA_HOME", testJavaHome);
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", testJavaHome);
|
|
|
|
|
|
// verify ES can start, stop and run plugin list
|
|
|
startElasticsearch();
|
|
@@ -227,7 +278,7 @@ public class ArchiveTests extends PackagingTestCase {
|
|
|
// cleanup from previous test
|
|
|
rm(installation.config("elasticsearch.keystore"));
|
|
|
|
|
|
- sh.getEnv().put("JAVA_HOME", "");
|
|
|
+ sh.getEnv().put("ES_JAVA_HOME", "");
|
|
|
|
|
|
startElasticsearch();
|
|
|
ServerUtils.runElasticsearchTests();
|