diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-08-14 02:47:29 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-08-14 02:48:08 +0000 |
commit | b88e1a41c01a34d08ba3a0e201d0603b35ee4fba (patch) | |
tree | 89670578a7cc72f047ef136edf8ed41c2696b9df /yardstick/benchmark/core | |
parent | c2f99db8b4d8f021b29a4e3aae483ba715936a66 (diff) |
Add yardstick report for each task
JIRA: YARDSTICK-784
Currently we have yardstick report in GUI.
But if users do not use GUI, they can't see this report.
So we need generate a report each task.
After run each test case, we can see report:
http://ip:port/report/report.html
Change-Id: Ic76cf57f55aa6680b91272e210135136f0225373
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/benchmark/core')
-rw-r--r-- | yardstick/benchmark/core/task.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index dd35bd4f4..ea3239edf 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -25,6 +25,7 @@ import errno import collections from six.moves import filter +from jinja2 import Environment from yardstick.benchmark.contexts.base import Context from yardstick.benchmark.runners import base as base_runner @@ -33,6 +34,7 @@ from yardstick.common.task_template import TaskTemplate from yardstick.common.utils import source_env from yardstick.common import utils from yardstick.common import constants +from yardstick.common.html_template import report_template output_file_default = "/tmp/yardstick.out" config_file = '/etc/yardstick/yardstick.conf' @@ -146,6 +148,7 @@ class Task(object): # pragma: no cover result = self._get_format_result(testcases) self._do_output(output_config, result) + self._generate_reporting(result) total_end_time = time.time() LOG.info("total finished in %d secs", @@ -158,6 +161,13 @@ class Task(object): # pragma: no cover print("Done, exiting") return result + def _generate_reporting(self, result): + env = Environment() + with open(constants.REPORTING_FILE, 'w') as f: + f.write(env.from_string(report_template).render(result)) + + LOG.info('yardstick reporting generate in %s', constants.REPORTING_FILE) + def _set_log(self): log_format = '%(asctime)s %(name)s %(filename)s:%(lineno)d %(levelname)s %(message)s' log_formatter = logging.Formatter(log_format) |