aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ansible/roles/barometer_collectd/tasks/main.yaml40
-rw-r--r--ansible/roles/docker/tasks/Debian.yml16
-rw-r--r--ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml2
-rw-r--r--docs/testing/user/userguide/10-yardstick-user-interface.rst18
-rw-r--r--requirements.txt3
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py16
-rw-r--r--yardstick/benchmark/core/report.py103
-rw-r--r--yardstick/common/html_template.py124
-rw-r--r--yardstick/common/nsb_report.css29
-rw-r--r--yardstick/common/nsb_report.html.j2160
-rw-r--r--yardstick/common/report.html.j2121
-rw-r--r--yardstick/common/utils.py3
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py3
-rw-r--r--yardstick/tests/unit/benchmark/core/test_report.py184
14 files changed, 615 insertions, 207 deletions
diff --git a/ansible/roles/barometer_collectd/tasks/main.yaml b/ansible/roles/barometer_collectd/tasks/main.yaml
new file mode 100644
index 000000000..c06540c3f
--- /dev/null
+++ b/ansible/roles/barometer_collectd/tasks/main.yaml
@@ -0,0 +1,40 @@
+#Copyright 2018 OPNFV and Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+
+- name: Remove barometer-collectd container
+ docker_container:
+ name: barometer-collectd
+ state: absent
+
+- name: Remove barometer-collectd image
+ docker_image:
+ name: opnfv/barometer-collectd
+ state: absent
+
+- name: Prepare collectd container
+ docker_container:
+ name: barometer-collectd
+ image: opnfv/barometer-collectd
+ volumes:
+ - /opt/collectd/etc/collectd.conf.d/:/opt/collectd/etc/collectd.conf.d
+ - /var/run:/var/run
+ - /tmp:/tmp
+ - /var/lib/collectd:/var/lib/collectd
+ command: "/run_collectd.sh"
+ detach: yes
+ state: present
+ restart: no
+ privileged: yes
+ network_mode: host
diff --git a/ansible/roles/docker/tasks/Debian.yml b/ansible/roles/docker/tasks/Debian.yml
index 7f998de45..a03040d88 100644
--- a/ansible/roles/docker/tasks/Debian.yml
+++ b/ansible/roles/docker/tasks/Debian.yml
@@ -14,3 +14,19 @@
---
- name: Install docker.io
action: "{{ ansible_pkg_mgr }} name=docker.io state=present force=yes"
+
+ - name: Update package manager cache
+ tags:
+ - cache_update
+ package:
+ update_cache: yes
+
+ - name: Install python-pip
+ package:
+ name: python-pip
+ state: present
+
+ - name: Install docker-py
+ pip:
+ name: docker-py
+ state: present
diff --git a/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml b/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml
index 3a29a8a90..b69fb58fb 100644
--- a/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml
+++ b/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml
@@ -54,3 +54,5 @@
- install_pmu_tools
- download_collectd
- install_collectd
+ - docker
+ - barometer_collectd
diff --git a/docs/testing/user/userguide/10-yardstick-user-interface.rst b/docs/testing/user/userguide/10-yardstick-user-interface.rst
index cadec78ef..76890b29a 100644
--- a/docs/testing/user/userguide/10-yardstick-user-interface.rst
+++ b/docs/testing/user/userguide/10-yardstick-user-interface.rst
@@ -16,15 +16,19 @@ Command
Description
===========
-1. When the command is triggered using the task-id and the testcase
-name provided the respective values are retrieved from the
-database (influxdb in this particular case).
+1. When the command is triggered, the relevant values for the
+ provided task-id and testcase name are retrieved from the
+ database (`InfluxDB`_ in this particular case).
-2. The values are then formatted and then provided to the html
-template framed with complete html body using Django Framework.
+2. The values are then formatted and provided to the html
+ template to be rendered using `Jinja2`_.
-3. Then the whole template is written into a html file.
+3. Then the rendered template is written into a html file.
The graph is framed with Timestamp on x-axis and output values
(differ from testcase to testcase) on y-axis with the help of
-"Highcharts".
+`Highcharts`_.
+
+.. _InfluxDB: https://www.influxdata.com/time-series-platform/influxdb/
+.. _Jinja2: http://jinja.pocoo.org/docs/2.10/
+.. _Highcharts: https://www.highcharts.com/products/highcharts/
diff --git a/requirements.txt b/requirements.txt
index 43d7120db..43a6c7fdb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -15,9 +15,6 @@ ansible==2.5.5 # GPLv3; OSI Approved GNU General Public License v3 or
backport-ipaddress==0.1; python_version <= "2.7" # OSI Approved Python Software Foundation License
chainmap==1.0.2 # Python Software Foundation License; OSI Approved Python Software Foundation License
cmd2==0.8.6 # MIT License; OSI Approved MIT License
-django==1.8.17 # BSD; OSI Approved BSD License
- # NOTE(ralonsoh): django must be bumped to 1.11.8; consider the migration notes [1]
- # [1] https://docs.djangoproject.com/ja/1.11/ref/templates/upgrading/
docker-py==1.10.6 # OSI Approved Apache Software License
extras==1.0.0 # OSI Approved MIT License
flasgger==0.5.13 # MIT
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index 42a275455..3a310f146 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -74,6 +74,11 @@ class OvsDpdkContext(base.Context):
self.wait_for_vswitchd = 10
super(OvsDpdkContext, self).__init__()
+ def get_dpdk_socket_mem_size(self, socket_id):
+ """Get the size of OvS DPDK socket memory (Mb)"""
+ ram = self.ovs_properties.get("ram", {})
+ return ram.get('socket_%d' % (socket_id), 2048)
+
def init(self, attrs):
"""initializes itself from the supplied arguments"""
super(OvsDpdkContext, self).init(attrs)
@@ -134,9 +139,6 @@ class OvsDpdkContext(base.Context):
if pmd_cpu_mask:
pmd_mask = pmd_cpu_mask
- socket0 = self.ovs_properties.get("ram", {}).get("socket_0", "2048")
- socket1 = self.ovs_properties.get("ram", {}).get("socket_1", "2048")
-
ovs_other_config = "ovs-vsctl {0}set Open_vSwitch . other_config:{1}"
detach_cmd = "ovs-vswitchd unix:{0}{1} --pidfile --detach --log-file={2}"
@@ -154,7 +156,9 @@ class OvsDpdkContext(base.Context):
("ovsdb-server --remote=punix:/{0}/{1} --remote=ptcp:6640"
" --pidfile --detach").format(vpath, ovs_sock_path),
ovs_other_config.format("--no-wait ", "dpdk-init=true"),
- ovs_other_config.format("--no-wait ", "dpdk-socket-mem='%s,%s'" % (socket0, socket1)),
+ ovs_other_config.format("--no-wait ", "dpdk-socket-mem='%d,%d'" % (
+ self.get_dpdk_socket_mem_size(0),
+ self.get_dpdk_socket_mem_size(1))),
lcore_mask,
detach_cmd.format(vpath, ovs_sock_path, log_path),
ovs_other_config.format("", "pmd-cpu-mask=%s" % pmd_mask),
@@ -399,7 +403,9 @@ class OvsDpdkContext(base.Context):
self.configure_nics_for_ovs_dpdk()
hp_total_mb = int(self.vm_flavor.get('ram', '4096')) * len(self.servers)
- common_utils.setup_hugepages(self.connection, hp_total_mb * 1024)
+ common_utils.setup_hugepages(self.connection, (hp_total_mb + \
+ self.get_dpdk_socket_mem_size(0) + \
+ self.get_dpdk_socket_mem_size(1)) * 1024)
self._check_hugepages()
diff --git a/yardstick/benchmark/core/report.py b/yardstick/benchmark/core/report.py
index 199602444..a484a49f3 100644
--- a/yardstick/benchmark/core/report.py
+++ b/yardstick/benchmark/core/report.py
@@ -1,7 +1,7 @@
-#############################################################################
-# Copyright (c) 2017 Rajesh Kudaka
+##############################################################################
+# Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com>
+# Copyright (c) 2018 Intel Corporation.
#
-# Author: Rajesh Kudaka 4k.rajesh@gmail.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
@@ -10,27 +10,76 @@
""" Handler for yardstick command 'report' """
-from __future__ import print_function
-
-from __future__ import absolute_import
-
import ast
import re
import uuid
+import jinja2
from api.utils import influx
-
-from django.conf import settings
-from django.template import Context
-from django.template import Template
-
from oslo_utils import encodeutils
from oslo_utils import uuidutils
from yardstick.common import constants as consts
-from yardstick.common.html_template import template
from yardstick.common.utils import cliargs
-settings.configure()
+
+class JSTree(object):
+ """Data structure to parse data for use with the JS library jsTree"""
+ def __init__(self):
+ self._created_nodes = ['#']
+ self.jstree_data = []
+
+ def _create_node(self, _id):
+ """Helper method for format_for_jstree to create each node.
+
+ Creates the node (and any required parents) and keeps track
+ of the created nodes.
+
+ :param _id: (string) id of the node to be created
+ :return: None
+ """
+ components = _id.split(".")
+
+ if len(components) == 1:
+ text = components[0]
+ parent_id = "#"
+ else:
+ text = components[-1]
+ parent_id = ".".join(components[:-1])
+ # make sure the parent has been created
+ if not parent_id in self._created_nodes:
+ self._create_node(parent_id)
+
+ self.jstree_data.append({"id": _id, "text": text, "parent": parent_id})
+ self._created_nodes.append(_id)
+
+ def format_for_jstree(self, data):
+ """Format the data into the required format for jsTree.
+
+ The data format expected is a list of key-value pairs which represent
+ the data and name for each metric e.g.:
+
+ [{'data': [0, ], 'name': 'tg__0.DropPackets'},
+ {'data': [548, ], 'name': 'tg__0.LatencyAvg.5'},]
+
+ This data is converted into the format required for jsTree to group and
+ display the metrics in a hierarchial fashion, including creating a
+ number of parent nodes e.g.::
+
+ [{"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"},]
+
+ :param data: (list) data to be converted
+ :return: list
+ """
+ self._created_nodes = ['#']
+ self.jstree_data = []
+
+ for item in data:
+ self._create_node(item["name"])
+
+ return self.jstree_data
class Report(object):
@@ -64,7 +113,7 @@ class Report(object):
if query_exec:
return query_exec
else:
- raise KeyError("Task ID or Test case not found..")
+ raise KeyError("Test case not found.")
def _get_tasks(self):
task_cmd = "select * from \"%s\" where task_id= '%s'"
@@ -73,7 +122,7 @@ class Report(object):
if query_exec:
return query_exec
else:
- raise KeyError("Task ID or Test case not found..")
+ raise KeyError("Task ID or Test case not found.")
@cliargs("task_id", type=str, help=" task id", nargs=1)
@cliargs("yaml_name", type=str, help=" Yaml file Name", nargs=1)
@@ -117,12 +166,22 @@ class Report(object):
series['data'] = values
temp_series.append(series)
- Template_html = Template(template)
- Context_html = Context({"series": temp_series,
- "Timestamp": self.Timestamp,
- "task_id": self.task_id,
- "table": table_vals})
+ template_dir = consts.YARDSTICK_ROOT_PATH + "yardstick/common"
+ template_environment = jinja2.Environment(
+ autoescape=False,
+ loader=jinja2.FileSystemLoader(template_dir),
+ trim_blocks=False)
+
+ context = {
+ "series": temp_series,
+ "Timestamps": self.Timestamp,
+ "task_id": self.task_id,
+ "table": table_vals,
+ }
+
+ template_html = template_environment.get_template("report.html.j2")
+
with open(consts.DEFAULT_HTML_FILE, "w") as file_open:
- file_open.write(Template_html.render(Context_html))
+ file_open.write(template_html.render(context))
print("Report generated. View /tmp/yardstick.htm")
diff --git a/yardstick/common/html_template.py b/yardstick/common/html_template.py
index e17c76637..c15dd8238 100644
--- a/yardstick/common/html_template.py
+++ b/yardstick/common/html_template.py
@@ -8,130 +8,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
#############################################################################
-template = """
-<html>
-<body>
-<head>
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7\
-/css/bootstrap.min.css">
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1\
-/jquery.min.js"></script>
-<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7\
-/js/bootstrap.min.js"></script>
-<script src="https://code.highcharts.com/highcharts.js"></script>
-<script src="jquery.min.js"></script>
-<script src="highcharts.js"></script>
-</head>
-<style>
-
-table{
- overflow-y: scroll;
- height: 360px;
- display: block;
- }
-
- header,h3{
- font-family:Frutiger;
- clear: left;
- text-align: center;
-}
-</style>
-<header class="jumbotron text-center">
- <h1>Yardstick User Interface</h1>
- <h4>Report of {{task_id}} Generated</h4>
-</header>
-
-<div class="container">
- <div class="row">
- <div class="col-md-4">
- <div class="table-responsive" >
- <table class="table table-hover" > </table>
- </div>
- </div>
- <div class="col-md-8" >
- <div id="container" ></div>
- </div>
- </div>
-</div>
-<script>
- var arr, tab, th, tr, td, tn, row, col, thead, tbody;
- arr={{table|safe}}
- tab = document.getElementsByTagName('table')[0];
- thead=document.createElement('thead');
- tr = document.createElement('tr');
- for(row=0;row<Object.keys(arr).length;row++)
- {
- th = document.createElement('th');
- tn = document.createTextNode(Object.keys(arr).sort()[row]);
- th.appendChild(tn);
- tr.appendChild(th);
- thead.appendChild(tr);
- }
- tab.appendChild(thead);
- tbody=document.createElement('tbody');
-
- for (col = 0; col < arr[Object.keys(arr)[0]].length; col++){
- tr = document.createElement('tr');
- for(row=0;row<Object.keys(arr).length;row++)
- {
- td = document.createElement('td');
- tn = document.createTextNode(arr[Object.keys(arr).sort()[row]][col]);
- td.appendChild(tn);
- tr.appendChild(td);
- }
- tbody.appendChild(tr);
- }
-tab.appendChild(tbody);
-
-</script>
-
-<script language="JavaScript">
-
-$(function() {
- $('#container').highcharts({
- title: {
- text: 'Yardstick test results',
- x: -20 //center
- },
- subtitle: {
- text: 'Report of {{task_id}} Task Generated',
- x: -20
- },
- xAxis: {
- title: {
- text: 'Timestamp'
- },
- categories:{{Timestamp|safe}}
- },
- yAxis: {
-
- plotLines: [{
- value: 0,
- width: 1,
- color: '#808080'
- }]
- },
- tooltip: {
- valueSuffix: ''
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'middle',
- borderWidth: 0
- },
- series: {{series|safe}}
- });
-});
-
-</script>
-
-
-</body>
-</html>"""
-
report_template = """
<html>
<head>
diff --git a/yardstick/common/nsb_report.css b/yardstick/common/nsb_report.css
new file mode 100644
index 000000000..0c47791e2
--- /dev/null
+++ b/yardstick/common/nsb_report.css
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com>
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ ******************************************************************************/
+
+body {
+ font-size: 16pt;
+}
+
+table {
+ overflow-y: scroll;
+ height: 360px;
+ display: block;
+}
+
+header {
+ font-family: Frutiger;
+ clear: left;
+ text-align: center;
+}
+
+.control-pane {
+ font-size: 10pt;
+}
diff --git a/yardstick/common/nsb_report.html.j2 b/yardstick/common/nsb_report.html.j2
new file mode 100644
index 000000000..f1b4ae1c2
--- /dev/null
+++ b/yardstick/common/nsb_report.html.j2
@@ -0,0 +1,160 @@
+<!DOCTYPE html>
+<html>
+
+<!--
+ Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com>
+ 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
+ which accompanies this distribution, and is available at
+ http://www.apache.org/licenses/LICENSE-2.0
+-->
+
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.5/themes/default/style.min.css">
+ <link rel="stylesheet" href="{{template_dir}}/nsb_report.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
+ <script src="https://code.highcharts.com/highcharts.js"></script>
+ </head>
+
+ <body>
+ <div class="container" style="width:80%">
+ <div class="row">
+ <header class="jumbotron">
+ <h1>Yardstick User Interface</h1>
+ <h4>Report of {{task_id}} Generated</h4>
+ </header>
+ </div>
+ <div class="row" style="height:500px">
+ <div class="col-md-2 control-pane">
+ <div id="data_selector"></div>
+ </div>
+ <div class="col-md-10 data-pane">
+ <div id="graph"></div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-12 table-responsive">
+ <table class="table table-hover"></table>
+ </div>
+ </div>
+ </div>
+
+ <script>
+ var arr, tab, tr, td, tbody, keys, key, curr_data;
+ arr = {{table|safe}};
+
+ tab = document.getElementsByTagName('table')[0];
+ tbody = document.createElement('tbody');
+ keys = Object.keys(arr);
+ // for each metric
+ for (var i = 0; i < keys.length; i++) {
+ tr = document.createElement('tr');
+ td = document.createElement('td');
+ key = keys[i];
+ td.append(key);
+ tr.append(td);
+ curr_data = arr[key];
+ // add each piece of data as its own column
+ for (var j = 0; j < curr_data.length; j++) {
+ td = document.createElement('td');
+ td.append(curr_data[j]);
+ tr.append(td);
+ }
+ tbody.append(tr);
+ }
+ tab.appendChild(tbody);
+
+ $(function() {
+ $('#data_selector').jstree({
+ plugins: ['checkbox'],
+ checkbox: {
+ three_state: false,
+ whole_node: true,
+ tie_selection: false,
+ },
+ core: {
+ themes: {
+ icons: false,
+ stripes: true,
+ },
+ data: {{jstree_nodes|safe}},
+ },
+ });
+
+ $('#data_selector').on('check_node.jstree uncheck_node.jstree', function(e, data) {
+ var selected_leaves = [];
+ for (var i = 0; i < data.selected.length; i++) {
+ var node = data.instance.get_node(data.selected[i]);
+ if (node.children.length == 0) {
+ var point = {name: node.id, data: arr[node.id]};
+ selected_leaves.push(point);
+ }
+ }
+
+ $('#graph').highcharts({
+ title: {
+ text: 'Yardstick Graphs',
+ x: -20, //center
+ },
+ chart: {
+ marginLeft: 400,
+ zoomType: 'x',
+ type: 'spline',
+ },
+ xAxis: {
+ crosshair: {
+ width: 1,
+ color: 'black',
+ },
+ title: {
+ text: 'Timestamp',
+ },
+ categories: {{Timestamps|safe}},
+ },
+ yAxis: {
+ crosshair: {
+ width: 1,
+ color: 'black',
+ },
+ plotLines: [{
+ value: 0,
+ width: 1,
+ color: '#808080',
+ }],
+ },
+ plotOptions: {
+ series: {
+ showCheckbox: false,
+ visible: false,
+ },
+ },
+ tooltip: {
+ valueSuffix: '',
+ },
+ legend: {
+ enabled: true,
+ },
+ series: selected_leaves,
+ });
+
+ var chart = $('#graph').highcharts();
+ for (var i = 0; i < chart.series.length; i++) {
+ var series = chart.series[i];
+ if (series.visible) {
+ series.hide();
+ } else {
+ series.show();
+ }
+ }
+ });
+ });
+ </script>
+ </body>
+</html>
diff --git a/yardstick/common/report.html.j2 b/yardstick/common/report.html.j2
new file mode 100644
index 000000000..ab76510ca
--- /dev/null
+++ b/yardstick/common/report.html.j2
@@ -0,0 +1,121 @@
+<!DOCTYPE html>
+<html>
+
+<!--
+ Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com>
+ 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
+ which accompanies this distribution, and is available at
+ http://www.apache.org/licenses/LICENSE-2.0
+-->
+
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ <script src="https://code.highcharts.com/highcharts.js"></script>
+
+ <style>
+ table {
+ overflow-y: scroll;
+ height: 360px;
+ display: block;
+ }
+ header {
+ font-family: Frutiger;
+ clear: left;
+ text-align: center;
+ }
+ </style>
+ </head>
+
+ <body>
+ <header class="jumbotron text-center">
+ <h1>Yardstick User Interface</h1>
+ <h4>Report of {{task_id}} Generated</h4>
+ </header>
+
+ <div class="container">
+ <div class="row">
+ <div class="col-md-4">
+ <div class="table-responsive">
+ <table class="table table-hover"></table>
+ </div>
+ </div>
+ <div class="col-md-8">
+ <div id="container"></div>
+ </div>
+ </div>
+ </div>
+
+ <script>
+ var arr, tab, th, tr, td, tn, row, col, thead, tbody;
+ arr = {{table|safe}};
+ tab = document.getElementsByTagName('table')[0];
+
+ thead = document.createElement('thead');
+ tr = document.createElement('tr');
+ for (col = 0; col < Object.keys(arr).length; col++) {
+ th = document.createElement('th');
+ tn = document.createTextNode(Object.keys(arr).sort()[col]);
+ th.appendChild(tn);
+ tr.appendChild(th);
+ thead.appendChild(tr);
+ }
+ tab.appendChild(thead);
+
+ tbody = document.createElement('tbody');
+ for (row = 0; row < arr[Object.keys(arr)[0]].length; row++) {
+ tr = document.createElement('tr');
+ for (col = 0; col < Object.keys(arr).length; col++) {
+ td = document.createElement('td');
+ tn = document.createTextNode(arr[Object.keys(arr).sort()[col]][row]);
+ td.appendChild(tn);
+ tr.appendChild(td);
+ }
+ tbody.appendChild(tr);
+ }
+ tab.appendChild(tbody);
+
+ $(function() {
+ $('#container').highcharts({
+ title: {
+ text: 'Yardstick test results',
+ x: -20, //center
+ },
+ subtitle: {
+ text: 'Report of {{task_id}} Task Generated',
+ x: -20,
+ },
+ xAxis: {
+ title: {
+ text: 'Timestamp',
+ },
+ categories: {{Timestamps|safe}},
+ },
+ yAxis: {
+ plotLines: [{
+ value: 0,
+ width: 1,
+ color: '#808080',
+ }],
+ },
+ tooltip: {
+ valueSuffix: '',
+ },
+ legend: {
+ layout: 'vertical',
+ align: 'right',
+ verticalAlign: 'middle',
+ borderWidth: 0,
+ },
+ series: {{series|safe}},
+ });
+ });
+ </script>
+ </body>
+</html>
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 205247947..51313ef47 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -30,6 +30,7 @@ import subprocess
import sys
import time
import threading
+import math
import six
from flask import jsonify
@@ -505,7 +506,7 @@ def setup_hugepages(ssh_client, size_kb):
NR_HUGEPAGES_PATH = '/proc/sys/vm/nr_hugepages'
meminfo = read_meminfo(ssh_client)
hp_size_kb = int(meminfo['Hugepagesize'])
- hp_number = int(abs(size_kb / hp_size_kb))
+ hp_number = int(math.ceil(size_kb / float(hp_size_kb)))
ssh_client.execute(
'echo %s | sudo tee %s' % (hp_number, NR_HUGEPAGES_PATH))
hp = six.BytesIO()
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
index 190e83d5f..b5051e90c 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -430,7 +430,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.assertEqual([vnf_instance_2],
self.ovs_dpdk.setup_ovs_dpdk_context())
- mock_setup_hugepages.assert_called_once_with(self.ovs_dpdk.connection, 1024 * 1024)
+ mock_setup_hugepages.assert_called_once_with(self.ovs_dpdk.connection,
+ (1024 + 4096) * 1024) # ram + dpdk_socket0_mem + dpdk_socket1_mem
mock__check_hugepages.assert_called_once()
mock_create_vm.assert_called_once_with(
self.ovs_dpdk.connection, '/tmp/vm_ovs_0.xml')
diff --git a/yardstick/tests/unit/benchmark/core/test_report.py b/yardstick/tests/unit/benchmark/core/test_report.py
index 524302f92..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
@@ -7,30 +8,93 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.core.report
-
-from __future__ import print_function
-
-from __future__ import absolute_import
-
+import mock
import unittest
import uuid
-try:
- from unittest import mock
-except ImportError:
- import mock
-
+from api.utils import influx
from yardstick.benchmark.core import report
from yardstick.cmd.commands import change_osloobj_to_paras
-FAKE_YAML_NAME = 'fake_name'
-FAKE_TASK_ID = str(uuid.uuid4())
-FAKE_DB_FIELDKEYS = [{'fieldKey': 'fake_key'}]
-FAKE_TIME = '0000-00-00T00:00:00.000000Z'
-FAKE_DB_TASK = [{'fake_key': 0.000, 'time': FAKE_TIME}]
-FAKE_TIMESTAMP = ['fake_time']
-DUMMY_TASK_ID = 'aaaaaa-aaaaaaaa-aaaaaaaaaa-aaaaaa'
+GOOD_YAML_NAME = 'fake_name'
+GOOD_TASK_ID = str(uuid.uuid4())
+GOOD_DB_FIELDKEYS = [{'fieldKey': 'fake_key'}]
+GOOD_DB_TASK = [{
+ 'fake_key': 0.000,
+ 'time': '0000-00-00T00:00:00.000000Z',
+ }]
+GOOD_TIMESTAMP = ['00:00:00.000000']
+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):
@@ -38,37 +102,69 @@ class ReportTestCase(unittest.TestCase):
def setUp(self):
super(ReportTestCase, self).setUp()
self.param = change_osloobj_to_paras({})
- self.param.yaml_name = [FAKE_YAML_NAME]
- self.param.task_id = [FAKE_TASK_ID]
+ self.param.yaml_name = [GOOD_YAML_NAME]
+ self.param.task_id = [GOOD_TASK_ID]
self.rep = report.Report()
+ def test___init__(self):
+ self.assertEqual([], self.rep.Timestamp)
+ self.assertEqual("", self.rep.yaml_name)
+ self.assertEqual("", self.rep.task_id)
+
+ def test__validate(self):
+ self.rep._validate(GOOD_YAML_NAME, GOOD_TASK_ID)
+ self.assertEqual(GOOD_YAML_NAME, self.rep.yaml_name)
+ self.assertEqual(GOOD_TASK_ID, str(self.rep.task_id))
+
+ def test__validate_invalid_yaml_name(self):
+ with self.assertRaisesRegexp(ValueError, "yaml*"):
+ self.rep._validate(BAD_YAML_NAME, GOOD_TASK_ID)
+
+ def test__validate_invalid_task_id(self):
+ with self.assertRaisesRegexp(ValueError, "task*"):
+ self.rep._validate(GOOD_YAML_NAME, BAD_TASK_ID)
+
+ @mock.patch.object(influx, 'query')
+ def test__get_fieldkeys(self, mock_query):
+ mock_query.return_value = GOOD_DB_FIELDKEYS
+ self.rep.yaml_name = GOOD_YAML_NAME
+ self.rep.task_id = GOOD_TASK_ID
+ self.assertEqual(GOOD_DB_FIELDKEYS, self.rep._get_fieldkeys())
+
+ @mock.patch.object(influx, 'query')
+ def test__get_fieldkeys_nodbclient(self, mock_query):
+ mock_query.side_effect = RuntimeError
+ self.assertRaises(RuntimeError, self.rep._get_fieldkeys)
+
+ @mock.patch.object(influx, 'query')
+ def test__get_fieldkeys_testcase_not_found(self, mock_query):
+ mock_query.return_value = []
+ self.rep.yaml_name = GOOD_YAML_NAME
+ self.rep.task_id = GOOD_TASK_ID
+ self.assertRaisesRegexp(KeyError, "Test case", self.rep._get_fieldkeys)
+
+ @mock.patch.object(influx, 'query')
+ def test__get_tasks(self, mock_query):
+ mock_query.return_value = GOOD_DB_TASK
+ self.rep.yaml_name = GOOD_YAML_NAME
+ self.rep.task_id = GOOD_TASK_ID
+ self.assertEqual(GOOD_DB_TASK, self.rep._get_tasks())
+
+ @mock.patch.object(influx, 'query')
+ def test__get_tasks_task_not_found(self, mock_query):
+ mock_query.return_value = []
+ self.rep.yaml_name = GOOD_YAML_NAME
+ self.rep.task_id = GOOD_TASK_ID
+ self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_tasks)
+
@mock.patch.object(report.Report, '_get_tasks')
@mock.patch.object(report.Report, '_get_fieldkeys')
@mock.patch.object(report.Report, '_validate')
- def test_generate_success(self, mock_valid, mock_keys, mock_tasks):
- mock_tasks.return_value = FAKE_DB_TASK
- mock_keys.return_value = FAKE_DB_FIELDKEYS
+ def test_generate(self, mock_valid, mock_keys, mock_tasks):
+ mock_tasks.return_value = GOOD_DB_TASK
+ mock_keys.return_value = GOOD_DB_FIELDKEYS
self.rep.generate(self.param)
- mock_valid.assert_called_once_with(FAKE_YAML_NAME, FAKE_TASK_ID)
+ mock_valid.assert_called_once_with(GOOD_YAML_NAME, GOOD_TASK_ID)
mock_tasks.assert_called_once_with()
mock_keys.assert_called_once_with()
-
- # pylint: disable=deprecated-method
- def test_invalid_yaml_name(self):
- self.assertRaisesRegexp(ValueError, "yaml*", self.rep._validate,
- 'F@KE_NAME', FAKE_TASK_ID)
-
- # pylint: disable=deprecated-method
- def test_invalid_task_id(self):
- self.assertRaisesRegexp(ValueError, "task*", self.rep._validate,
- FAKE_YAML_NAME, DUMMY_TASK_ID)
-
- @mock.patch('api.utils.influx.query')
- def test_task_not_found(self, mock_query):
- mock_query.return_value = []
- self.rep.yaml_name = FAKE_YAML_NAME
- self.rep.task_id = FAKE_TASK_ID
- # pylint: disable=deprecated-method
- self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_fieldkeys)
- self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_tasks)
- # pylint: enable=deprecated-method
+ self.assertEqual(GOOD_TIMESTAMP, self.rep.Timestamp)