Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive JDK version at runtime #518

Merged
merged 3 commits into from
Jun 14, 2018
Merged

Conversation

danielmitterdorfer
Copy link
Member

With this commit we derive the appropriate JDK version at benchmark
runtime instead of requiring that it is preconfigured. This requires two
new variables in the rally-teams repo: build.jdk and runtime.jdk to
resolve the appropriate (major) JDK version depending on the
Elasticsearch version.

When we know the required JDK version, we check the environment
variables JAVAx_HOME (where x is the JDK version) and JAVA_HOME to
find the correct JAVA_HOME path. We also allow the user to override the
runtime JDK with a new command line parameter --runtime-jdk as Rally
will default to the highest available and supported JDK version on the
target system.

Closes #452

With this commit we derive the appropriate JDK version at benchmark
runtime instead of requiring that it is preconfigured. This requires two
new variables in the rally-teams repo: `build.jdk` and `runtime.jdk` to
resolve the appropriate (major) JDK version depending on the
Elasticsearch version.

When we know the required JDK version, we check the environment
variables `JAVAx_HOME` (where `x` is the JDK version) and `JAVA_HOME` to
find the correct JAVA_HOME path. We also allow the user to override the
runtime JDK with a new command line parameter `--runtime-jdk` as Rally
will default to the highest available and supported JDK version on the
target system.

Closes #452
@danielmitterdorfer danielmitterdorfer added enhancement Improves the status quo :Benchmark Candidate Management Anything affecting how Rally sets up Elasticsearch labels Jun 5, 2018
@danielmitterdorfer danielmitterdorfer added this to the 1.0.0 milestone Jun 5, 2018
Copy link
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job and there's some much unnecessary code that's been removed now!

I left some minor comments and suggestions.

@@ -4,7 +4,7 @@ Quickstart
Install
-------

Install Python 3.4+ including ``pip3``, git 1.9+ and at least JDK 8. If you want to benchmark source builds of Elasticsearch you also need JDK 10. Then run the following command, optionally prefixed by ``sudo`` if necessary::
Install Python 3.4+ including ``pip3``, git 1.9+ and an appropriate JDK to run Elasticsearch Be sure that ``JAVA_HOME`` points to that JDK. Then run the following command, optionally prefixed by ``sudo`` if necessary::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we link the JVM support matrix here? https://www.elastic.co/support/matrix#matrix_jvm

try:
return self.variables[name]
except KeyError:
raise exceptions.SystemSetupError("Car \"{}\" misses mandatory config key \"{}\"".format(self.name, name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit/English comment: "is missing". Misses here implies an emotional state i.e. wishes it would be present.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote it to: "Car ... requires config key ..."

def resolve_path(majors, sysprop_reader=system_property):
"""
Resolves the path to the JDK with the provided major version(s). It checks the provided versions in order and will return the first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order --> are in order

Copy link
Member Author

@danielmitterdorfer danielmitterdorfer Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant something different here, namely that the resolution depends on the order in the list provided by the parameter majors. So it will behave differently when you pass [7, 8, 9] instead of [9, 8, 7].

I rewrote it to:

It checks the versions in the same order specified in ``majors``  and will return the first match.

env = {}
env.update(os.environ)
env.update(car.env)
# Unix specific!:
self._set_env(env, "PATH", "%s/bin" % self.java_home, separator=":")
self._set_env(env, "PATH", "%s/bin" % java_home, separator=":")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think we are in the hot code path here, could be replaced with {}.format

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the more OS agnostic os.pathsep for the separator here (and maybe even as the default in _set_env?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch(es)! I also used os.path.join(java_home, "bin") now instead of string formatting.

"""
Resolves the path to the JDK with the provided major version(s). It checks the provided versions in order and will return the first
match. For that it checks first the environment variable ``JAVAx_HOME`` where ``x`` is the checked major version and will fall back
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring: Could be re-written as:

To achieve this, it first checks the major version x in the environment variable JAVAx_HOME and falls back to JAVA_HOME.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@danielmitterdorfer danielmitterdorfer merged commit 0c65771 into master Jun 14, 2018
dliappis added a commit to dliappis/rally that referenced this pull request Jul 23, 2018
Align Dockerfile with JAVAx_HOME environment variable requirements
introduced in: elastic#518
dliappis added a commit that referenced this pull request Jul 24, 2018
Align Dockerfile with JAVAx_HOME environment variable requirements
introduced in #518
@danielmitterdorfer danielmitterdorfer deleted the dynamic-jdk-detection branch March 5, 2019 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Benchmark Candidate Management Anything affecting how Rally sets up Elasticsearch enhancement Improves the status quo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust JDK detection / configuration
2 participants