diff options
author | Emma Foley <emma.l.foley@intel.com> | 2019-01-25 14:44:20 +0000 |
---|---|---|
committer | Myron Sosyak <myronx.sosyak@intel.com> | 2019-04-03 10:38:37 +0100 |
commit | 34276b464ac7a2013d292680e545d25e515bb0cd (patch) | |
tree | f7078cb7c153b2de9fc27c054c60fb5cb124317c | |
parent | 6a0ab66ed2890c7236db8ff49cde909f24f5d92a (diff) |
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 <emma.l.foley@intel.com>
-rw-r--r-- | yardstick/benchmark/core/report.py | 30 | ||||
-rw-r--r-- | yardstick/common/nsb_report.html.j2 | 7 | ||||
-rw-r--r-- | yardstick/common/nsb_report.js | 11 | ||||
-rw-r--r-- | yardstick/tests/functional/benchmark/core/test_report.py | 226 | ||||
-rw-r--r-- | yardstick/tests/unit/benchmark/core/test_report.py | 1 |
5 files changed, 249 insertions, 26 deletions
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 @@ <!-- Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com> - Copyright (c) 2018 Intel Corporation. + Copyright (c) 2018-2019 Intel Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Apache License, Version 2.0 @@ -57,6 +57,7 @@ var report_time = {{report_time|safe}}; var report_keys = {{report_keys|safe}}; var report_tree = {{report_tree|safe}}; + var table_data = {{table_data|safe}}; // Wait for DOM to be loaded $(function() { @@ -64,10 +65,10 @@ var cnvGraph = $('#cnvGraph'); var divTree = $('#divTree'); - create_table(tblMetrics, report_data, report_time, report_keys); + create_table(tblMetrics, table_data, report_time, report_keys); var objGraph = create_graph(cnvGraph, report_time); create_tree(divTree, report_tree); - handle_tree(divTree, tblMetrics, objGraph, report_data, report_time); + handle_tree(divTree, tblMetrics, objGraph, report_data, table_data, report_time); }); </script> </body> diff --git a/yardstick/common/nsb_report.js b/yardstick/common/nsb_report.js index 4de1c8e78..18141900b 100644 --- a/yardstick/common/nsb_report.js +++ b/yardstick/common/nsb_report.js @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com> - * Copyright (c) 2018 Intel Corporation. + * Copyright (c) 2018-2019 Intel Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 @@ -72,11 +72,16 @@ function create_graph(cnvGraph, timestamps) borderWidth: 2, fill: false, tension: 0, + showline: true, + spanGaps: true, }, }, scales: { xAxes: [{ type: 'category', + display: true, + labels: timestamps, + autoSkip: true, }], yAxes: [{ type: 'linear', @@ -144,7 +149,7 @@ function update_graph(objGraph, datasets) objGraph.update(); } -function handle_tree(divTree, tblMetrics, objGraph, table_data, timestamps) +function handle_tree(divTree, tblMetrics, objGraph, graph_data, table_data, timestamps) { divTree.on('check_node.jstree uncheck_node.jstree', function(e, data) { var selected_keys = []; @@ -155,7 +160,7 @@ function handle_tree(divTree, tblMetrics, objGraph, table_data, timestamps) selected_keys.push(node.id); selected_datasets.push({ label: node.id, - data: table_data[node.id], + data: graph_data[node.id], }); } }); diff --git a/yardstick/tests/functional/benchmark/core/test_report.py b/yardstick/tests/functional/benchmark/core/test_report.py index 5f060dd1e..832d3b3e1 100644 --- a/yardstick/tests/functional/benchmark/core/test_report.py +++ b/yardstick/tests/functional/benchmark/core/test_report.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2018 Intel Corporation. +# Copyright (c) 2018-2019 Intel Corporation. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -41,6 +41,33 @@ GOOD_DB_METRICS = [ {u'time': u'2018-08-20T16:49:30.379359421Z', u'metric1': 8, u'metric2': 5, u'metric3': 1, u'metric4': 0}, ] +GOOD_DB_BARO_METRICS = [ + {u'value': 324050, u'instance': u'0', u'host': u'myhostname', + u'time': u'2018-08-20T16:49:27.383698038Z', + u'type_instance': u'user', u'type': u'cpu'}, + { + u'value': 193798, u'instance': u'0', u'host': u'myhostname', + u'time': u'2018-12-19T16:49:27.383712594Z', + u'type_instance': u'system', u'type': u'cpu'}, + { + u'value': 324051, u'instance': u'0', u'host': u'myhostname', + u'time': u'2018-08-20T16:49:28.383696624Z', + u'type_instance': u'user', u'type': u'cpu'}, + { + u'value': 193800, u'instance': u'0', u'host': u'myhostname', + u'time': u'2018-08-20T16:49:28.383713481Z', + u'type_instance': u'system', u'type': u'cpu'}, + { + u'value': 324054, u'instance': u'0', u'host': u'myhostname', + u'time': u'2018-08-20T16:49:29.3836966789Z', + u'type_instance': u'user', u'type': u'cpu'}, + { + u'value': 193801, u'instance': u'0', u'host': u'myhostname', + u'time': u'2018-08-20T16:49:29.383716296Z', + u'type_instance': u'system', u'type': u'cpu'} +] +TIMESTAMP_START = '2018-08-20T16:49:26.372662016Z' +TIMESTAMP_END = '2018-08-20T16:49:30.379359421Z' yardstick_config = """ [DEFAULT] @@ -48,11 +75,19 @@ dispatcher = influxdb """ -def my_query(query_sql): +def my_query(query_sql, db=None): get_fieldkeys_cmd = 'show field keys' get_metrics_cmd = 'select * from' - - if get_fieldkeys_cmd in query_sql: + get_start_time_cmd = 'ORDER ASC limit 1' + get_end_time_cmd = 'ORDER DESC limit 1' + if db: + if get_start_time_cmd in query_sql: + return TIMESTAMP_START + elif get_end_time_cmd in query_sql: + return TIMESTAMP_END + else: + return GOOD_DB_BARO_METRICS + elif get_fieldkeys_cmd in query_sql: return GOOD_DB_FIELDKEYS elif get_metrics_cmd in query_sql: return GOOD_DB_METRICS @@ -87,25 +122,190 @@ class ReportTestCase(unittest.TestCase): keys_act = ast.literal_eval(l.strip()[18:-1]) elif "var report_tree = [" in l: tree_act = ast.literal_eval(l.strip()[18:-1]) - data_exp = { - 'metric1': [1, 1, 2, 3, 5, 8], - 'metric2': [0, 1, 2, 3, 4, 5], - 'metric3': [8, 5, 3, 2, 1, 1], - 'metric4': [5, 4, 3, 2, 1, 0], + 'metric1': [ + {'x': '16:49:26.372662', 'y': 1}, + {'x': '16:49:27.374208', 'y': 1}, + {'x': '16:49:28.375742', 'y': 2}, + {'x': '16:49:29.377299', 'y': 3}, + {'x': '16:49:30.378252', 'y': 5}, + {'x': '16:49:30.379359', 'y': 8}], + 'metric2': [ + {'x': '16:49:26.372662', 'y': 0}, + {'x': '16:49:27.374208', 'y': 1}, + {'x': '16:49:28.375742', 'y': 2}, + {'x': '16:49:29.377299', 'y': 3}, + {'x': '16:49:30.378252', 'y': 4}, + {'x': '16:49:30.379359', 'y': 5}], + 'metric3': [ + {'x': '16:49:26.372662', 'y': 8}, + {'x': '16:49:27.374208', 'y': 5}, + {'x': '16:49:28.375742', 'y': 3}, + {'x': '16:49:29.377299', 'y': 2}, + {'x': '16:49:30.378252', 'y': 1}, + {'x': '16:49:30.379359', 'y': 1}], + 'metric4': [ + {'x': '16:49:26.372662', 'y': 5}, + {'x': '16:49:27.374208', 'y': 4}, + {'x': '16:49:28.375742', 'y': 3}, + {'x': '16:49:29.377299', 'y': 2}, + {'x': '16:49:30.378252', 'y': 1}, + {'x': '16:49:30.379359', 'y': 0}], + 'myhostname.cpu_value.cpu.system.0': [ + {'x': '16:49:27.3837', 'y': 193798}, + {'x': '16:49:28.3837', 'y': 193800}, + {'x': '16:49:29.3837', 'y': 193801}], + 'myhostname.cpu_value.cpu.user.0': [ + {'x': '16:49:27.3836', 'y': 324050}, + {'x': '16:49:28.3836', 'y': 324051}, + {'x': '16:49:29.3836', 'y': 324054}], + 'myhostname.cpufreq_value.cpu.system.0': [ + {'x': '16:49:27.3837', 'y': 193798}, + {'x': '16:49:28.3837', 'y': 193800}, + {'x': '16:49:29.3837', 'y': 193801}], + 'myhostname.cpufreq_value.cpu.user.0': [ + {'x': '16:49:27.3836', 'y': 324050}, + {'x': '16:49:28.3836', 'y': 324051}, + {'x': '16:49:29.3836', 'y': 324054}], + 'myhostname.intel_pmu_value.cpu.system.0': [ + {'x': '16:49:27.3837', 'y': 193798}, + {'x': '16:49:28.3837', 'y': 193800}, + {'x': '16:49:29.3837', 'y': 193801}], + 'myhostname.intel_pmu_value.cpu.user.0': [ + {'x': '16:49:27.3836', 'y': 324050}, + {'x': '16:49:28.3836', 'y': 324051}, + {'x': '16:49:29.3836', 'y': 324054}], + 'myhostname.virt_value.cpu.system.0': [ + {'x': '16:49:27.3837', 'y': 193798}, + {'x': '16:49:28.3837', 'y': 193800}, + {'x': '16:49:29.3837', 'y': 193801}], + 'myhostname.virt_value.cpu.user.0': [ + {'x': '16:49:27.3836', 'y': 324050}, + {'x': '16:49:28.3836', 'y': 324051}, + {'x': '16:49:29.3836', 'y': 324054}], + 'myhostname.memory_value.cpu.system.0': [ + {'x': '16:49:27.3837', 'y': 193798}, + {'x': '16:49:28.3837', 'y': 193800}, + {'x': '16:49:29.3837', 'y': 193801}], + 'myhostname.memory_value.cpu.user.0': [ + {'x': '16:49:27.3836', 'y': 324050}, + {'x': '16:49:28.3836', 'y': 324051}, + {'x': '16:49:29.3836', 'y': 324054}] } time_exp = [ - '16:49:26.372662', '16:49:27.374208', '16:49:28.375742', - '16:49:29.377299', '16:49:30.378252', '16:49:30.379359', + '16:49:26.372662', '16:49:27.374208', '16:49:27.3836', + '16:49:27.3837', '16:49:28.375742', '16:49:28.3836', + '16:49:28.3837', '16:49:29.377299', '16:49:29.3836', + '16:49:29.3837', '16:49:30.378252', '16:49:30.379359', ] - keys_exp = [ + keys_exp = sorted([ 'metric1', 'metric2', 'metric3', 'metric4', - ] + 'myhostname.cpu_value.cpu.system.0', + 'myhostname.cpu_value.cpu.user.0', + 'myhostname.cpufreq_value.cpu.system.0', + 'myhostname.cpufreq_value.cpu.user.0', + 'myhostname.intel_pmu_value.cpu.system.0', + 'myhostname.intel_pmu_value.cpu.user.0', + 'myhostname.virt_value.cpu.system.0', + 'myhostname.virt_value.cpu.user.0', + 'myhostname.memory_value.cpu.system.0', + 'myhostname.memory_value.cpu.user.0', + ]) tree_exp = [ {'parent': '#', 'text': 'metric1', 'id': 'metric1'}, {'parent': '#', 'text': 'metric2', 'id': 'metric2'}, {'parent': '#', 'text': 'metric3', 'id': 'metric3'}, {'parent': '#', 'text': 'metric4', 'id': 'metric4'}, + {'id': 'myhostname', 'parent': '#', 'text': 'myhostname'}, + {'id': 'myhostname.cpu_value', + 'parent': 'myhostname', + 'text': 'cpu_value'}, + {'id': 'myhostname.cpu_value.cpu', + 'parent': 'myhostname.cpu_value', + 'text': 'cpu'}, + {'id': 'myhostname.cpu_value.cpu.system', + 'parent': 'myhostname.cpu_value.cpu', + 'text': 'system'}, + {'id': 'myhostname.cpu_value.cpu.system.0', + 'parent': 'myhostname.cpu_value.cpu.system', + 'text': '0'}, + {'id': 'myhostname.cpu_value.cpu.user', + 'parent': 'myhostname.cpu_value.cpu', + 'text': 'user'}, + {'id': 'myhostname.cpu_value.cpu.user.0', + 'parent': 'myhostname.cpu_value.cpu.user', + 'text': '0'}, + {'id': 'myhostname.cpufreq_value', + 'parent': 'myhostname', + 'text': 'cpufreq_value'}, + {'id': 'myhostname.cpufreq_value.cpu', + 'parent': 'myhostname.cpufreq_value', + 'text': 'cpu'}, + {'id': 'myhostname.cpufreq_value.cpu.system', + 'parent': 'myhostname.cpufreq_value.cpu', + 'text': 'system'}, + {'id': 'myhostname.cpufreq_value.cpu.system.0', + 'parent': 'myhostname.cpufreq_value.cpu.system', + 'text': '0'}, + {'id': 'myhostname.cpufreq_value.cpu.user', + 'parent': 'myhostname.cpufreq_value.cpu', + 'text': 'user'}, + {'id': 'myhostname.cpufreq_value.cpu.user.0', + 'parent': 'myhostname.cpufreq_value.cpu.user', + 'text': '0'}, + {'id': 'myhostname.intel_pmu_value', + 'parent': 'myhostname', + 'text': 'intel_pmu_value'}, + {'id': 'myhostname.intel_pmu_value.cpu', + 'parent': 'myhostname.intel_pmu_value', + 'text': 'cpu'}, + {'id': 'myhostname.intel_pmu_value.cpu.system', + 'parent': 'myhostname.intel_pmu_value.cpu', + 'text': 'system'}, + {'id': 'myhostname.intel_pmu_value.cpu.system.0', + 'parent': 'myhostname.intel_pmu_value.cpu.system', + 'text': '0'}, + {'id': 'myhostname.intel_pmu_value.cpu.user', + 'parent': 'myhostname.intel_pmu_value.cpu', + 'text': 'user'}, + {'id': 'myhostname.intel_pmu_value.cpu.user.0', + 'parent': 'myhostname.intel_pmu_value.cpu.user', + 'text': '0'}, + {'id': 'myhostname.memory_value', + 'parent': 'myhostname', + 'text': 'memory_value'}, + {'id': 'myhostname.memory_value.cpu', + 'parent': 'myhostname.memory_value', + 'text': 'cpu'}, + {'id': 'myhostname.memory_value.cpu.system', + 'parent': 'myhostname.memory_value.cpu', + 'text': 'system'}, + {'id': 'myhostname.memory_value.cpu.system.0', + 'parent': 'myhostname.memory_value.cpu.system', + 'text': '0'}, + {'id': 'myhostname.memory_value.cpu.user', + 'parent': 'myhostname.memory_value.cpu', + 'text': 'user'}, + {'id': 'myhostname.memory_value.cpu.user.0', + 'parent': 'myhostname.memory_value.cpu.user', + 'text': '0'}, + {'id': 'myhostname.virt_value', 'parent': 'myhostname', + 'text': 'virt_value'}, + {'id': 'myhostname.virt_value.cpu', + 'parent': 'myhostname.virt_value', + 'text': 'cpu'}, + {'id': 'myhostname.virt_value.cpu.system', + 'parent': 'myhostname.virt_value.cpu', + 'text': 'system'}, + {'id': 'myhostname.virt_value.cpu.system.0', + 'parent': 'myhostname.virt_value.cpu.system', + 'text': '0'}, + {'id': 'myhostname.virt_value.cpu.user', + 'parent': 'myhostname.virt_value.cpu', + 'text': 'user'}, + {'id': 'myhostname.virt_value.cpu.user.0', + 'parent': 'myhostname.virt_value.cpu.user', + 'text': '0'} ] self.assertEqual(data_exp, data_act) diff --git a/yardstick/tests/unit/benchmark/core/test_report.py b/yardstick/tests/unit/benchmark/core/test_report.py index f3b17f30a..89fb1e90a 100644 --- a/yardstick/tests/unit/benchmark/core/test_report.py +++ b/yardstick/tests/unit/benchmark/core/test_report.py @@ -322,7 +322,6 @@ class ReportTestCase(unittest.TestCase): '14:11:45.3836': 3600281000, } } - self.maxDiff = None self.assertEqual( BARO_EXPECTED_METRICS, self.rep._get_baro_metrics() |