From 300e35478739e35aaa54eb1113567fbec31db847 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 4 Sep 2019 15:29:44 +0300 Subject: [PATCH] Fix the JVM we use for bwc nodes Before this change we would run bwc nodes with their bundled jdk if these supported it, so the passed in runtime JDK was not honored. This became obvius when running with FIPS. Closes #41721 --- .../gradle/test/ClusterFormationTasks.groovy | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index c563cd2236dd1..bfba30619b37f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -659,8 +659,7 @@ class ClusterFormationTasks { static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) { return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec -> exec.workingDir node.cwd - if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes - || node.config.distribution == 'integ-test-zip') { + if (useRuntimeJava(project, node)) { exec.environment.put('JAVA_HOME', project.runtimeJavaHome) } else { // force JAVA_HOME to *not* be set @@ -678,6 +677,12 @@ class ClusterFormationTasks { } } + public static boolean useRuntimeJava(Project project, NodeInfo node) { + return (project.isRuntimeJavaHomeSet || + (node.isBwcNode == false && node.nodeVersion.before(Version.fromString("7.0.0"))) || + node.config.distribution == 'integ-test-zip') + } + /** Adds a task to start an elasticsearch node with the given configuration */ static Task configureStartTask(String name, Project project, Task setup, NodeInfo node) { // this closure is converted into ant nodes by groovy's AntBuilder @@ -685,8 +690,7 @@ class ClusterFormationTasks { ant.exec(executable: node.executable, spawn: node.config.daemonize, newenvironment: true, dir: node.cwd, taskname: 'elasticsearch') { node.env.each { key, value -> env(key: key, value: value) } - if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes - || node.config.distribution == 'integ-test-zip') { + if (useRuntimeJava(project, node)) { env(key: 'JAVA_HOME', value: project.runtimeJavaHome) } node.args.each { arg(value: it) }