From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 40475374E for ; Mon, 20 Feb 2017 10:07:13 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2017 01:07:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,185,1484035200"; d="scan'208";a="1113078633" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by fmsmga001.fm.intel.com with ESMTP; 20 Feb 2017 01:07:12 -0800 From: "xu,gang" To: dts@dpdk.org Cc: "xu,gang" Date: Mon, 20 Feb 2017 17:08:18 +0800 Message-Id: <1487581699-30545-1-git-send-email-gangx.xu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH V1] add test suite l2fwd_jobstats X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Feb 2017 09:07:14 -0000 Signed-off-by: xu,gang --- tests/TestSuite_l2fwd_jobstats.py | 201 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 tests/TestSuite_l2fwd_jobstats.py diff --git a/tests/TestSuite_l2fwd_jobstats.py b/tests/TestSuite_l2fwd_jobstats.py new file mode 100644 index 0000000..858b710 --- /dev/null +++ b/tests/TestSuite_l2fwd_jobstats.py @@ -0,0 +1,201 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2017 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +""" +DPDK Test suite. +Test l2fwd-jobstats +""" + +import string +import time +import re +import utils +from test_case import TestCase +from qemu_kvm import QEMUKvm +from packet import Packet, sniff_packets, load_sniff_packets + + +class TestL2fwdJobstats(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + """ + + self.dut_ports = self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >= 2, "Insufficient ports") + cores = self.dut.get_core_list("1S/4C/1T") + self.coremask = utils.create_mask(cores) + self.portmask = utils.create_mask(self.dut_ports) + self.path = "./examples/l2fwd-jobstats/build/l2fwd-jobstats" + + self.tester_tx_port = self.tester.get_local_port(self.dut_ports[0]) + self.tester_tx_pci = self.tester.ports_info[self.tester_tx_port]['pci'] + port = self.tester.ports_info[self.tester_tx_port]['port'] + self.tester_port_driver = port.get_nic_driver() + self.intf = port.get_interface_name() + + # build sample app + out = self.dut.build_dpdk_apps("./examples/l2fwd-jobstats") + self.verify("Error" not in out, "compilation error 1") + self.verify("No such file" not in out, "compilation error 2") + + def set_up(self): + """ + Run before each test case. + """ + pass + + def generate_pcap_pkt(self, dst, load, pktname='flow.pcap'): + """ + generate pcap pkt + """ + context = '[Ether(dst="%s")/IP()/Raw(load=%s)]' % (dst, load) + self.session_secondary.send_expect('scapy', '>>> ', 10) + self.session_secondary.send_expect( + 'wrpcap("%s", %s)' % (pktname, context), '>>> ', 10) + self.session_secondary.send_expect('quit()', '#', 10) + + def pktgen_prerequisites(self): + """ + igb_uio.ko should be put in + have enough hugetpages + bind port + before you using pktgen + """ + self.tester.send_expect("modprobe uio", "#", 70) + out = self.tester.send_expect("lsmod | grep igb_uio", "#") + if "igb_uio" not in out: + self.tester.send_expect("rmmod -f igb_uio", "#", 70) + self.tester.send_expect( + "insmod ~/dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko", "#", 70) + out = self.tester.send_expect("lsmod | grep igb_uio", "#") + self.verify("igb_uio" in out, + "No file igb_uio.ko, please add it in ~") + total_huge_pages = self.tester.get_total_huge_pages() + if total_huge_pages == 0: + self.tester.mount_huge_pages() + self.tester.send_expect( + "./dpdk_nic_bind.py --bind=igb_uio %s" % self.tester_tx_pci, "#") + + def start_pktgen(self, pktname='flow.pcap'): + """ + start pktgen with pcap file + """ + self.session_secondary.send_expect( + "tar xvf ./dep/tgen.tgz -C ~", '#', 20) + self.session_secondary.send_expect( + "./pktgen -c 0xf -n 2 --proc-type auto -- -P -T -m '1.0' -s 0:%s" % pktname, "", 100) + + def set_parameter(self, rate, count): + """ + start pgtgen with send package's rate and count + """ + self.session_secondary.send_expect("set 0 rate %s" % rate, "", 20) + self.session_secondary.send_expect("set 0 count %d" % count, "", 20) + self.session_secondary.send_expect("start all", "", 20) + + def test_stability_rate(self): + """ + Verify l2fwd_jobstats rx package stability on different rate + """ + cmd = self.path + " -c %s -n %d -- -q 8 -p %s -l" % ( + self.coremask, self.dut.get_memory_channels(), self.portmask) + self.dut.send_expect(cmd, "Port statistics", 60) + out = self.dut.get_session_output(timeout=1) + total_sent = re.search("Total packets sent:\s*(\d*)", out) + total_received = re.search("Total packets received:\s*(\d*)", out) + total_dropped = re.search("Total packets dropped:\s*(\d*)", out) + pack_sent = total_sent.group(1) + pack_received = total_received.group(1) + pack_dropped = total_dropped.group(1) + self.verify(int(pack_sent) == int(pack_received) == int( + pack_dropped) == 0, "Error: get wrong package") + + self.pktgen_prerequisites() + self.session_secondary = self.tester.create_session( + name='pktgen_session') + dst = self.dut.ports_info[self.dut_ports[0]]['mac'] + load = "'X'*46" + self.generate_pcap_pkt(dst, load) + self.start_pktgen() + total = [] + rates = [10, 20, 30, 40, 50, 60, 70, 80, 90] + for rate in rates: + self.set_parameter(rate, 1000000000) + put = self.dut.get_session_output(timeout=60) + pkt_rare = re.findall(r"management\s.*\s(\d*.\d*)%", put) + pkt_received = re.findall("Total packets received:\s*(\d*)", put) + total.append(float(max(pkt_rare))) + + self.verify(sorted(total) == total, "Error: %s rate abnormal" % total) + + def test_stability_rx(self): + """ + Verify l2fwd_jobstats rx package stability + """ + cmd = self.path + " -c %s -n %d -- -q 8 -p %s -l" % ( + self.coremask, self.dut.get_memory_channels(), self.portmask) + self.dut.send_expect(cmd, "Port statistics", 60) + self.scapy_send_packet(100) + out = self.dut.get_session_output(timeout=60) + total_received = re.findall("Total packets received:\s*(\d*)", out) + + self.verify(int(max(total_received)) == 100, + "Error: get only %s not 1000000" % int(max(total_received))) + + def scapy_send_packet(self, num=1): + """ + Send a packet to port + """ + self.dmac = self.dut.get_mac_address(self.dut_ports[0]) + txport = self.tester.get_local_port(self.dut_ports[0]) + self.txItf = self.tester.get_interface(txport) + pkt = Packet(pkt_type='UDP') + pkt.config_layer('ether', {'dst': self.dmac, }) + pkt.send_pkt(tx_port=self.txItf, count=num) + + def tear_down(self): + """ + Run after each test case. + """ + self.tester.send_expect("./dpdk_nic_bind.py --bind=%s %s" % + (self.tester_port_driver, self.tester_tx_pci), "#") + self.tester.send_expect("ifconfig %s up" % self.intf, "#") + self.dut.kill_all() + time.sleep(2) + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 1.9.3