test suite reviews and discussions
 help / color / mirror / Atom feed
From: "xu,gang" <gangx.xu@intel.com>
To: dts@dpdk.org
Cc: "xu,gang" <gangx.xu@intel.com>
Subject: [dts] [PATCH V2 1/2] add test suite vhost_pmd_xstats
Date: Wed, 28 Dec 2016 10:14:35 +0800	[thread overview]
Message-ID: <1482891276-18365-1-git-send-email-gangx.xu@intel.com> (raw)

Signed-off-by: xu,gang <gangx.xu@intel.com>
---
 tests/TestSuite_vhost_pmd_xstats.py | 251 ++++++++++++++++++++++++++++++++++++
 1 file changed, 251 insertions(+)
 create mode 100644 tests/TestSuite_vhost_pmd_xstats.py

diff --git a/tests/TestSuite_vhost_pmd_xstats.py b/tests/TestSuite_vhost_pmd_xstats.py
new file mode 100644
index 0000000..b8f2c83
--- /dev/null
+++ b/tests/TestSuite_vhost_pmd_xstats.py
@@ -0,0 +1,251 @@
+# 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
+# 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.
+
+vhost pmd xstats test suite.
+"""
+import os
+import dts
+import string
+import re
+import time
+import utils
+import datetime
+from scapy.utils import wrpcap, rdpcap
+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):
+
+    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.dmac = self.dut.get_mac_address(self.dut_ports[0]) 
+        self.virtio1_mac = "52:54:00:00:00:01"
+
+        # build sample app
+        out = 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", "#")
+
+    def set_up(self):
+        """ 
+        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", "#")
+
+    def vm_testpmd_start(self):
+        """
+        Start testpmd in vm
+        """
+        self.vm_testpmd = "./x86_64-native-linuxapp-gcc/app/testpmd -c 0x3 -n 4 -- -i --txqflags=0xf01"
+        if self.vm_dut is not None:
+            self.vm_dut.send_expect(self.vm_testpmd, "testpmd>", 60)
+            out = 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 = None
+        self.vm = QEMUKvm(self.dut, 'vm0', 'vhost_pmd_xstats')
+        vm_params = {}
+        vm_params['driver'] = 'vhost-user'
+        vm_params['opt_path'] = './vhost-net'
+        vm_params['opt_mac'] = self.virtio1_mac
+        self.vm.set_vm_device(**vm_params)
+        try:
+            self.vm_dut = 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))
+        return True
+
+    def scapy_send_packet(self, pktsize, dmac, num=1):
+        """
+        Send a packet to port
+        """
+        txport = self.tester.get_local_port(self.dut_ports[0])
+        self.txItf = self.tester.get_interface(txport)
+        pkt = Packet(pkt_type='UDP', pkt_len=pktsize)
+        pkt.config_layer('ether', {'dst': dmac,})
+        pkt.send_pkt(tx_port=self.txItf, count=num)
+
+    def send_verify(self, scope, mun):
+        """
+        according the scope to check results
+        """
+        out = self.dut.send_expect("show port xstats %s" % self.dut_ports[1], "testpmd>", 60)
+        packet = re.search("rx_%s_packets:\s*(\d*)" % scope, out)
+        sum_packet = packet.group(1)
+        self.verify(int(sum_packet) >= mun, "Insufficient the received 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=vhost-net,queues=1' -- -i --nb-cores=1" % (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) 
+        self.vm_tx_first_start()
+
+    def vhost_pmd_xstats_based(self):
+        """
+        Verify receiving and transmitting packets correctly in the Vhsot PMD xstats
+        """
+        self.prepare_start()
+        sizes = [64,65,128,256,513,1025]
+        scope = ''
+        for pktsize in sizes:
+            if pktsize == 64:
+                scope = 'size_64'
+            elif 65 <= pktsize <= 127:
+                scope = 'size_65_to_127'
+            elif 128 <= pktsize <= 255:
+                scope = 'size_128_to_255'
+            elif 256 <= pktsize <= 511:
+                scope = 'size_256_to_511'
+            elif 512 <= pktsize <= 1023:
+                scope = 'size_512_to_1023'
+            elif 1024 <= pktsize:
+                scope = 'size_1024_to_max'
+
+            self.scapy_send_packet(pktsize, self.dmac, 1000000)
+            self.send_verify(scope, 100)
+    
+    def test_vhost_pmd_xstats_based(self):
+        """
+        Verify receiving and transmitting packets correctly in the Vhsot PMD xstats
+        """
+        self.vhost_pmd_xstats_based()        
+    def test_vhost_pmd_xstats_based_types(self):
+        """
+        Verify different type of packets receiving and transmitting packets correctly in the Vhsot PMD xstats
+        """
+        self.prepare_start()
+        types = ['ff:ff:ff:ff:ff:ff','01:00:00:33:00:01']
+        scope = ''
+        for p in types:
+            if p == 'ff:ff:ff:ff:ff:ff':
+                scope = 'broadcast'
+                self.dmac = 'ff:ff:ff:ff:ff:ff'
+            elif p == '01:00:00:33:00:01':
+                scope = 'multicast'
+                self.dmac = '01:00:00:33:00:01'
+            self.scapy_send_packet(64, self.dmac, 1000000)
+            self.send_verify(scope, 100)
+           
+    def test_clear_vhost_pmd_xstats(self):
+        """
+        Verify clear Vhsot PMD xstats
+        """   
+        self.vhost_pmd_xstats_based() 
+        self.dut.send_expect("clear port xstats all", "testpmd>", 60)
+        out = self.dut.send_expect("show port xstats all", "testpmd>", 60)
+        size_packets = ['size_64','size_65_to_127','size_128_to_255','size_256_to_511','size_512_to_1023','size_1024_to_max',]
+        for size_packet in size_packets:
+            packet = re.search("rx_%s_packets:\s*(\d*)" % size_packet, out)
+            sum_packet = packet.group(1)
+            self.verify(int(sum_packet) >= 0, "Insufficient the received package")
+
+    def test_longlasting_vhost_pmd_xstats(self):
+        """
+        Verify Long lasting test for Vhsot PMD xstats 
+        Send packets for 30 minutes, check the Xstatsa still can work correctly
+        """
+        self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c %s -n %s --socket-mem 1024,0 --vdev 'net_vhost0,iface=vhost-net,queues=1' -- -i --nb-cores=1" % (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)
+        if self.vm_dut is not None:
+            out = self.vm_dut.send_expect("start", "testpmd>")
+        date_old = datetime.datetime.now()
+        date_new = date_old + datetime.timedelta(minutes=30)
+        while(1):
+            date_now = datetime.datetime.now()
+            self.scapy_send_packet(64, self.dmac, 1)
+            if date_now >= date_new:
+                break
+        out_0 = self.dut.send_expect("show port xstats %s" % self.dut_ports[0], "testpmd>", 60)
+        out_1 = self.dut.send_expect("show port xstats %s" % self.dut_ports[1], "testpmd>", 60)
+        out = self.dut.send_expect("show port stats all", "testpmd>", 60)
+        print out
+        print out_0
+        print out_1
+        rx_packet = re.search("rx_size_64_packets:\s*(\d*)" , out_1)
+        tx_packet = re.search("tx_good_packets:\s*(\d*)" , out_0)
+        tx_packets = tx_packet.group(1)
+        rx_packets = rx_packet.group(1)
+        print "tx_packets=%s"%tx_packets
+        print "rx_packets=%s"%rx_packets
+        self.verify(int(rx_packets) >= int(tx_packets), "Insufficient 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

             reply	other threads:[~2016-12-28  2:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-28  2:14 xu,gang [this message]
2016-12-28  2:14 ` [dts] [PATCH V2 2/2] add test plan vhost_pmd_xstats xu,gang
2016-12-28  2:42   ` Liu, Yong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482891276-18365-1-git-send-email-gangx.xu@intel.com \
    --to=gangx.xu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).