From e37a78443b5dd481e76e07ab3be4f151eb65c107 Mon Sep 17 00:00:00 2001 From: Roman Vasilets Date: Fri, 25 Dec 2015 16:04:10 +0200 Subject: [PATCH] Add task exporter to the file system This is the first task exporter plugin. It used to export rally task results to the file in json format. Change-Id: I25117933ac0881453a001d96600d4c95e6064fff --- etc/rally.bash_completion | 3 +- tests/functional/test_cli_task.py | 53 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/etc/rally.bash_completion b/etc/rally.bash_completion index cd8bf1ac..3cc70b8f 100644 --- a/etc/rally.bash_completion +++ b/etc/rally.bash_completion @@ -36,6 +36,7 @@ _rally() OPTS["task_abort"]="--uuid --soft" OPTS["task_delete"]="--force --uuid" OPTS["task_detailed"]="--uuid --iterations-data" + OPTS["task_export"]="--uuid --connection" OPTS["task_list"]="--deployment --all-deployments --status --uuids-only" OPTS["task_report"]="--tasks --out --open --html --html-static --junit" OPTS["task_results"]="--uuid" @@ -86,4 +87,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/functional/test_cli_task.py b/tests/functional/test_cli_task.py index 7282a813..4a7aa425 100644 --- a/tests/functional/test_cli_task.py +++ b/tests/functional/test_cli_task.py @@ -740,6 +740,59 @@ class TaskTestCase(unittest.TestCase): r"(?P[0-9a-f\-]{36}): started", output) self.assertIsNotNone(result) + def test_export(self): + rally = utils.Rally() + cfg = { + "Dummy.dummy": [ + { + "runner": { + "type": "constant", + "times": 100, + "concurrency": 5 + } + } + ] + } + 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) + + def test_export_with_wrong_connection(self): + rally = utils.Rally() + cfg = { + "Dummy.dummy": [ + { + "runner": { + "type": "constant", + "times": 100, + "concurrency": 5 + } + } + ] + } + 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)) + class SLATestCase(unittest.TestCase):