From ce498c14a3a338eaaee7d8ff1bc56acab64f5d7e Mon Sep 17 00:00:00 2001 From: Mikhail Dubov Date: Thu, 12 Feb 2015 02:55:00 +0300 Subject: [PATCH] Fix rally task detailed --iterations-data In case an input scenario had no atomic actions, the "--iterations-data" table contained "n/a" values. Here we fix this and enhance the corresponding functional tests. Change-Id: Ic4d3809f64bcfcbce804023de7ce0c2d1f6e965f Closes-Bug: 1420703 --- rally/cmd/commands/task.py | 9 ++------- tests/functional/test_cli_task.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/rally/cmd/commands/task.py b/rally/cmd/commands/task.py index 6438ad8189..55d05331d9 100644 --- a/rally/cmd/commands/task.py +++ b/rally/cmd/commands/task.py @@ -273,16 +273,11 @@ class TaskCommands(object): for col in float_cols])) for (c, r) in enumerate(raw_data, 1): dlist = [c] + dlist.append(r["duration"]) if r["atomic_actions"]: - dlist.append(r["duration"]) for action in atomic_actions: dlist.append(r["atomic_actions"].get(action) or 0) - table_rows.append(rutils.Struct(**dict(zip(headers, - dlist)))) - else: - data = dlist + [None for i in range(1, len(headers))] - table_rows.append(rutils.Struct(**dict(zip(headers, - data)))) + table_rows.append(rutils.Struct(**dict(zip(headers, dlist)))) common_cliutils.print_list(table_rows, fields=headers, formatters=formatters) diff --git a/tests/functional/test_cli_task.py b/tests/functional/test_cli_task.py index 81db910d81..8bec5a0ae4 100644 --- a/tests/functional/test_cli_task.py +++ b/tests/functional/test_cli_task.py @@ -63,6 +63,27 @@ class TaskTestCase(unittest.TestCase): self.assertIn("dummy_fail_test (2)", detailed) detailed_iterations_data = rally("task detailed --iterations-data") self.assertIn("2. dummy_fail_test (2)", detailed_iterations_data) + self.assertNotIn("n/a", detailed_iterations_data) + + def test_detailed_no_atomic_actions(self): + rally = utils.Rally() + cfg = { + "Dummy.dummy": [ + { + "runner": { + "type": "constant", + "times": 100, + "concurrency": 5 + } + } + ] + } + config = utils.TaskConfig(cfg) + rally("task start --task %s" % config.filename) + detailed = rally("task detailed") + self.assertIn("Dummy.dummy", detailed) + detailed_iterations_data = rally("task detailed --iterations-data") + self.assertNotIn("n/a", detailed_iterations_data) def test_results(self): rally = utils.Rally()