Skip to content

Commit c19c7d0

Browse files
authored
Enable --exclude-tasks option (elastic#160)
Closes elastic/night-rally#159
1 parent ae2204a commit c19c7d0

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

night_rally/night_rally.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,14 @@ class StandardParams:
389389
"""
390390
Extracts all parameters that are needed for all Rally invocations.
391391
"""
392-
def __init__(self, configuration_name, effective_start_date, runtime_jdk, user_tag_setup, race_configs_id=None, test_mode=False):
392+
def __init__(self, configuration_name, effective_start_date, runtime_jdk, user_tag_setup, race_configs_id=None, test_mode=False, exclude_tasks=None):
393393
self.configuration_name = configuration_name
394394
self.effective_start_date = effective_start_date
395395
self.runtime_jdk = runtime_jdk
396396
self.user_tag_setup = user_tag_setup
397397
self.race_configs_id = race_configs_id
398398
self.test_mode = test_mode
399+
self.exclude_tasks = exclude_tasks
399400

400401
def __call__(self, race_config):
401402
params = {
@@ -421,6 +422,7 @@ def __call__(self, race_config):
421422
params["runtime-jdk"] = race_config.runtime_jdk
422423
else:
423424
add_if_present(params, "runtime-jdk", self.runtime_jdk)
425+
add_if_present(params, "exclude-tasks", race_config.exclude_tasks)
424426
add_if_present(params, "car-params", race_config.car_params)
425427
add_if_present(params, "track-params", race_config.track_params)
426428
add_if_present(params, "elasticsearch-plugins", race_config.plugins)
@@ -533,6 +535,10 @@ def car(self):
533535
@property
534536
def car_params(self):
535537
return self.configuration.get("car-params")
538+
539+
@property
540+
def exclude_tasks(self):
541+
return self.configuration.get("exclude-tasks")
536542

537543
@property
538544
def plugins(self):

tests/night_rally_test.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,52 @@ def test_run_two_oss_challenges_successfully(self, mocked_wait_until_port_is_fre
374374
,
375375
system_call.calls
376376
)
377+
378+
@mock.patch('night_rally.night_rally.wait_until_port_is_free', return_value=True)
379+
def test_exclude_tasks_option(self, mocked_wait_until_port_is_free):
380+
system_call = RecordingSystemCall(return_value=False)
381+
382+
tracks = [
383+
{
384+
"track": "geonames",
385+
"flavors": [
386+
{
387+
"name": "oss",
388+
"licenses": [
389+
{
390+
"name": "oss",
391+
"configurations": [
392+
{
393+
"name": "geonames-append-1node",
394+
"challenge": "append-no-conflicts",
395+
"car": "defaults",
396+
"exclude-tasks": "delete,type:search"
397+
}
398+
]
399+
}
400+
]
401+
}
402+
]
403+
}
404+
]
405+
406+
start_date = datetime.datetime(2016, 1, 1)
407+
race_configs_id = os.path.basename(get_random_race_configs_id())
408+
params = [night_rally.StandardParams("nightly", start_date, 8, "bare", race_configs_id=race_configs_id)]
409+
cmd = night_rally.NightlyCommand(params, start_date)
410+
night_rally.run_rally(tracks, None, ["localhost"], cmd, skip_ansible=True, system=system_call)
411+
self.assertEqual(
412+
[
413+
"rally --skip-update --configuration-name=\"nightly\" --quiet --target-host=\"localhost:39200\" "
414+
"--effective-start-date=\"2016-01-01 00:00:00\" --track-repository=\"default\" --track=\"geonames\" "
415+
"--challenge=\"append-no-conflicts\" --car=\"defaults\" --client-options=\"timeout:240\" "
416+
"--user-tag=\"name:geonames-append-1node,setup:bare,race-configs-id:{},license:oss\" --runtime-jdk=\"8\" "
417+
"--exclude-tasks=\"delete,type:search\" --pipeline=\"from-sources-complete\" "
418+
"--revision=\"@2016-01-01T00:00:00Z\"".format(race_configs_id)
419+
]
420+
,
421+
system_call.calls
422+
)
377423

378424
@mock.patch('night_rally.night_rally.wait_until_port_is_free', return_value=True)
379425
def test_overwrite_runtime_jdk_successfully(self, mocked_wait_until_port_is_free):

0 commit comments

Comments
 (0)