-
Notifications
You must be signed in to change notification settings - Fork 313
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
Validate if car allows for using the bundled JDK #987
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5e297ae
Validate if car allows for using the bundled JDK
hub-cap 0c0a892
Merge branch 'master' into bundle_version_check
elasticmachine 76d6528
Fix docker
hub-cap 7255c99
Fix signature
hub-cap e95be18
named params
hub-cap c30eef8
Rename param
hub-cap 20eb79f
Fix lint
hub-cap d422648
Move converter
hub-cap ac3e578
Test cleanup
hub-cap 667fa79
Fix lint
hub-cap 451e2cb
Test un-cleanup ;)
hub-cap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,44 +18,44 @@ | |
import unittest.mock as mock | ||
from unittest import TestCase | ||
|
||
from esrally import config | ||
from esrally import exceptions | ||
from esrally.mechanic import java_resolver | ||
|
||
|
||
class JavaResolverTests(TestCase): | ||
@mock.patch("esrally.utils.jvm.resolve_path") | ||
def test_resolves_java_home_for_default_runtime_jdk(self, resolve_jvm_path): | ||
resolve_jvm_path.return_value = (12, "/opt/jdk12") | ||
major, java_home = java_resolver.java_home("12,11,10,9,8", | ||
specified_runtime_jdk=None, | ||
provides_bundled_jdk=True) | ||
|
||
cfg = config.Config() | ||
cfg.add(config.Scope.application, "mechanic", "runtime.jdk", None) | ||
|
||
major, java_home = java_resolver.java_home("12,11,10,9,8", cfg) | ||
|
||
self.assertEqual(major, 12) | ||
self.assertEqual(java_home, "/opt/jdk12") | ||
self.assertEqual(major, resolve_jvm_path.return_value[0]) | ||
self.assertEqual(java_home, resolve_jvm_path.return_value[1]) | ||
|
||
@mock.patch("esrally.utils.jvm.resolve_path") | ||
def test_resolves_java_home_for_specific_runtime_jdk(self, resolve_jvm_path): | ||
resolve_jvm_path.return_value = (8, "/opt/jdk8") | ||
major, java_home = java_resolver.java_home("12,11,10,9,8", | ||
specified_runtime_jdk=8, | ||
provides_bundled_jdk=True) | ||
|
||
cfg = config.Config() | ||
cfg.add(config.Scope.application, "mechanic", "runtime.jdk", 8) | ||
|
||
major, java_home = java_resolver.java_home("12,11,10,9,8", cfg) | ||
|
||
self.assertEqual(major, 8) | ||
self.assertEqual(java_home, "/opt/jdk8") | ||
self.assertEqual(major, resolve_jvm_path.return_value[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the previous implementation was more readable, even if we duplicate code. However, the scope of duplication is within the test method so this is ok IMHO. |
||
self.assertEqual(java_home, resolve_jvm_path.return_value[1]) | ||
resolve_jvm_path.assert_called_with([8]) | ||
|
||
def test_resolves_java_home_for_bundled_jdk(self): | ||
|
||
cfg = config.Config() | ||
cfg.add(config.Scope.application, "mechanic", "runtime.jdk", "bundled") | ||
|
||
major, java_home = java_resolver.java_home("12,11,10,9,8", cfg) | ||
major, java_home = java_resolver.java_home("12,11,10,9,8", | ||
specified_runtime_jdk="bundled", | ||
provides_bundled_jdk=True) | ||
|
||
# assumes most recent JDK | ||
self.assertEqual(major, 12) | ||
# does not set JAVA_HOME for the bundled JDK | ||
self.assertEqual(java_home, None) | ||
|
||
def test_disallowed_bundled_jdk(self): | ||
with self.assertRaises(exceptions.SystemSetupError) as ctx: | ||
java_resolver.java_home("12,11,10,9,8", specified_runtime_jdk="bundled") | ||
self.assertEqual("This Elasticsearch version does not contain a bundled JDK. Please specify a different runtime JDK.", | ||
ctx.exception.args[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the previous implementation was more readable, even if we duplicate code. However, the scope of duplication is within the test method so this is ok IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im fine w/ either. I just hate reusing strings in a test method in general, cuz things can get out of sync. I can revert.