# Elasticsearch tests not running againts system installed java jdk

**URL:** <https://discuss.elastic.co/t/elasticsearch-tests-not-running-againts-system-installed-java-jdk/231571>\
**Category:** Elasticsearch\
**Created:** [May 7, 2020, 3:06pm UTC](https://discuss.elastic.co/t/elasticsearch-tests-not-running-againts-system-installed-java-jdk/231571 "2020-05-07T15:06:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adpopescu-ibm](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@adpopescu-ibm](https://discuss.elastic.co/u/adpopescu-ibm)\
**Post date:** [May 7, 2020, 3:06pm UTC](https://discuss.elastic.co/t/elasticsearch-tests-not-running-againts-system-installed-java-jdk/231571/1 "2020-05-07T15:06:00Z")

</div>

Hi, I was running the tests with:

```auto
./gradlew --continue test

```

My environment variables are:

```auto
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

```auto
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`

```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`

```java
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![adpopescu-ibm](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@adpopescu-ibm](https://discuss.elastic.co/u/adpopescu-ibm)\
**Post date:** [May 25, 2020, 3:40pm UTC](https://discuss.elastic.co/t/elasticsearch-tests-not-running-againts-system-installed-java-jdk/231571/2 "2020-05-25T15:40:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 22, 2020, 3:40pm UTC](https://discuss.elastic.co/t/elasticsearch-tests-not-running-againts-system-installed-java-jdk/231571/3 "2020-06-22T15:40:32Z")

</div>

Closed on June 22, 2020, 3:40pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
