Skip to content

Commit

Permalink
Add an ability to override the default runtime JDK (elastic#134)
Browse files Browse the repository at this point in the history
runtime-jdk in race config will overwrite default runtime for a
particular challenge.

Relates to elastic/night-rally#123
  • Loading branch information
ebadyano committed Oct 31, 2019
1 parent 2ca3f26 commit d253ef1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
9 changes: 8 additions & 1 deletion night_rally/night_rally.py
Expand Up @@ -417,7 +417,10 @@ def __call__(self, race_config):
additional_tags["race-configs-id"] = self.race_configs_id
params["user-tag"] = self.tags(additional_tags=additional_tags)

add_if_present(params, "runtime-jdk", self.runtime_jdk)
if race_config.runtime_jdk:
params["runtime-jdk"] = race_config.runtime_jdk
else:
add_if_present(params, "runtime-jdk", self.runtime_jdk)
add_if_present(params, "car-params", race_config.car_params)
add_if_present(params, "track-params", race_config.track_params)
add_if_present(params, "elasticsearch-plugins", race_config.plugins)
Expand Down Expand Up @@ -534,6 +537,10 @@ def car_params(self):
@property
def plugins(self):
return self.configuration.get("plugins", "")

@property
def runtime_jdk(self):
return self.configuration.get("runtime-jdk")

@property
def track_params(self):
Expand Down
4 changes: 4 additions & 0 deletions night_rally/resources/race-configs-schema.json
Expand Up @@ -68,6 +68,10 @@
"type": ["array", "string"],
"description": "Car to use from rally-teams repo"
},
"runtime-jdk": {
"type": "string",
"description": "Runtime jdk to use, overwrites the default"
},
"node-count": {
"type": "integer",
"minimum": 1
Expand Down
46 changes: 46 additions & 0 deletions tests/night_rally_test.py
Expand Up @@ -375,6 +375,52 @@ def test_run_two_oss_challenges_successfully(self, mocked_wait_until_port_is_fre
system_call.calls
)

@mock.patch('night_rally.night_rally.wait_until_port_is_free', return_value=True)
def test_overwrite_runtime_jdk_successfully(self, mocked_wait_until_port_is_free):
system_call = RecordingSystemCall(return_value=False)

tracks = [
{
"track": "geonames",
"flavors": [
{
"name": "oss",
"licenses": [
{
"name": "oss",
"configurations": [
{
"name": "geonames-append-1node",
"challenge": "append-no-conflicts",
"car": "defaults",
"runtime-jdk": "13"
}
]
}
]
}
]
}
]

start_date = datetime.datetime(2016, 1, 1)
race_configs_id = os.path.basename(get_random_race_configs_id())
params = [night_rally.StandardParams("nightly", start_date, 8, "bare", race_configs_id=race_configs_id)]
cmd = night_rally.NightlyCommand(params, start_date)
night_rally.run_rally(tracks, None, ["localhost"], cmd, skip_ansible=True, system=system_call)
self.assertEqual(
[
"rally --skip-update --configuration-name=\"nightly\" --quiet --target-host=\"localhost:39200\" "
"--effective-start-date=\"2016-01-01 00:00:00\" --track-repository=\"default\" --track=\"geonames\" "
"--challenge=\"append-no-conflicts\" --car=\"defaults\" --client-options=\"timeout:240\" "
"--user-tag=\"name:geonames-append-1node,setup:bare,race-configs-id:{},license:oss\" --runtime-jdk=\"13\" "
"--pipeline=\"from-sources-complete\" "
"--revision=\"@2016-01-01T00:00:00Z\"".format(race_configs_id)
]
,
system_call.calls
)

@mock.patch('night_rally.night_rally.wait_until_port_is_free', return_value=True)
def test_run_two_mixed_license_challenges_successfully(self, mocked_wait_until_port_is_free):
system_call = RecordingSystemCall(return_value=False)
Expand Down

0 comments on commit d253ef1

Please sign in to comment.