aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc077.yaml63
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py12
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py186
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk.py35
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk_benchmark.bash196
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk_throughput.py226
-rw-r--r--yardstick/benchmark/scenarios/networking/testpmd_rev.bash69
-rw-r--r--yardstick/common/utils.py19
8 files changed, 772 insertions, 34 deletions
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc077.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc077.yaml
new file mode 100644
index 000000000..93ae063c6
--- /dev/null
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc077.yaml
@@ -0,0 +1,63 @@
+##############################################################################
+# Copyright (c) 2017 Nokia 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
+##############################################################################
+---
+
+schema: "yardstick:task:0.1"
+description: >
+ Yardstick TC077 config file;
+ Extend TC008 to run pktgen-dpdk (sender) and testpmd (receiver) inside VM.
+
+scenarios:
+{% for pkt_size in [64, 128, 256, 512, 1024, 1280, 1518] %}
+ {% for num_ports in [1, 10, 50, 100, 500, 1000] %}
+-
+ type: PktgenDPDK
+ options:
+ packetsize: {{pkt_size}}
+ number_of_ports: {{num_ports}}
+ duration: 20
+
+ host: demeter.yardstick-TC077
+ target: poseidon.yardstick-TC077
+
+ runner:
+ type: Iteration
+ iterations: 3
+ interval: 1
+
+ sla:
+ max_ppm: 1
+ action: rate-control
+ {% endfor %}
+{% endfor %}
+
+context:
+ name: yardstick-TC077
+ image: yardstick-dpdk-image
+ flavor: yardstick-dpdk-flavor
+ user: ubuntu
+
+ placement_groups:
+ pgrp1:
+ policy: "availability"
+
+ servers:
+ demeter:
+ floating_ip: true
+ placement: "pgrp1"
+ poseidon:
+ floating_ip: true
+ placement: "pgrp1"
+
+ networks:
+ test:
+ cidr: '10.0.1.0/24'
+ test2:
+ cidr: '10.0.2.0/24'
+ provider: "sriov"
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
index 496ee770c..e6998e443 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
@@ -16,6 +16,7 @@ import unittest
import mock
+import yardstick.common.utils as utils
from yardstick.benchmark.scenarios.networking import pktgen_dpdk
@@ -60,11 +61,10 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.get_port_ip(p.server, "eth1")
+ utils.get_port_ip(p.server, "eth1")
mock_ssh.SSH.from_node().execute.assert_called_with(
- "ifconfig eth1 |grep 'inet addr' |awk '{print $2}' \
- |cut -d ':' -f2 ")
+ "ifconfig eth1 |grep 'inet addr' |awk '{print $2}' |cut -d ':' -f2 ")
def test_pktgen_dpdk_unsuccessful_get_port_ip(self, mock_ssh):
@@ -76,7 +76,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.get_port_ip, p.server, "eth1")
+ self.assertRaises(RuntimeError, utils.get_port_ip, p.server, "eth1")
def test_pktgen_dpdk_successful_get_port_mac(self, mock_ssh):
@@ -88,7 +88,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.get_port_mac(p.server, "eth1")
+ utils.get_port_mac(p.server, "eth1")
mock_ssh.SSH.from_node().execute.assert_called_with(
"ifconfig |grep HWaddr |grep eth1 |awk '{print $5}' ")
@@ -103,7 +103,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.get_port_mac, p.server, "eth1")
+ self.assertRaises(RuntimeError, utils.get_port_mac, p.server, "eth1")
def test_pktgen_dpdk_successful_no_sla(self, mock_ssh):
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
new file mode 100644
index 000000000..0178165f8
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
@@ -0,0 +1,186 @@
+##############################################################################
+# Copyright (c) 2017 Nokia 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
+##############################################################################
+#!/usr/bin/env python
+
+# Unittest for yardstick.benchmark.scenarios.networking.pktgen.PktgenDPDK
+
+from __future__ import absolute_import
+import unittest
+
+from oslo_serialization import jsonutils
+import mock
+
+from yardstick.benchmark.scenarios.networking import pktgen_dpdk_throughput
+
+
+@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.ssh')
+class PktgenDPDKTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.ctx = {
+ 'host': {
+ 'ip': '172.16.0.137',
+ 'user': 'root',
+ 'key_filename': 'mykey.key'
+ },
+ 'target': {
+ 'ip': '172.16.0.138',
+ 'user': 'root',
+ 'key_filename': 'mykey.key',
+ }
+ }
+
+ def test_pktgen_dpdk_throughput_successful_setup(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60},
+ }
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+ p.setup()
+
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ self.assertIsNotNone(p.server)
+ self.assertIsNotNone(p.client)
+ self.assertEqual(p.setup_done, True)
+
+ def test_pktgen_dpdk_throughput_successful_no_sla(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60, 'number_of_ports': 10},
+ }
+
+ result = {}
+
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+
+ p.server = mock_ssh.SSH()
+ p.client = mock_ssh.SSH()
+
+ mock_dpdk_result = mock.Mock()
+ mock_dpdk_result.return_value = 149300
+ p._dpdk_get_result = mock_dpdk_result
+
+ sample_output = '{"packets_per_second": 9753, "errors": 0, \
+ "packets_sent": 149776, "flows": 110}'
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+
+ p.run(result)
+ expected_result = jsonutils.loads(sample_output)
+ expected_result["packets_received"] = 149300
+ expected_result["packetsize"] = 60
+ self.assertEqual(result, expected_result)
+
+ def test_pktgen_dpdk_throughput_successful_sla(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60, 'number_of_ports': 10},
+ 'sla': {'max_ppm': 10000}
+ }
+ result = {}
+
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+
+ p.server = mock_ssh.SSH()
+ p.client = mock_ssh.SSH()
+
+ mock_dpdk_result = mock.Mock()
+ mock_dpdk_result.return_value = 149300
+ p._dpdk_get_result = mock_dpdk_result
+
+ sample_output = '{"packets_per_second": 9753, "errors": 0, \
+ "packets_sent": 149776, "flows": 110}'
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+
+ p.run(result)
+ expected_result = jsonutils.loads(sample_output)
+ expected_result["packets_received"] = 149300
+ expected_result["packetsize"] = 60
+ self.assertEqual(result, expected_result)
+
+ def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60, 'number_of_ports': 10},
+ 'sla': {'max_ppm': 1000}
+ }
+ result = {}
+
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+
+ p.server = mock_ssh.SSH()
+ p.client = mock_ssh.SSH()
+
+ mock_dpdk_result = mock.Mock()
+ mock_dpdk_result.return_value = 149300
+ p._dpdk_get_result = mock_dpdk_result
+
+ sample_output = '{"packets_per_second": 9753, "errors": 0, \
+ "packets_sent": 149776, "flows": 110}'
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ self.assertRaises(AssertionError, p.run, result)
+
+ def test_pktgen_dpdk_throughput_unsuccessful_script_error(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60, 'number_of_ports': 10},
+ 'sla': {'max_ppm': 1000}
+ }
+ result = {}
+
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+
+ p.server = mock_ssh.SSH()
+ p.client = mock_ssh.SSH()
+
+ mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
+ self.assertRaises(RuntimeError, p.run, result)
+
+ def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60},
+ }
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+ p.server = mock_ssh.SSH()
+
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+
+ p._is_dpdk_setup("server")
+
+ mock_ssh.SSH().execute.assert_called_with(
+ "ip a | grep eth1 2>/dev/null")
+
+ def test_pktgen_dpdk_throughput_dpdk_setup(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60},
+ }
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+ p.server = mock_ssh.SSH()
+ p.client = mock_ssh.SSH()
+
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+
+ p.dpdk_setup()
+
+ self.assertEqual(p.dpdk_setup_done, True)
+
+ def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock_ssh):
+ args = {
+ 'options': {'packetsize': 60},
+ }
+ p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
+ p.server = mock_ssh.SSH()
+ p.client = mock_ssh.SSH()
+
+ mock_ssh.SSH().execute.return_value = (0, '10000', '')
+
+ p._dpdk_get_result()
+
+ mock_ssh.SSH().execute.assert_called_with(
+ "sudo /dpdk/destdir/bin/dpdk-procinfo -- --stats-reset > /dev/null 2>&1")
+
+def main():
+ unittest.main()
+
+if __name__ == '__main__':
+ main()
diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
index f57ca843a..ce8a7f497 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
@@ -12,8 +12,10 @@ import logging
import time
import yardstick.ssh as ssh
+import yardstick.common.utils as utils
from yardstick.benchmark.scenarios import base
+
LOG = logging.getLogger(__name__)
@@ -65,29 +67,6 @@ class PktgenDPDKLatency(base.Scenario):
self.testpmd_args = ''
self.pktgen_args = []
- @staticmethod
- def get_port_mac(sshclient, port):
- cmd = "ifconfig |grep HWaddr |grep %s |awk '{print $5}' " % port
- LOG.debug("Executing command: %s", cmd)
- status, stdout, stderr = sshclient.execute(cmd)
-
- if status:
- raise RuntimeError(stderr)
- else:
- return stdout.rstrip()
-
- @staticmethod
- def get_port_ip(sshclient, port):
- cmd = "ifconfig %s |grep 'inet addr' |awk '{print $2}' \
- |cut -d ':' -f2 " % port
- LOG.debug("Executing command: %s", cmd)
- status, stdout, stderr = sshclient.execute(cmd)
-
- if status:
- raise RuntimeError(stderr)
- else:
- return stdout.rstrip()
-
def run(self, result):
"""execute the benchmark"""
@@ -95,13 +74,13 @@ class PktgenDPDKLatency(base.Scenario):
self.setup()
if not self.testpmd_args:
- self.testpmd_args = self.get_port_mac(self.client, 'eth2')
+ self.testpmd_args = utils.get_port_mac(self.client, 'eth2')
if not self.pktgen_args:
- server_rev_mac = self.get_port_mac(self.server, 'eth1')
- server_send_mac = self.get_port_mac(self.server, 'eth2')
- client_src_ip = self.get_port_ip(self.client, 'eth1')
- client_dst_ip = self.get_port_ip(self.client, 'eth2')
+ server_rev_mac = utils.get_port_mac(self.server, 'eth1')
+ server_send_mac = utils.get_port_mac(self.server, 'eth2')
+ client_src_ip = utils.get_port_ip(self.client, 'eth1')
+ client_dst_ip = utils.get_port_ip(self.client, 'eth2')
self.pktgen_args = [client_src_ip, client_dst_ip,
server_rev_mac, server_send_mac]
diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk_benchmark.bash b/yardstick/benchmark/scenarios/networking/pktgen_dpdk_benchmark.bash
new file mode 100644
index 000000000..cb028f005
--- /dev/null
+++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk_benchmark.bash
@@ -0,0 +1,196 @@
+##############################################################################
+# Copyright (c) 2017 Nokia 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
+##############################################################################
+#!/bin/sh
+
+set -e
+
+# Commandline arguments
+SRC_IP=$1 # source IP address
+DST_IP=$2 # destination IP address
+DST_MAC=$3 # destination MAC address
+NUM_PORTS=$4 # number of source ports
+PKT_SIZE=$5 # packet size
+DURATION=$6 # test duration (seconds)
+RATE=$7 # packet rate in percentage for 10G NIC
+
+MAX_RATE=100
+
+# Configuration
+UDP_SRC_MIN=1000 # UDP source port min
+UDP_SRC_MAX=$(( UDP_SRC_MIN + NUM_PORTS - 1 )) # UDP source port max
+UDP_DST_MIN=1000 # UDP destination port min
+UDP_DST_MAX=$(( UDP_DST_MIN + NUM_PORTS )) # UDP destination port max
+
+load_modules()
+{
+ if ! lsmod | grep "uio" &> /dev/null; then
+ modprobe uio
+ fi
+
+ if ! lsmod | grep "igb_uio" &> /dev/null; then
+ insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
+ fi
+
+ if ! lsmod | grep "rte_kni" &> /dev/null; then
+ insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
+ fi
+}
+
+change_permissions()
+{
+ chmod 777 /sys/bus/pci/drivers/virtio-pci/*
+ chmod 777 /sys/bus/pci/drivers/igb_uio/*
+}
+
+add_interface_to_dpdk(){
+ interfaces=$(lspci |grep Eth |tail -n +2 |awk '{print $1}')
+ /dpdk/usertools/dpdk-devbind.py --bind=igb_uio $interfaces &> /dev/null
+}
+
+create_pktgen_config_lua()
+{
+ lua_file="/home/ubuntu/pktgen_tput.lua"
+ touch $lua_file
+ chmod 777 $lua_file
+
+ cat << EOF > "/home/ubuntu/pktgen_tput.lua"
+package.path = package.path ..";?.lua;test/?.lua;app/?.lua;"
+
+ -- require "Pktgen";
+function pktgen_config()
+
+ pktgen.screen("off");
+
+ pktgen.set_ipaddr("0", "src", "$SRC_IP/24");
+ pktgen.set_ipaddr("0", "dst", "$DST_IP");
+ pktgen.set_mac("0", "$DST_MAC");
+ pktgen.set("all", "sport", $UDP_SRC_MIN);
+ pktgen.set("all", "dport", $UDP_DST_MIN);
+ pktgen.set("all", "size", $PKT_SIZE);
+ pktgen.set("all", "rate", $RATE);
+ pktgen.set_type("all", "ipv4");
+ pktgen.set_proto("all", "udp");
+
+ pktgen.src_ip("0", "start", "$SRC_IP");
+ pktgen.src_ip("0", "inc", "0.0.0.0");
+ pktgen.src_ip("0", "min", "$SRC_IP");
+ pktgen.src_ip("0", "max", "$SRC_IP");
+ pktgen.dst_ip("0", "start", "$DST_IP");
+ pktgen.dst_ip("0", "inc", "0.0.0.0");
+ pktgen.dst_ip("0", "min", "$DST_IP");
+ pktgen.dst_ip("0", "max", "$DST_IP");
+
+ pktgen.dst_mac("0", "start", "$DST_MAC");
+
+ pktgen.src_port("all", "start", $UDP_SRC_MIN);
+ pktgen.src_port("all", "inc", 1);
+ pktgen.src_port("all", "min", $UDP_SRC_MIN);
+ pktgen.src_port("all", "max", $UDP_SRC_MAX);
+ pktgen.dst_port("all", "start", $UDP_DST_MIN);
+ pktgen.dst_port("all", "inc", 1);
+ pktgen.dst_port("all", "min", $UDP_DST_MIN);
+ pktgen.dst_port("all", "max", $UDP_DST_MAX);
+
+ pktgen.pkt_size("all", "start", $PKT_SIZE);
+ pktgen.pkt_size("all", "inc",0);
+ pktgen.pkt_size("all", "min", $PKT_SIZE);
+ pktgen.pkt_size("all", "max", $PKT_SIZE);
+ pktgen.ip_proto("all", "udp");
+ pktgen.set_range("all", "on");
+
+ pktgen.start("all");
+ pktgen.sleep($DURATION)
+ pktgen.stop("all");
+ pktgen.sleep(1)
+
+ prints("opackets", pktgen.portStats("all", "port")[0].opackets);
+ prints("oerrors", pktgen.portStats("all", "port")[0].oerrors);
+
+ end
+
+pktgen_config()
+EOF
+}
+
+
+create_expect_file()
+{
+ expect_file="/home/ubuntu/pktgen_tput.exp"
+ touch $expect_file
+ chmod 777 $expect_file
+
+ cat << 'EOF' > "/home/ubuntu/pktgen_tput.exp"
+#!/usr/bin/expect
+
+set blacklist [lindex $argv 0]
+spawn ./app/app/x86_64-native-linuxapp-gcc/pktgen -c 0x0f -n 4 -b $blacklist -- -P -m "{2-3}.0" -f /home/ubuntu/pktgen_tput.lua
+expect "Pktgen"
+send "on\n"
+expect "Pktgen"
+send "page main\n"
+expect "Pktgen"
+sleep 1
+send "quit\n"
+expect "#"
+
+EOF
+
+}
+
+run_pktgen()
+{
+ blacklist=$(lspci |grep Eth |awk '{print $1}'|head -1)
+ cd /pktgen-dpdk
+ result_log="/home/ubuntu/result.log"
+ touch $result_log
+ sudo expect /home/ubuntu/pktgen_tput.exp $blacklist > $result_log 2>&1
+}
+
+# write the result to stdout in json format
+output_json()
+{
+ sent=0
+ result_pps=0
+ errors=0
+
+ sent=$(cat ~/result.log -vT | grep "Tx Pkts" | tail -1 | awk '{match($0,/\[18;20H +[0-9]+/)} {print substr($0,RSTART,RLENGTH)}' | awk '{if ($2 != 0) print $2}')
+ result_pps=$(( sent / DURATION ))
+ errors=$(cat ~/result.log -vT |grep "Errors Rx/Tx" | tail -1 | awk '{match($0,/\[16;20H +[0-9]+\/+[0-9]+/)} {print substr($0,RSTART,RLENGTH)}' | cut -d '/' -f2)
+
+ flows=$(( NUM_PORTS * (NUM_PORTS + 1) ))
+
+ echo '{ "packets_sent"':${sent} , '"packets_per_second"':${result_pps}, '"flows"':${flows}, '"errors"':${errors} '}'
+}
+
+main()
+{
+ if ip a | grep eth2 >/dev/null 2>&1; then
+ ip link set eth2 down
+ fi
+
+ if ip a | grep eth1 >/dev/null 2>&1; then
+ ip link set eth1 down
+ load_modules
+ change_permissions
+ add_interface_to_dpdk
+ fi
+
+ if [ $RATE -gt $MAX_RATE ]; then
+ RATE=$MAX_RATE
+ fi
+
+ create_pktgen_config_lua
+ create_expect_file
+
+ run_pktgen
+
+ output_json
+}
+
+main
diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk_throughput.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk_throughput.py
new file mode 100644
index 000000000..497e59ee8
--- /dev/null
+++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk_throughput.py
@@ -0,0 +1,226 @@
+##############################################################################
+# Copyright (c) 2017 Nokia 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
+##############################################################################
+from __future__ import absolute_import
+import pkg_resources
+import logging
+import json
+import time
+
+import yardstick.ssh as ssh
+import yardstick.common.utils as utils
+from yardstick.benchmark.scenarios import base
+
+LOG = logging.getLogger(__name__)
+
+
+class PktgenDPDK(base.Scenario):
+ """Execute pktgen-dpdk on one vm and execute testpmd on the other vm
+ """
+ __scenario_type__ = "PktgenDPDK"
+
+ PKTGEN_DPDK_SCRIPT = 'pktgen_dpdk_benchmark.bash'
+ TESTPMD_SCRIPT = 'testpmd_rev.bash'
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.source_ipaddr = [None] * 2
+ self.source_ipaddr[0] = \
+ self.context_cfg["host"].get("ipaddr", '127.0.0.1')
+ self.target_ipaddr = [None] * 2
+ self.target_ipaddr[0] = \
+ self.context_cfg["target"].get("ipaddr", '127.0.0.1')
+ self.target_macaddr = [None] * 2
+ self.setup_done = False
+ self.dpdk_setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.pktgen_dpdk_script = pkg_resources.resource_filename(
+ 'yardstick.benchmark.scenarios.networking',
+ PktgenDPDK.PKTGEN_DPDK_SCRIPT)
+ self.testpmd_script = pkg_resources.resource_filename(
+ 'yardstick.benchmark.scenarios.networking',
+ PktgenDPDK.TESTPMD_SCRIPT)
+
+ host = self.context_cfg['host']
+ host_user = host.get('user', 'ubuntu')
+ host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT)
+ host_ip = host.get('ip', None)
+ host_key_filename = host.get('key_filename', '~/.ssh/id_rsa')
+ target = self.context_cfg['target']
+ target_user = target.get('user', 'ubuntu')
+ target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT)
+ target_ip = target.get('ip', None)
+ target_key_filename = target.get('key_filename', '~/.ssh/id_rsa')
+
+ LOG.info("user:%s, target:%s", target_user, target_ip)
+ self.server = ssh.SSH(target_user, target_ip,
+ key_filename=target_key_filename,
+ port=target_ssh_port)
+ self.server.wait(timeout=600)
+
+ # copy script to host
+ self.server._put_file_shell(self.testpmd_script, '~/testpmd_rev.sh')
+
+ LOG.info("user:%s, host:%s", host_user, host_ip)
+ self.client = ssh.SSH(host_user, host_ip,
+ key_filename=host_key_filename,
+ port=host_ssh_port)
+ self.client.wait(timeout=600)
+
+ # copy script to host
+ self.client._put_file_shell(self.pktgen_dpdk_script,
+ '~/pktgen_dpdk.sh')
+
+ self.setup_done = True
+
+ def dpdk_setup(self):
+ """dpdk setup"""
+
+ # disable Address Space Layout Randomization (ASLR)
+ cmd = "echo 0 | sudo tee /proc/sys/kernel/randomize_va_space"
+ self.server.send_command(cmd)
+ self.client.send_command(cmd)
+
+ if not self._is_dpdk_setup("client"):
+ cmd = "sudo ifup eth1"
+ LOG.debug("Executing command: %s", cmd)
+ self.client.send_command(cmd)
+ time.sleep(1)
+ self.source_ipaddr[1] = utils.get_port_ip(self.client, 'eth1')
+ self.client.run("tee ~/.pktgen-dpdk.ipaddr.eth1 > /dev/null",
+ stdin=self.source_ipaddr[1])
+ else:
+ cmd = "cat ~/.pktgen-dpdk.ipaddr.eth1"
+ status, stdout, stderr = self.client.execute(cmd)
+ if status:
+ raise RuntimeError(stderr)
+ self.source_ipaddr[1] = stdout
+
+ if not self._is_dpdk_setup("server"):
+ cmd = "sudo ifup eth1"
+ LOG.debug("Executing command: %s", cmd)
+ self.server.send_command(cmd)
+ time.sleep(1)
+ self.target_ipaddr[1] = utils.get_port_ip(self.server, 'eth1')
+ self.target_macaddr[1] = utils.get_port_mac(self.server, 'eth1')
+ self.server.run("tee ~/.testpmd.ipaddr.eth1 > /dev/null",
+ stdin=self.target_ipaddr[1])
+ self.server.run("tee ~/.testpmd.macaddr.eth1 > /dev/null",
+ stdin=self.target_macaddr[1])
+
+ cmd = "screen sudo -E bash ~/testpmd_rev.sh"
+ LOG.debug("Executing command: %s", cmd)
+ self.server.send_command(cmd)
+
+ time.sleep(1)
+ else:
+ cmd = "cat ~/.testpmd.ipaddr.eth1"
+ status, stdout, stderr = self.server.execute(cmd)
+ if status:
+ raise RuntimeError(stderr)
+ self.target_ipaddr[1] = stdout
+
+ cmd = "cat ~/.testpmd.macaddr.eth1"
+ status, stdout, stderr = self.server.execute(cmd)
+ if status:
+ raise RuntimeError(stderr)
+ self.target_macaddr[1] = stdout
+
+ self.dpdk_setup_done = True
+
+ def _is_dpdk_setup(self, host):
+ """Is dpdk already setup in the host?"""
+ is_run = True
+ cmd = "ip a | grep eth1 2>/dev/null"
+ LOG.debug("Executing command: %s in %s", cmd, host)
+ if "server" in host:
+ status, stdout, stderr = self.server.execute(cmd)
+ if stdout:
+ is_run = False
+ else:
+ status, stdout, stderr = self.client.execute(cmd)
+ if stdout:
+ is_run = False
+
+ return is_run
+
+ def _dpdk_get_result(self):
+ """Get packet statistics from server"""
+ cmd = "sudo /dpdk/destdir/bin/dpdk-procinfo -- --stats 2>/dev/null | \
+ awk '$1 ~ /RX-packets/' | cut -d ':' -f2 | cut -d ' ' -f2 | \
+ head -n 1"
+ LOG.debug("Executing command: %s", cmd)
+ status, stdout, stderr = self.server.execute(cmd)
+ if status:
+ raise RuntimeError(stderr)
+ received = int(stdout)
+
+ cmd = "sudo /dpdk/destdir/bin/dpdk-procinfo -- --stats-reset" \
+ " > /dev/null 2>&1"
+ self.server.execute(cmd)
+ time.sleep(1)
+ self.server.execute(cmd)
+ return received
+
+ def run(self, result):
+ """execute the benchmark"""
+
+ if not self.setup_done:
+ self.setup()
+
+ if not self.dpdk_setup_done:
+ self.dpdk_setup()
+
+ options = self.scenario_cfg['options']
+ packetsize = options.get("packetsize", 60)
+ rate = options.get("rate", 100)
+ self.number_of_ports = options.get("number_of_ports", 10)
+ # if run by a duration runner
+ duration_time = self.scenario_cfg["runner"].get("duration", None) \
+ if "runner" in self.scenario_cfg else None
+ # if run by an arithmetic runner
+ arithmetic_time = options.get("duration", None)
+
+ if duration_time:
+ duration = duration_time
+ elif arithmetic_time:
+ duration = arithmetic_time
+ else:
+ duration = 20
+
+ cmd = "sudo bash pktgen_dpdk.sh %s %s %s %s %s %s %s" \
+ % (self.source_ipaddr[1],
+ self.target_ipaddr[1], self.target_macaddr[1],
+ self.number_of_ports, packetsize, duration, rate)
+
+ LOG.debug("Executing command: %s", cmd)
+ status, stdout, stderr = self.client.execute(cmd)
+
+ if status:
+ raise RuntimeError(stderr)
+
+ result.update(json.loads(stdout))
+
+ result['packets_received'] = self._dpdk_get_result()
+
+ result['packetsize'] = packetsize
+
+ if "sla" in self.scenario_cfg:
+ sent = result['packets_sent']
+ received = result['packets_received']
+ ppm = 1000000 * (sent - received) / sent
+ # Added by Jing
+ ppm += (sent - received) % sent > 0
+ LOG.debug("Lost packets %d - Lost ppm %d", (sent - received), ppm)
+ sla_max_ppm = int(self.scenario_cfg["sla"]["max_ppm"])
+ assert ppm <= sla_max_ppm, "ppm %d > sla_max_ppm %d; " \
+ % (ppm, sla_max_ppm)
diff --git a/yardstick/benchmark/scenarios/networking/testpmd_rev.bash b/yardstick/benchmark/scenarios/networking/testpmd_rev.bash
new file mode 100644
index 000000000..72a8fde3a
--- /dev/null
+++ b/yardstick/benchmark/scenarios/networking/testpmd_rev.bash
@@ -0,0 +1,69 @@
+##############################################################################
+# Copyright (c) 2017 Nokia 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
+##############################################################################
+#!/bin/sh
+
+set -e
+
+# Commandline arguments
+NUM_TRAFFIC_PORTS=${1:-1}
+
+load_modules()
+{
+ if ! lsmod | grep "uio" &> /dev/null; then
+ modprobe uio
+ fi
+
+ if ! lsmod | grep "igb_uio" &> /dev/null; then
+ insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
+ fi
+
+ if ! lsmod | grep "rte_kni" &> /dev/null; then
+ insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
+ fi
+}
+
+change_permissions()
+{
+ chmod 777 /sys/bus/pci/drivers/virtio-pci/*
+ chmod 777 /sys/bus/pci/drivers/igb_uio/*
+}
+
+add_interface_to_dpdk(){
+ interfaces=$(lspci |grep Eth |tail -n +2 |awk '{print $1}')
+ /dpdk/usertools/dpdk-devbind.py --bind=igb_uio $interfaces &> /dev/null
+}
+
+run_testpmd()
+{
+ blacklist=$(lspci |grep Eth |awk '{print $1}'|head -1)
+ cd /dpdk
+ if [ $NUM_TRAFFIC_PORTS -gt 1 ]; then
+ sudo ./destdir/bin/testpmd -c 0x3f -n 4 -b $blacklist -- -a --nb-cores=4 --coremask=0x3c --rxq=2 --rxd=4096 --rss-udp --txq=2 --forward-mode=rxonly
+ else
+ sudo ./destdir/bin/testpmd -c 0x0f -n 4 -b $blacklist -- -a --nb-cores=2 --coremask=0x0c --rxq=2 --rxd=4096 --rss-udp --txq=2 --forward-mode=rxonly
+ fi
+}
+
+main()
+{
+ if ip a | grep eth2 >/dev/null 2>&1; then
+ ip link set eth2 down
+ fi
+
+ if ip a | grep eth1 >/dev/null 2>&1; then
+ ip link set eth1 down
+ load_modules
+ change_permissions
+ add_interface_to_dpdk
+ fi
+
+ run_testpmd
+}
+
+main
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 7035f3374..f4def8533 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -167,3 +167,22 @@ def parse_ini_file(path):
s)} for s in parser.sections()})
return config
+
+
+def get_port_mac(sshclient, port):
+ cmd = "ifconfig |grep HWaddr |grep %s |awk '{print $5}' " % port
+ status, stdout, stderr = sshclient.execute(cmd)
+
+ if status:
+ raise RuntimeError(stderr)
+ return stdout.rstrip()
+
+
+def get_port_ip(sshclient, port):
+ cmd = "ifconfig %s |grep 'inet addr' |awk '{print $2}' " \
+ "|cut -d ':' -f2 " % port
+ status, stdout, stderr = sshclient.execute(cmd)
+
+ if status:
+ raise RuntimeError(stderr)
+ return stdout.rstrip()