{ "__inputs": [ { "name": "DS_YARDSTICK", "label": "yardstick", "description": "", "type": "datasource", "pluginId": "influxdb", "pluginName": "InfluxDB" } ], "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", "version": "4.4.3" }, { "type": "panel", "id": "graph", "name": "Graph", "version": "" }, { "type": "datasource", "id": "influxdb", "name": "InfluxDB", "version": "1.0.0" }, { "type": "panel", "id": "text", "name": "Text", "version": "" } ], "annotations": { "list": [] }, "editable": true, "gnetId": null, "graphTooltip": 0, "hideControls": false, "id": null, "links": [], "refresh": false, "rows": [ { "collapse": false, "height": "100px", "panels": [ { "content": "
OPNFV_Yardstick_NSB_PROX_Heat_vPE_4Port_Test
\n
\n

The vPE handles packet processing, routing, QinQ encapsulation, flows, ACL rules, adds/removes MPLS tags and performs QoS

\n

The KPI is the number of packets per second for a specified packet size (min packet size is 68 byte) with an accepted minimal packet loss

\n
", "editable": true, "error": false, "id": 3, "links": [], "mode": "html", "span": 12, "title": "", "type": "text" }, { "content": "
Prox vPE VNF stats
\n", "editable": true, "error": false, "height": "40", "id": 7, "links": [], "mode": "html", "span": 12, "title": "", "type": "text" } ], "repeat": null, "repeatIteration": null, "repeatRowId": null, "showTitle": false, "title": "Row", "titleSize": "h6" }, { "collapse": false, "height": "300px", "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_YARDSTICK}", "editable": true, "error": false, "fill": 1, "grid": {}, "height": "300", "id": 4, "legend": { "alignAsTable": true, "avg": true, "current": false, "max": true, "min": true, "rightSide": false, "show": true, "total": false, "values": true }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "connected", "percentage": false, "pointradius": 1, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "span": 12, "stack": false, "steppedLine": false, "targets": [ { "alias": "VNF packets Forward", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "vnf__0.packets_fwd" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "VNF packets in", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "C", "resultFormat": "time_series", "select": [ [ { "params": [ "vnf__0.packets_in" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "VNF packets dropped", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "vnf__0.packets_dropped" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] } ], "thresholds": [ { "colorMode": "custom", "fill": true, "fillColor": "rgba(216, 200, 27, 0.27)", "op": "gt", "value": 2 }, { "colorMode": "custom", "fill": true, "fillColor": "rgba(234, 112, 112, 0.22)", "op": "gt", "value": 2 } ], "timeFrom": null, "timeShift": null, "title": "vPE VNF stats", "tooltip": { "msResolution": true, "shared": true, "sort": 0, "value_type": "cumulative" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": "Packets", "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ] }, { "content": "
Prox vPE Traffic Gen stats
\n", "editable": true, "error": false, "height": "40", "id": 8, "links": [], "mode": "html", "span": 12, "title": "", "type": "text" } ], "repeat": null, "repeatIteration": null, "repeatRowId": null, "showTitle": false, "title": "New row", "titleSize": "h6" }, { "collapse": false, "height": "300px", "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_YARDSTICK}", "editable": true, "error": false, "fill": 1, "grid": {}, "id": 6, "legend": { "alignAsTable": true, "avg": true, "current": false, "max": true, "min": true, "show": true, "total": false, "values": true }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "connected", "percentage": false, "pointradius": 5, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "span": 6, "stack": false, "steppedLine": false, "targets": [ { "alias": "TG xe-0 Out packets", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "tg__0.xe0.out_packets" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "TG xe-1 Out packets", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "tg__0.xe1.out_packets" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "TG xe-2 Out packets", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "C", "resultFormat": "time_series", "select": [ [ { "params": [ "tg__0.xe2.out_packets" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "TG xe-3 Out packets", "dsType": "influxdb", "groupBy": [ { "params": [ "$interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "tc_prox_heat_context_vpe-4", "orderByTime": "ASC", "policy": "default", "refId": "D", "resul
#!/usr/bin/env python

##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
#
# 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
##############################################################################

# Unittest for yardstick.benchmark.scenarios.compute.lmbench.Lmbench

from __future__ import absolute_import
import mock
import unittest
import os

from yardstick.benchmark.scenarios.compute import cpuload


@mock.patch('yardstick.benchmark.scenarios.compute.cpuload.ssh')
class CPULoadTestCase(unittest.TestCase):

    def setUp(self):
        self.ctx = {
            'host': {
                'ip': '172.16.0.137',
                'user': 'cirros',
                'key_filename': "mykey.key"
            }
        }

        self.result = {}

    def test_setup_mpstat_installed(self, mock_ssh):
        options = {
            "interval": 1,
            "count": 1
        }

        args = {'options': options}

        l = cpuload.CPULoad(args, self.ctx)
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')

        l.setup()
        self.assertIsNotNone(l.client)
        self.assertTrue(l.setup_done)
        self.assertTrue(l.has_mpstat)

    def test_setup_mpstat_not_installed(self, mock_ssh):
        options = {
            "interval": 1,
            "count": 1
        }

        args = {'options': options}

        l = cpuload.CPULoad(args, self.ctx)
        mock_ssh.SSH.from_node().execute.return_value = (127, '', '')

        l.setup()
        self.assertIsNotNone(l.client)
        self.assertTrue(l.setup_done)
        self.assertFalse(l.has_mpstat)

    def test_execute_command_success(self, mock_ssh):
        options = {
            "interval": 1,
            "count": 1
        }

        args = {'options': options}

        l = cpuload.CPULoad(args, self.ctx)
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
        l.setup()

        expected_result = 'abcdefg'
        mock_ssh.SSH.from_node().execute.return_value = (0, expected_result, '')
        result = l._execute_command("foo")
        self.assertEqual(result, expected_result)

    def test_execute_command_failed(self, mock_ssh):
        options = {
            "interval": 1,
            "count": 1
        }

        args = {'options': options}

        l = cpuload.CPULoad(args, self.ctx)
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
        l.setup()

        mock_ssh.SSH.from_node().execute.return_value = (127, '', 'abcdefg'