From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 51EE74CC5 for ; Wed, 4 Jan 2017 04:23:47 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 03 Jan 2017 19:23:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,458,1477983600"; d="scan'208";a="918677625" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 03 Jan 2017 19:23:46 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 3 Jan 2017 19:23:45 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Wed, 4 Jan 2017 11:23:41 +0800 From: "Liu, Yong" To: "Xu, GangX" , "dts@dpdk.org" CC: "Xu, GangX" Thread-Topic: [dts] [PATCH V1] add test suite vhost_pmd_xstats Thread-Index: AQHSYZl4lsAjoxkt7EyAH9+dvyemJaEnoc4A Date: Wed, 4 Jan 2017 03:23:40 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62D38A02@SHSMSX103.ccr.corp.intel.com> References: <1482991533-20910-1-git-send-email-gangx.xu@intel.com> In-Reply-To: <1482991533-20910-1-git-send-email-gangx.xu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] add test suite vhost_pmd_xstats 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: Wed, 04 Jan 2017 03:23:48 -0000 Gang, some comments below. BTW, please use pep8 check tool to verify code s= tyle before sent out your patches. -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of xu,gang Sent: Thursday, December 29, 2016 2:06 PM To: dts@dpdk.org Cc: Xu, GangX Subject: [dts] [PATCH V1] add test suite vhost_pmd_xstats Signed-off-by: xu,gang --- tests/TestSuite_vhost_pmd_xstats.py | 237 ++++++++++++++++++++++++++++++++= ++++ 1 file changed, 237 insertions(+) create mode 100644 tests/TestSuite_vhost_pmd_xstats.py diff --git a/tests/TestSuite_vhost_pmd_xstats.py b/tests/TestSuite_vhost_pm= d_xstats.py new file mode 100644 index 0000000..eabfc3a --- /dev/null +++ b/tests/TestSuite_vhost_pmd_xstats.py @@ -0,0 +1,237 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2016 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +DPDK Test suite. + +vhost pmd xstats test suite. +""" +import os +import string +import re +import time +import utils +import datetime +from scapy.utils import wrpcap, rdpcap These two functions not used in this suite. Please try to not include thir= d-party modules, framework will supply wrapper function for basic usage. +from test_case import TestCase +from exception import VerifyFailure +from settings import HEADER_SIZE +from etgen import IxiaPacketGenerator +from qemu_kvm import QEMUKvm +from packet import Packet, sniff_packets, load_sniff_packets + + +class TestVhostPmdXstats(TestCase, IxiaPacketGenerator): + No need to inherit " IxiaPacketGenerator" module, it used for change defaul= t packet generator function. =09 + def set_up_all(self): + """ + Run at the start of each test suite. + """ + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") + cores =3D self.dut.get_core_list("1S/4C/1T") + self.coremask =3D utils.create_mask(cores) + =20 + self.dmac =3D self.dut.get_mac_address(self.dut_ports[0])=20 + self.virtio1_mac =3D "52:54:00:00:00:01" + + # build sample app + out =3D self.dut.build_dpdk_apps("./examples/vhost") + self.verify("Error" not in out, "compilation error 1") + self.verify("No such file" not in out, "compilation error 2") + #stop vhost firewalld.service + self.dut.send_expect("systemctl stop firewalld.service", "#") It's not good to change host setting by ourselves. You can just verify fire= walld service status. If it's up, just raise warning and skip execution. + + def set_up(self): + """=20 + Run before each test case. + Launch vhost sample using default params + """ + self.dut.send_expect("rm -rf ./vhost.out", "#") + self.dut.send_expect("rm -rf ./vhost-net*", "#") + self.dut.send_expect("killall -s INT vhost-switch", "#") + self.dut.send_expect("killall -s INT qemu-system-x86_64", "#") Please do not kill all qemu process, others may use it for other usage. J= ust use self.vm.stop() to stop the virtual machine. Code look like unaligned here, please check again. + + def vm_testpmd_start(self): + """ + Start testpmd in vm + """ + self.vm_testpmd =3D "./x86_64-native-linuxapp-gcc/app/testpmd -c 0= x3 -n 4 -- -i --txqflags=3D0xf01" Target should not hard code to " x86_64-native-linuxapp-gcc", please use s= elf.target for replacement. + if self.vm_dut is not None: + self.vm_dut.send_expect(self.vm_testpmd, "testpmd>", 60) + out =3D self.vm_dut.send_expect("start", "testpmd>") + + def vm_tx_first_start(self): + if self.vm_dut is not None: + # Start tx_first + self.vm_dut.send_expect("set fwd mac", "testpmd>") + self.vm_dut.send_expect("start tx_first", "testpmd>") + + def start_onevm(self): + """ + Start One VM with one virtio device + """ + self.vm_dut =3D None + self.vm =3D QEMUKvm(self.dut, 'vm0', 'vhost_pmd_xstats') + vm_params =3D {} + vm_params['driver'] =3D 'vhost-user' + vm_params['opt_path'] =3D './vhost-net' + vm_params['opt_mac'] =3D self.virtio1_mac + self.vm.set_vm_device(**vm_params) + try: + self.vm_dut =3D self.vm.start() + if self.vm_dut is None: + raise Exception("Set up VM ENV failed") + except Exception as e: + print utils.RED("Failure for %s" % str(e)) Please use self.logger.error to log these error information.=20 + return True + + def scapy_send_packet(self, pktsize, dmac, num=3D1): + """ + Send a packet to port + """ + txport =3D self.tester.get_local_port(self.dut_ports[0]) + self.txItf =3D self.tester.get_interface(txport) + pkt =3D Packet(pkt_type=3D'UDP', pkt_len=3Dpktsize) + pkt.config_layer('ether', {'dst': dmac,}) + pkt.send_pkt(tx_port=3Dself.txItf, count=3Dnum) + + def send_verify(self, scope, mun): + """ + according the scope to check results + """ + out =3D self.dut.send_expect("show port xstats %s" % self.dut_port= s[1], "testpmd>", 60) + packet =3D re.search("rx_%s_packets:\s*(\d*)" % scope, out) + sum_packet =3D packet.group(1) + self.verify(int(sum_packet) >=3D mun, "Insufficient the received=20 + package") + + def prepare_start(self): + """ + prepare all of the conditions for start + """ + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c = %s -n %s --socket-mem 1024,0 --vdev 'net_vhost0,iface=3Dvhost-net,queues=3D= 1' -- -i --nb-cores=3D1" % (self.coremask,self.dut.get_memory_channels()), = "testpmd>", 60) + self.start_onevm() + self.vm_testpmd_start() + self.dut.send_expect("set fwd mac", "testpmd>", 60) + self.dut.send_expect("start tx_first", "testpmd>", 60)=20 + self.vm_tx_first_start() + + def test_based_size(self): + """ + Verify receiving and transmitting packets correctly in the Vhsot P= MD xstats + """ + self.prepare_start() + sizes =3D [64,65,128,256,513,1025] + scope =3D '' + for pktsize in sizes: + if pktsize =3D=3D 64: + scope =3D 'size_64' + elif 65 <=3D pktsize <=3D 127: + scope =3D 'size_65_to_127' + elif 128 <=3D pktsize <=3D 255: + scope =3D 'size_128_to_255' + elif 256 <=3D pktsize <=3D 511: + scope =3D 'size_256_to_511' + elif 512 <=3D pktsize <=3D 1023: + scope =3D 'size_512_to_1023' + elif 1024 <=3D pktsize: + scope =3D 'size_1024_to_max' + + self.scapy_send_packet(pktsize, self.dmac, 1000000) + self.send_verify(scope, 1000000) + self.clear_port_xstats(scope) Need space line here.=20 + def clear_port_xstats(self,scope):=20 + + self.dut.send_expect("clear port xstats all", "testpmd>", 60) + out =3D self.dut.send_expect("show port xstats %s" % self.dut_port= s[1], "testpmd>", 60) + print out + packet =3D re.search("rx_%s_packets:\s*(\d*)" % scope, out) + sum_packet =3D packet.group(1) + self.verify(int(sum_packet) =3D=3D 0, "Insufficient the received=20 + package") +=20 + def test_based_types(self): + """ + Verify different type of packets receiving and transmitting packet= s correctly in the Vhsot PMD xstats + """ + self.prepare_start() + types =3D ['ff:ff:ff:ff:ff:ff','01:00:00:33:00:01'] + scope =3D '' + for p in types: + if p =3D=3D 'ff:ff:ff:ff:ff:ff': + scope =3D 'broadcast' + self.dmac =3D 'ff:ff:ff:ff:ff:ff' + elif p =3D=3D '01:00:00:33:00:01': + scope =3D 'multicast' + self.dmac =3D '01:00:00:33:00:01' + self.scapy_send_packet(64, self.dmac, 1000000) + self.send_verify(scope, 1000000) + self.clear_port_xstats(scope) + =20 + def test_stability(self): + """ + Verify stability case with multiple queues for Vhsot PMD xstats=20 + Send packets for 30 minutes, check the Xstatsa still can work corr= ectly + """ + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c = %s -n %s --socket-mem 1024,0 --vdev 'net_vhost0,iface=3Dvhost-net,queues=3D= 1' -- -i --nb-cores=3D1" % (self.coremask,self.dut.get_memory_channels()), = "testpmd>", 60) Same comment as previous, please use self.target replace of x86_64-native-l= inuxapp-gcc. + self.start_onevm() + self.vm_testpmd_start() + self.dut.send_expect("set fwd mac", "testpmd>", 60) + self.dut.send_expect("start tx_first", "testpmd>", 60) + if self.vm_dut is not None: + out =3D self.vm_dut.send_expect("start", "testpmd>") + date_old =3D datetime.datetime.now() + date_new =3D date_old + datetime.timedelta(minutes=3D30) + while(1): + date_now =3D datetime.datetime.now() + self.scapy_send_packet(64, self.dmac, 1) + if date_now >=3D date_new: + break + out_0 =3D self.dut.send_expect("show port xstats %s" % self.dut_po= rts[0], "testpmd>", 60) + out_1 =3D self.dut.send_expect("show port xstats %s" % self.dut_po= rts[1], "testpmd>", 60) + rx_packet =3D re.search("rx_size_64_packets:\s*(\d*)" , out_1) + tx_packet =3D re.search("tx_good_packets:\s*(\d*)" , out_0) + tx_packets =3D tx_packet.group(1) + rx_packets =3D rx_packet.group(1) + =20 + self.verify(int(rx_packets) <=3D int(tx_packets), "Insufficient=20 + the received package") + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.kill_all() + time.sleep(2) + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 1.9.3