Elasticsearch tests not running againts system installed java jdk

Hi, I was running the tests with:

./gradlew --continue test

My environment variables are:

JAVA_HOME=/usr/local/jdk-13.0.2+8/
JAVA13_HOME=/usr/local/jdk-13.0.2+8/

RUNTIME_JAVA_HOME is not set.

I noticed that only while executing the tests, it downloads another instance of the JDK and places it in

elasticsearch/build/jdks/adoptopenjdk-13.0.2_linux

Then it seems to run all the tests against that instance, instead of the system one.

Previously to running the tests, I built a packaged version with the system installed JDK.
I was expecting/hoping to run the tests against the same instance.

I looked through the code and found these two snippets:

In buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java

public class GlobalBuildInfoPlugin implements Plugin<Project> {
...
  public void apply(Project project) {
  ...
    File compilerJavaHome = findCompilerJavaHome();
    File runtimeJavaHome = findRuntimeJavaHome(compilerJavaHome);
    ...
    
    // Initialize global build parameters
    BuildParams.init(params -> {
        ...
        params.setIsRutimeJavaHomeSet(compilerJavaHome.equals(runtimeJavaHome) == false);

and in gradle/runtime-jdk-provision.gradle

configure(allprojects - project(':build-tools')) {
    project.tasks.withType(Test).configureEach { Test test ->
        if (BuildParams.getIsRuntimeJavaHomeSet()) {
            test.executable = "${BuildParams.runtimeJavaHome}/bin/java"
        } else {
            test.dependsOn(rootProject.jdks.provisioned_runtime)
            test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath()
        }
    }
}

It looks like if you have a different runtime java set in RUNTIME_JAVA_HOME then the tests run against the system installed instance of that version. However, in the case where you either don't have that variable set, or your JAVA_HOME is set to the same value as RUNTIME_JAVA_HOME then it downloads the 'exact' same version and tests against that one.

I'm not sure if this is a bug, or intended?

The JDK that it downloads does not run on the system I'm on, so all the tests fail out of hand when trying to do:

command 'elasticsearch/build/jdks/adoptopenjdk-13.0.2_linux/bin/java -version'

Is there a work around that I'm missing? Another way to make sure it uses the system runtime java?

Hi, can any dev chime in here, please? I was running on release 7.6.2.

Need to know if this is intended behaviour?

Thank you,
-Adrian