From 8adfcb3ce37963cf07fc0e1c616080ebdf4ee4c6 Mon Sep 17 00:00:00 2001 From: chenhb Date: Thu, 27 Apr 2017 11:17:09 +0800 Subject: [PATCH] Refactor the related command of task report and export 1.Use report plugins instead of separated reports, however, we still save old report command. 2.New report command rally task report --html --uuid --out we can use --html and --html-static, and deprecate --junit, we have move junit to `rally task export` command. Example: rally task report --html --uuid xxxxxx --out /home/report.html 3.Change `rally task export` format, and deprecate old Exporter plugin. rally task export --uuid --type --to Example: rally task export --uuid xxxx --type junit-xml --to xxxxx 4.Remove FileExporter plugin. Change-Id: I44cafccb8d6c6c3cc704fb6e3ff2f49a756209ef --- etc/rally.bash_completion | 6 +- tests/ci/rally_gate_functions.sh | 4 +- tests/functional/test_cli_task.py | 120 +++++++++++++++++------------- 3 files changed, 73 insertions(+), 57 deletions(-) diff --git a/etc/rally.bash_completion b/etc/rally.bash_completion index 76a0e502..fb62dd69 100644 --- a/etc/rally.bash_completion +++ b/etc/rally.bash_completion @@ -31,10 +31,10 @@ _rally() OPTS["task_abort"]="--uuid --soft" OPTS["task_delete"]="--force --uuid" OPTS["task_detailed"]="--uuid --iterations-data" - OPTS["task_export"]="--uuid --connection" + OPTS["task_export"]="--uuid --type --to" OPTS["task_import"]="--file --deployment --tag" OPTS["task_list"]="--deployment --all-deployments --status --uuids-only" - OPTS["task_report"]="--tasks --out --open --html --html-static --junit" + OPTS["task_report"]="--out --open --html --html-static --uuid" OPTS["task_results"]="--uuid" OPTS["task_sla-check"]="--uuid --json" OPTS["task_sla_check"]="--uuid --json" @@ -91,4 +91,4 @@ _rally() return 0 } -complete -o filenames -F _rally rally \ No newline at end of file +complete -o filenames -F _rally rally diff --git a/tests/ci/rally_gate_functions.sh b/tests/ci/rally_gate_functions.sh index e2dc6c98..6a050e49 100644 --- a/tests/ci/rally_gate_functions.sh +++ b/tests/ci/rally_gate_functions.sh @@ -135,8 +135,10 @@ function run () { gzip -9 rally-plot/detailed.txt rally task detailed --iterations-data > rally-plot/detailed_with_iterations.txt gzip -9 rally-plot/detailed_with_iterations.txt - rally task report --out rally-plot/results.html + rally task report --html --out rally-plot/results.html gzip -9 rally-plot/results.html + rally task export --type junit-xml --to rally-plot/junit.xml + gzip -9 rally-plot/junit.xml # NOTE(stpierre): if the sla check fails, we still want osresources.py # to run, so we turn off -e and save the return value diff --git a/tests/functional/test_cli_task.py b/tests/functional/test_cli_task.py index 5d261637..736e2b0c 100644 --- a/tests/functional/test_cli_task.py +++ b/tests/functional/test_cli_task.py @@ -204,6 +204,8 @@ class TaskTestCase(unittest.TestCase): rally = utils.Rally() self.assertRaises(utils.RallyCliError, rally, "task report --tasks %s" % FAKE_TASK_UUID) + self.assertRaises(utils.RallyCliError, + rally, "task report --uuid %s" % FAKE_TASK_UUID) def test_sla_check_with_wrong_task_id(self): rally = utils.Rally() @@ -233,16 +235,22 @@ class TaskTestCase(unittest.TestCase): cfg = self._get_sample_task_config() config = utils.TaskConfig(cfg) rally("task start --task %s" % config.filename) - rally("task report --out %s" % rally.gen_report_path(extension="html")) html_report = rally.gen_report_path(extension="html") + rally("task report --out %s" % html_report) self.assertTrue(os.path.exists(html_report)) self._assert_html_report_libs_are_embedded(html_report, False) self.assertRaises(utils.RallyCliError, rally, "task report --report %s" % FAKE_TASK_UUID) - rally("task report --junit --out %s" % - rally.gen_report_path(extension="junit")) - self.assertTrue(os.path.exists( - rally.gen_report_path(extension="junit"))) + + def test_new_report_one_uuid(self): + rally = utils.Rally() + cfg = self._get_sample_task_config() + config = utils.TaskConfig(cfg) + rally("task start --task %s" % config.filename) + html_report = rally.gen_report_path(extension="html") + rally("task report --out %s" % html_report) + self.assertTrue(os.path.exists(html_report)) + self._assert_html_report_libs_are_embedded(html_report, False) self.assertRaises(utils.RallyCliError, rally, "task report --report %s" % FAKE_TASK_UUID) @@ -262,6 +270,21 @@ class TaskTestCase(unittest.TestCase): self.assertTrue(os.path.exists(html_report)) self._assert_html_report_libs_are_embedded(html_report, False) + def test_new_report_bunch_uuids(self): + rally = utils.Rally() + cfg = self._get_sample_task_config() + config = utils.TaskConfig(cfg) + task_uuids = [] + for i in range(3): + res = rally("task start --task %s" % config.filename) + for line in res.splitlines(): + if "finished" in line: + task_uuids.append(line.split(" ")[1][:-1]) + html_report = rally.gen_report_path(extension="html") + rally("task report --uuid %s --out %s" % (" ".join(task_uuids), + html_report)) + self.assertTrue(os.path.exists(html_report)) + def test_report_bunch_files(self): rally = utils.Rally() cfg = self._get_sample_task_config() @@ -289,7 +312,8 @@ class TaskTestCase(unittest.TestCase): task_result_file = "/tmp/report_42.json" if os.path.exists(task_result_file): os.remove(task_result_file) - rally("task results", report_path=task_result_file, raw=True) + rally("task results", report_path=task_result_file, + raw=True) task_run_output = rally( "task start --task %s" % config.filename).splitlines() @@ -319,6 +343,16 @@ class TaskTestCase(unittest.TestCase): self.assertTrue(os.path.exists(html_report)) self._assert_html_report_libs_are_embedded(html_report) + def test_new_report_one_uuid_with_static_libs(self): + rally = utils.Rally() + cfg = self._get_sample_task_config() + config = utils.TaskConfig(cfg) + rally("task start --task %s" % config.filename) + html_report = rally.gen_report_path(extension="html") + rally("task report --out %s --html-static" % html_report) + self.assertTrue(os.path.exists(html_report)) + self._assert_html_report_libs_are_embedded(html_report) + def test_trends(self): cfg1 = { "Dummy.dummy": [ @@ -865,58 +899,38 @@ class TaskTestCase(unittest.TestCase): r"(?P[0-9a-f\-]{36}): started", output) self.assertIsNotNone(result) - def test_export(self): + def test_export_one_uuid(self): rally = utils.Rally() - cfg = { - "Dummy.dummy": [ - { - "runner": { - "type": "constant", - "times": 100, - "concurrency": 5 - } - } - ] - } + cfg = self._get_sample_task_config() config = utils.TaskConfig(cfg) - output = rally("task start --task %s" % config.filename) - uuid = re.search( - r"(?P[0-9a-f\-]{36}): started", output).group("uuid") - connection = ( - "file-exporter:///" + rally.gen_report_path(extension="json")) - output = rally("task export --uuid %s --connection %s" % ( - uuid, connection)) - expected = ( - "Task %(uuid)s results was successfully exported to %(" - "connection)s using file-exporter plugin." % { - "uuid": uuid, - "connection": connection, - }) - self.assertIn(expected, output) + rally("task start --task %s" % config.filename) + html_report = rally.gen_report_path(extension="html") + rally("task export --type html --to %s" % html_report) + self.assertTrue(os.path.exists(html_report)) + self._assert_html_report_libs_are_embedded(html_report, False) - def test_export_with_wrong_connection(self): + rally("task export --type html-static --to %s" % html_report) + self.assertTrue(os.path.exists(html_report)) + self._assert_html_report_libs_are_embedded(html_report) + + junit_report = rally.gen_report_path(extension="junit") + rally("task export --type junit-xml --to %s" % junit_report) + self.assertTrue(os.path.exists(junit_report)) + + def test_export_bunch_uuids(self): rally = utils.Rally() - cfg = { - "Dummy.dummy": [ - { - "runner": { - "type": "constant", - "times": 100, - "concurrency": 5 - } - } - ] - } + cfg = self._get_sample_task_config() config = utils.TaskConfig(cfg) - output = rally("task start --task %s" % config.filename) - uuid = re.search( - r"(?P[0-9a-f\-]{36}): started", output).group("uuid") - connection = ( - "fake:///" + rally.gen_report_path(extension="json")) - self.assertRaises(utils.RallyCliError, - rally, - "task export --uuid %s --connection %s" % ( - uuid, connection)) + task_uuids = [] + for i in range(3): + res = rally("task start --task %s" % config.filename) + for line in res.splitlines(): + if "finished" in line: + task_uuids.append(line.split(" ")[1][:-1]) + html_report = rally.gen_report_path(extension="html") + rally("task export --uuid %s --type html --to %s" % ( + " ".join(task_uuids), html_report)) + self.assertTrue(os.path.exists(html_report)) class SLATestCase(unittest.TestCase):