From 34276b464ac7a2013d292680e545d25e515bb0cd Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Fri, 25 Jan 2019 14:44:20 +0000 Subject: Use baro and yardstick metrics in dynamic HTML report _combine_metrics combines metrics from different sources. This is for use with the ``yardstick report generate-nsb`` command, which will combine yardstick and barometer metrics in the dynamic HTML report. JIRA: YARDSTICK-1593 Change-Id: I87002948ebb4cc88fb0932380bcb9920eb53db58 Signed-off-by: Emma Foley --- yardstick/benchmark/core/report.py | 30 ++- yardstick/common/nsb_report.html.j2 | 7 +- yardstick/common/nsb_report.js | 11 +- .../tests/functional/benchmark/core/test_report.py | 226 +++++++++++++++++++-- yardstick/tests/unit/benchmark/core/test_report.py | 1 - 5 files changed, 249 insertions(+), 26 deletions(-) (limited to 'yardstick') diff --git a/yardstick/benchmark/core/report.py b/yardstick/benchmark/core/report.py index 587c85a14..e5dc62050 100644 --- a/yardstick/benchmark/core/report.py +++ b/yardstick/benchmark/core/report.py @@ -342,25 +342,43 @@ class Report(object): """Start NSB report generation.""" _, report_data = self._generate_common(args) report_time = report_data.pop('Timestamp') - report_keys = sorted(report_data, key=str.lower) - report_tree = JSTree().format_for_jstree(report_keys) report_meta = { "testcase": self.yaml_name, "task_id": self.task_id, } + yardstick_data = {} + for i, t in enumerate(report_time): + for m in report_data: + if not yardstick_data.get(m): + yardstick_data[m] = {} + yardstick_data[m][t] = report_data[m][i] + + baro_data = self._get_baro_metrics() + baro_timestamps = baro_data.pop('Timestamp') + + yard_timestamps = report_time + report_time = self._combine_times(yard_timestamps, baro_timestamps) + + combo_metrics, combo_keys, combo_table = self._combine_metrics( + baro_data, baro_timestamps, yardstick_data, yard_timestamps) + combo_time = self._combine_times(baro_timestamps, yard_timestamps) + combo_tree = JSTree().format_for_jstree(combo_keys) + template_dir = consts.YARDSTICK_ROOT_PATH + "yardstick/common" template_environment = jinja2.Environment( autoescape=False, loader=jinja2.FileSystemLoader(template_dir), lstrip_blocks=True) + combo_data = combo_metrics context = { "report_meta": report_meta, - "report_data": report_data, - "report_time": report_time, - "report_keys": report_keys, - "report_tree": report_tree, + "report_data": combo_data, + "report_time": combo_time, + "report_keys": combo_keys, + "report_tree": combo_tree, + "table_data": combo_table, } template_html = template_environment.get_template("nsb_report.html.j2") diff --git a/yardstick/common/nsb_report.html.j2 b/yardstick/common/nsb_report.html.j2 index aa90253f8..a6713eb16 100644 --- a/yardstick/common/nsb_report.html.j2 +++ b/yardstick/common/nsb_report.html.j2 @@ -3,7 +3,7 @@