From 835411e9d454b9672081cb1ff3241c036f204b95 Mon Sep 17 00:00:00 2001 From: Patrice Buriez Date: Fri, 9 Nov 2018 10:45:31 +0100 Subject: Add parser to support jsTree in report Allow the user to select what data to show in the report using jsTree to navigate a hierarchical metrics list. JIRA: YARDSTICK-1367 Topic: report/html_table (4 of 11) Change-Id: I86d782a0a70b80a1cdfaab2f41afb7668066cbf7 Signed-off-by: Emma Foley Signed-off-by: Patrice Buriez --- yardstick/tests/unit/benchmark/core/test_report.py | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'yardstick/tests/unit') diff --git a/yardstick/tests/unit/benchmark/core/test_report.py b/yardstick/tests/unit/benchmark/core/test_report.py index 2827f8e26..3e80dcc45 100644 --- a/yardstick/tests/unit/benchmark/core/test_report.py +++ b/yardstick/tests/unit/benchmark/core/test_report.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2017 Rajesh Kudaka. +# Copyright (c) 2018 Intel Corporation. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -27,6 +28,75 @@ BAD_YAML_NAME = 'F@KE_NAME' BAD_TASK_ID = 'aaaaaa-aaaaaaaa-aaaaaaaaaa-aaaaaa' +class JSTreeTestCase(unittest.TestCase): + + def setUp(self): + self.jstree = report.JSTree() + + def test__create_node(self): + _id = "tg__0.DropPackets" + + expected_data = [ + {"id": "tg__0", "text": "tg__0", "parent": "#"}, + {"id": "tg__0.DropPackets", "text": "DropPackets", "parent": "tg__0"} + ] + self.jstree._create_node(_id) + + self.assertEqual(self.jstree._created_nodes, ['#', 'tg__0', 'tg__0.DropPackets']) + self.assertEqual(self.jstree.jstree_data, expected_data) + + def test_format_for_jstree(self): + data = [ + {'data': [0, ], 'name': 'tg__0.DropPackets'}, + {'data': [548, ], 'name': 'tg__0.LatencyAvg.5'}, + {'data': [1172, ], 'name': 'tg__0.LatencyAvg.6'}, + {'data': [1001, ], 'name': 'tg__0.LatencyMax.5'}, + {'data': [1468, ], 'name': 'tg__0.LatencyMax.6'}, + {'data': [18.11, ], 'name': 'tg__0.RxThroughput'}, + {'data': [18.11, ], 'name': 'tg__0.TxThroughput'}, + {'data': [0, ], 'name': 'tg__1.DropPackets'}, + {'data': [548, ], 'name': 'tg__1.LatencyAvg.5'}, + {'data': [1172, ], 'name': 'tg__1.LatencyAvg.6'}, + {'data': [1001, ], 'name': 'tg__1.LatencyMax.5'}, + {'data': [1468, ], 'name': 'tg__1.LatencyMax.6'}, + {'data': [18.1132084505, ], 'name': 'tg__1.RxThroughput'}, + {'data': [18.1157260383, ], 'name': 'tg__1.TxThroughput'}, + {'data': [9057888, ], 'name': 'vnf__0.curr_packets_in'}, + {'data': [0, ], 'name': 'vnf__0.packets_dropped'}, + {'data': [617825443, ], 'name': 'vnf__0.packets_fwd'}, + ] + + expected_output = [ + {"id": "tg__0", "text": "tg__0", "parent": "#"}, + {"id": "tg__0.DropPackets", "text": "DropPackets", "parent": "tg__0"}, + {"id": "tg__0.LatencyAvg", "text": "LatencyAvg", "parent": "tg__0"}, + {"id": "tg__0.LatencyAvg.5", "text": "5", "parent": "tg__0.LatencyAvg"}, + {"id": "tg__0.LatencyAvg.6", "text": "6", "parent": "tg__0.LatencyAvg"}, + {"id": "tg__0.LatencyMax", "text": "LatencyMax", "parent": "tg__0"}, + {"id": "tg__0.LatencyMax.5", "text": "5", "parent": "tg__0.LatencyMax"}, + {"id": "tg__0.LatencyMax.6", "text": "6", "parent": "tg__0.LatencyMax"}, + {"id": "tg__0.RxThroughput", "text": "RxThroughput", "parent": "tg__0"}, + {"id": "tg__0.TxThroughput", "text": "TxThroughput", "parent": "tg__0"}, + {"id": "tg__1", "text": "tg__1", "parent": "#"}, + {"id": "tg__1.DropPackets", "text": "DropPackets", "parent": "tg__1"}, + {"id": "tg__1.LatencyAvg", "text": "LatencyAvg", "parent": "tg__1"}, + {"id": "tg__1.LatencyAvg.5", "text": "5", "parent": "tg__1.LatencyAvg"}, + {"id": "tg__1.LatencyAvg.6", "text": "6", "parent": "tg__1.LatencyAvg"}, + {"id": "tg__1.LatencyMax", "text": "LatencyMax", "parent": "tg__1"}, + {"id": "tg__1.LatencyMax.5", "text": "5", "parent": "tg__1.LatencyMax"}, + {"id": "tg__1.LatencyMax.6", "text": "6", "parent": "tg__1.LatencyMax"}, + {"id": "tg__1.RxThroughput", "text": "RxThroughput", "parent": "tg__1"}, + {"id": "tg__1.TxThroughput", "text": "TxThroughput", "parent": "tg__1"}, + {"id": "vnf__0", "text": "vnf__0", "parent": "#"}, + {"id": "vnf__0.curr_packets_in", "text": "curr_packets_in", "parent": "vnf__0"}, + {"id": "vnf__0.packets_dropped", "text": "packets_dropped", "parent": "vnf__0"}, + {"id": "vnf__0.packets_fwd", "text": "packets_fwd", "parent": "vnf__0"}, + ] + + result = self.jstree.format_for_jstree(data) + self.assertEqual(expected_output, result) + + class ReportTestCase(unittest.TestCase): def setUp(self): -- cgit 1.2.3-korg