Fix archive tests to not create elasticsearch home (#47239)

The test for java home with special characters on linux would create a
temporary java home under /home/elasticsearch. But our packaging
assertions expect that to not exist. Unfortunately this would fail much
later when the checks were actually done in bats tests. This commit
fixes the linux test to match the behavior of windows, which links the
entire java directory, and now does it into a /tmp dir.

closes #45903
This commit is contained in:
Ryan Ernst 2019-09-30 02:05:29 -07:00 committed by Alpar Torok
parent 3648481eb2
commit 33ebf5f5dc
1 changed files with 3 additions and 9 deletions

View File

@ -202,17 +202,11 @@ public class ArchiveTests extends PackagingTestCase {
Platforms.onLinux(() -> {
final Shell sh = new Shell();
// Create temporary directory with a space and link to java binary.
// Use it as java_home
String testJavaHome = FileUtils.mkdir(Paths.get("/home", ARCHIVE_OWNER, "java home")).toAbsolutePath().toString();
// Create temporary directory with a space and link to real java home
String testJavaHome = Paths.get("/tmp", "java home").toString();
try {
final String systemJavaHome = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim();
final String java = systemJavaHome + "/bin/java";
sh.run("mkdir -p \"" + testJavaHome + "/bin\"");
sh.run("ln -s \"" + java + "\" \"" + testJavaHome + "/bin/java\"");
sh.run("chown -R " + ARCHIVE_OWNER + ":" + ARCHIVE_OWNER + " \"" + testJavaHome + "\"");
sh.run("ln -s \"" + systemJavaHome + "\" \"" + testJavaHome + "\"");
sh.getEnv().put("JAVA_HOME", testJavaHome);
//verify ES can start, stop and run plugin list