Skip to content

Commit 97562a8

Browse files
authored
Configure TMP for test nodes on Windows (elastic#39959)
This breaks on windows where TMP dir default to C:\Windows and startup fails with a permission error. I tried to create a tmp dir and pass in `TMP` env, but it lead to a class not found error, and since testclusers is already independent of the calling environment I stopped there.
1 parent 0ada3e2 commit 97562a8

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,13 @@ class ClusterFormationTasks {
690690
env(key: 'JAVA_HOME', value: project.runtimeJavaHome)
691691
}
692692
node.args.each { arg(value: it) }
693+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
694+
// Having no TMP on Windows defaults to C:\Windows and permission errors
695+
// Since we configure ant to run with a new environment above, we need to set this to a dir we have access to
696+
File tmpDir = new File(node.baseDir, "tmp")
697+
tmpDir.mkdirs()
698+
env(key: "TMP", value: tmpDir.absolutePath)
699+
}
693700
}
694701
}
695702

distribution/src/bin/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ source "`dirname "$0"`"/elasticsearch-env
1818

1919
ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options
2020
JVM_OPTIONS=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_JVM_OPTIONS"`
21-
ES_JAVA_OPTS="${JVM_OPTIONS//\$\{ES_TMPDIR\}/$ES_TMPDIR} $ES_JAVA_OPTS"
21+
ES_JAVA_OPTS="${JVM_OPTIONS//\"\$\{ES_TMPDIR\}\"/$ES_TMPDIR} $ES_JAVA_OPTS"
2222

2323
cd "$ES_HOME"
2424
# manual parsing to find out, if process should be detached

distribution/src/config/jvm.options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
-Dlog4j.shutdownHookEnabled=false
8787
-Dlog4j2.disable.jmx=true
8888

89-
-Djava.io.tmpdir=${ES_TMPDIR}
89+
-Djava.io.tmpdir="${ES_TMPDIR}"
9090

9191
## heap dumps
9292

0 commit comments

Comments
 (0)