Change the default value of scenario_output

Change the default value of the scenario_output variable of the
_run_scenario_once function of the rally/benchmark/runners/base.py
module because there was no errors key in this variable when a scenario
failed with timeout.

Closes-Bug: 1336762
Change-Id: Ieebc2064bcfee3f2bd23ee40394f8117e9096f01
This commit is contained in:
Tzanetos Balitsaris 2014-07-02 15:43:34 +03:00
parent 8e03a98837
commit 044abcbd8f
3 changed files with 11 additions and 14 deletions

View File

@ -55,11 +55,11 @@ def _run_scenario_once(args):
clients=osclients.Clients(context["user"]["endpoint"])) clients=osclients.Clients(context["user"]["endpoint"]))
error = [] error = []
scenario_output = {} scenario_output = {"errors": "", "data": {}}
try: try:
with rutils.Timer() as timer: with rutils.Timer() as timer:
scenario_output = getattr(scenario, scenario_output = getattr(scenario,
method_name)(**kwargs) or {} method_name)(**kwargs) or scenario_output
except Exception as e: except Exception as e:
error = utils.format_exc(e) error = utils.format_exc(e)
if cfg.CONF.debug: if cfg.CONF.debug:

View File

@ -235,11 +235,8 @@ class TaskCommands(object):
# NOTE(hughsaunders): ssrs=scenario specific results # NOTE(hughsaunders): ssrs=scenario specific results
ssrs = [] ssrs = []
for result in raw: for result in raw:
try: if result['scenario_output']['data']:
ssrs.append(result['scenario_output']['data']) ssrs.append(result['scenario_output']['data'])
except (KeyError, TypeError):
# No SSRs in this result
pass
if ssrs: if ssrs:
keys = set() keys = set()
for ssr in ssrs: for ssr in ssrs:

View File

@ -75,14 +75,14 @@ class ScenarioHelpersTestCase(test.TestCase):
args = (1, fakes.FakeScenario, "do_it", context, {}) args = (1, fakes.FakeScenario, "do_it", context, {})
result = base._run_scenario_once(args) result = base._run_scenario_once(args)
expected_reuslt = { expected_result = {
"duration": fakes.FakeTimer().duration(), "duration": fakes.FakeTimer().duration(),
"idle_duration": 0, "idle_duration": 0,
"error": [], "error": [],
"scenario_output": {}, "scenario_output": {"errors": "", "data": {}},
"atomic_actions": [] "atomic_actions": []
} }
self.assertEqual(expected_reuslt, result) self.assertEqual(expected_result, result)
@mock.patch("rally.benchmark.runners.base.rutils") @mock.patch("rally.benchmark.runners.base.rutils")
@mock.patch("rally.benchmark.runners.base.osclients") @mock.patch("rally.benchmark.runners.base.osclients")
@ -93,14 +93,14 @@ class ScenarioHelpersTestCase(test.TestCase):
args = (1, fakes.FakeScenario, "with_output", context, {}) args = (1, fakes.FakeScenario, "with_output", context, {})
result = base._run_scenario_once(args) result = base._run_scenario_once(args)
expected_reuslt = { expected_result = {
"duration": fakes.FakeTimer().duration(), "duration": fakes.FakeTimer().duration(),
"idle_duration": 0, "idle_duration": 0,
"error": [], "error": [],
"scenario_output": fakes.FakeScenario().with_output(), "scenario_output": fakes.FakeScenario().with_output(),
"atomic_actions": [] "atomic_actions": []
} }
self.assertEqual(expected_reuslt, result) self.assertEqual(expected_result, result)
@mock.patch("rally.benchmark.runners.base.rutils") @mock.patch("rally.benchmark.runners.base.rutils")
@mock.patch("rally.benchmark.runners.base.osclients") @mock.patch("rally.benchmark.runners.base.osclients")
@ -110,13 +110,13 @@ class ScenarioHelpersTestCase(test.TestCase):
args = (1, fakes.FakeScenario, "something_went_wrong", context, {}) args = (1, fakes.FakeScenario, "something_went_wrong", context, {})
result = base._run_scenario_once(args) result = base._run_scenario_once(args)
expected_error = result.pop("error") expected_error = result.pop("error")
expected_reuslt = { expected_result = {
"duration": fakes.FakeTimer().duration(), "duration": fakes.FakeTimer().duration(),
"idle_duration": 0, "idle_duration": 0,
"scenario_output": {}, "scenario_output": {"errors": "", "data": {}},
"atomic_actions": [] "atomic_actions": []
} }
self.assertEqual(expected_reuslt, result) self.assertEqual(expected_result, result)
self.assertEqual(expected_error[:2], self.assertEqual(expected_error[:2],
[str(Exception), "Something went wrong"]) [str(Exception), "Something went wrong"])