test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] add test suite vf kernel
@ 2017-03-13  8:52 xu,gang
  2017-03-14  3:02 ` Liu, Yong
  0 siblings, 1 reply; 2+ messages in thread
From: xu,gang @ 2017-03-13  8:52 UTC (permalink / raw)
  To: dts; +Cc: xu,gang

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

diff --git a/tests/TestSuite_vf_kernel.py b/tests/TestSuite_vf_kernel.py
new file mode 100644
index 0000000..444ffbf
--- /dev/null
+++ b/tests/TestSuite_vf_kernel.py
@@ -0,0 +1,590 @@
+# 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 VF kernel
+"""
+
+import utils
+import string
+import time
+import re
+import random
+import threading
+from test_case import TestCase
+from qemu_kvm import QEMUKvm
+from pmd_output import PmdOutput
+from packet import Packet, sniff_packets, load_sniff_packets
+
+
+class TestVfKernel(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) >= 1, "Insufficient ports")
+        self.cores = self.dut.get_core_list("1S/4C/1T")
+        self.coremask = utils.create_mask(self.cores)
+
+        self.dmac = self.dut.get_mac_address(self.dut_ports[0])
+        txport = self.tester.get_local_port(self.dut_ports[0])
+        self.tester_intf = self.tester.get_interface(txport)
+
+        self.intf = self.dut.ports_info[self.dut_ports[0]]['intf']
+        self.pci = self.dut.ports_info[self.dut_ports[0]]['pci'].split(':')
+
+        self.IXGBE = '3.15.1-k'
+        self.IXGBEVF = '2.11.3-k'
+        self.IXGBE_FIRMWARE = '0x61bf0001'
+
+        self.I40E = '2.0.15'
+        self.I40EVF = '2.0.13'
+        self.I40E_FIRMWARE = '5.50 0x80002c0c 1.3908.0'
+        
+        self.verify_version()
+        self.dut.send_expect("killall qemu-system-x86_64", "#", 10)
+        self.setup_vm_env()
+        self.get_vm_intf()
+
+        self.vm0_mac = self.vm0_dut.get_mac_address(0)
+        self.vm1_mac = self.vm1_dut.get_mac_address(0)
+
+    def set_up(self):
+        """
+        Run before each test case.
+        """
+        self.dut.kill_all()
+        time.sleep(2)
+        pass
+
+    def verify_version(self):
+        """
+        verify the dut version
+        """
+        self.dut.restore_interfaces_linux()
+        if self.kdriver == "ixgbe":
+            out = self.dut.send_expect("ethtool -i %s" % self.intf, "# ", 60)
+            self.verify(self.IXGBE in out, "%s does not ixgbe %s test" %
+                        (self.IXGBE, self.nic))
+            self.verify(self.IXGBE_FIRMWARE in out, "%s does not firmware %s test" % (
+                self.IXGBE_FIRMWARE, self.nic))
+            put = self.dut.send_expect("modinfo %svf" % self.kdriver, "# ", 60)
+            self.verify(self.IXGBEVF in put, "%s does not ixgbevf %s test" % (
+                self.IXGBEVF, self.nic))
+        elif self.kdriver == "i40e":
+            out = self.dut.send_expect("ethtool -i %s" % self.intf, "# ", 60)
+            self.verify(self.I40E in out and self.I40E_FIRMWARE in out,
+                        "Temporarily does not support %s test" % self.nic)
+            put = self.dut.send_expect("modinfo %svf" % self.kdriver, "# ", 60)
+            self.verify(self.I40EVF in put,
+                        "Temporarily does not support %s test" % self.nic)
+        self.bind_interfaces_linux()
+
+    def get_vm_intf(self):
+        if self.vm0_dut is not None:
+            self.vm0_intf = self.vm0_dut.ports_info[0]['intf']
+            self.verify(self.vm0_intf != 'N/A', "erroe intf")
+        if self.vm1_dut is not None:
+            self.vm1_intf = self.vm1_dut.ports_info[0]['intf']
+            self.verify(self.vm1_intf != 'N/A', "erroe intf")
+
+    def setup_vm_env(self):
+        """
+        Start One VM with one virtio device
+        """
+        self.dut.generate_sriov_vfs_by_port(
+            self.dut_ports[0], 6, driver='igb_uio')
+        self.sriov_vfs_port = self.dut.ports_info[
+            self.dut_ports[0]]['vfs_port']
+        self.dut.send_expect("rmmod %svf" % self.kdriver, "# ")
+        self.dut_testpmd = PmdOutput(self.dut)
+        vf0_prop_1 = {'opt_host': self.sriov_vfs_port[0].pci}
+        vf0_prop_2 = {'opt_host': self.sriov_vfs_port[1].pci}
+        vf0_prop_3 = {'opt_host': self.sriov_vfs_port[2].pci}
+        vf0_prop_4 = {'opt_host': self.sriov_vfs_port[3].pci}
+        self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_kernel')
+        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_1)
+        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_2)
+        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_3)
+        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_4)
+
+        try:
+            self.vm0_dut = self.vm0.start()
+            if self.vm0_dut is None:
+                raise Exception("Set up VM ENV failed")
+        except Exception as e:
+            self.destroy_vm_env()
+            self.logger.error("Failure for %s" % str(e))
+
+        vf1_prop_5 = {'opt_host': self.sriov_vfs_port[4].pci}
+        vf1_prop_6 = {'opt_host': self.sriov_vfs_port[5].pci}
+        self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_kernel')
+        self.vm1.set_vm_device(driver='pci-assign', **vf1_prop_5)
+        self.vm1.set_vm_device(driver='pci-assign', **vf1_prop_6)
+
+        try:
+            self.vm1_dut = self.vm1.start()
+            if self.vm1_dut is None:
+                raise Exception("Set up VM1 ENV failed!")
+        except Exception as e:
+            self.destroy_vm_env()
+            raise Exception(e)
+        self.vm0_testpmd = PmdOutput(self.vm0_dut)
+        self.vm1_testpmd = PmdOutput(self.vm1_dut)
+        self.vm0_dut.restore_interfaces_linux()
+        self.vm1_dut.restore_interfaces_linux()
+        self.env_done = True
+
+    def destroy_vm_env(self):
+        """
+        destroy vm environment
+        """
+        if getattr(self, 'vm0', None):
+            self.vm0_dut.kill_all()
+            self.vm0_dut_ports = None
+            # destroy vm0
+            self.vm0.stop()
+            self.vm0 = None
+
+        if getattr(self, 'vm1', None):
+            self.vm1_dut.kill_all()
+            self.vm1_dut_ports = None
+            # destroy vm1
+            self.vm1.stop()
+            self.vm1 = None
+
+        if getattr(self, 'used_dut_port', None):
+            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+            port = self.dut.ports_info[self.used_dut_port]['port']
+            self.used_dut_port = None
+
+        self.env_done = False
+
+    def send_packet(self, mac, vlan_id='', pkt_lens=64, num=1, tran_type=''):
+        """
+        Send a packet to port
+        """
+        if tran_type == "vlan":
+            pkt = Packet(pkt_type='VLAN_UDP', pkt_len=pkt_lens)
+            pkt.config_layer('ether', {'dst': mac})
+            pkt.config_layer('vlan', {'vlan': vlan_id})
+            pkt.send_pkt(tx_port=self.tester_intf, count=num)
+            time.sleep(.5)
+        else:
+            pkt = Packet(pkt_type='TCP', pkt_len=pkt_lens)
+            pkt.config_layer('ether', {'dst': mac})
+            pkt.send_pkt(tx_port=self.tester_intf, count=num)
+            time.sleep(.5)
+
+    def test_link(self):
+        """
+        verify the link state
+        """
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        for time in range(2):
+            self.vm0_dut.send_expect(
+                "ifconfig %s up" % self.vm0_intf, "#", 10)
+            out = self.vm0_dut.send_expect(
+                "ifconfig %s" % self.vm0_intf, "#", 10)
+            self.verify("UP" in out, "up error")
+            self.vm0_dut.send_expect("ifconfig %s down" %
+                                     self.vm0_intf, "#", 10)
+            out = self.vm0_dut.send_expect(
+                "ifconfig %s" % self.vm0_intf, "#", 10)
+            self.verify("UP" not in out, "down error")
+        self.dut_testpmd.quit()
+
+    def test_ping(self):
+        """
+        verify the ping state
+        """
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+
+        for i in range(3):
+            self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf, "#", 10)
+            self.tester.send_expect("ifconfig %s up " %
+                                    self.tester_intf, "#", 10)
+
+            self.vm0_dut.send_expect("ifconfig %s 5.5.5.7" %
+                                     self.vm0_intf, "#", 10)
+            self.tester.send_expect("ifconfig %s 5.5.5.9" %
+                                    self.tester_intf, "#", 10)
+            self.tester.send_expect("ping 5.5.5.7", "PING", 10)
+            time.sleep(10)
+            out = self.tester.send_expect("^C", "#", 10)
+            packet = re.findall("\s*(\d*)% packet loss,", out)
+            self.verify(packet[0] == '0', "can't ping successfully to vm0")
+
+            self.tester.send_expect("ifconfig %s down" %
+                                    self.tester_intf, "#", 10)
+            self.vm0_dut.send_expect("ifconfig %s down" %
+                                     self.vm0_intf, "#", 10)
+
+        self.dut_testpmd.quit()
+
+    def test_reset(self):
+        """
+        verify reset the vf1 impact on VF0
+        """
+        for i in range(2):
+            out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+            self.verify("Port %s Link Up" % self.dut_ports[
+                        0] in out, "PF link down error")
+
+            self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf, "#", 20)
+            self.vm1_dut.send_expect("ifconfig %s up" % self.vm1_intf, "#", 20)
+
+            self.vm1_dut.send_expect("ifconfig %s down" %
+                                     self.vm1_intf, "#", 10)
+            out = self.vm0_dut.send_expect(
+                "ifconfig %s" % self.vm0_intf, "#", 10)
+            self.verify("UP"in out, "VF1 link change impact on VF0")
+
+            self.vm1_dut.send_expect("rmmod ixgbevf", "#", 10)
+            out = self.vm0_dut.send_expect(
+                "ifconfig %s" % self.vm0_intf, "#", 10)
+            self.verify("UP"in out, "VF1 kernel driver change impact on VF0")
+
+            self.vm0_dut.send_expect("tcpdump -i %s" %
+                                     self.vm0_intf, "listening on", 10)
+            self.send_packet(self.vm0_mac)
+            out = self.vm0_dut.send_expect("^C", "#", 10)
+            packet = re.findall("\s*(\d*) packet captured", out)
+            self.verify('1' == packet[0], "VF0 rx_package failure")
+
+            self.vm1_dut.restore_interfaces_linux()
+            out = self.vm0_dut.send_expect(
+                "ifconfig %s" % self.vm0_intf, "#", 10)
+            self.verify("UP"in out, "VF0 link change impact on VF1")
+
+            self.vm0_dut.send_expect("tcpdump -i %s" %
+                                     self.vm0_intf, "listening on", 10)
+            self.send_packet(self.vm0_mac)
+            out = self.vm0_dut.send_expect("^C", "#", 10)
+            packet = re.findall("\s*(\d*) packet captured", out)
+            self.verify('1' == packet[0], "VF1 rx_package failure")
+            self.dut_testpmd.quit()
+
+    def test_address(self):
+        """
+        verify add/delete IP/MAC address
+        """
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        self.vm0_dut.send_expect(
+            "ifconfig %s up" % self.vm0_intf, "#", 10)
+        self.vm0_dut.send_expect(
+            "ifconfig %s add efdd::9fc8:6a6d:c232:f1c0" % self.vm0_intf, "#", 10)
+        self.vm0_dut.send_expect(
+            "ifconfig %s del efdd::9fc8:6a6d:c232:f1c0" % self.vm0_intf, "#", 10)
+        self.vm0_dut.send_expect(
+            "ifconfig %s hw ether 00:AA:BB:CC:dd:EE" % self.vm0_intf, "#", 10)
+        self.vm0_dut.send_expect("tcpdump -i %s" %
+                                 self.vm0_intf, "tcpdump", 10)
+        self.send_packet('00:AA:BB:CC:dd:EE')
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("\s*(\d*) packet captured", out)
+        self.verify(packet[0] == '1', "address error")
+        self.dut_testpmd.quit()
+
+    def test_vlan(self):
+        """
+        verify add/delete vlan
+        """
+        vlan_id = random.randint(0, 4095)
+
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        self.vm0_dut.send_expect("modprobe 8021q", "#", 10)
+        self.vm0_dut.send_expect("vconfig add %s %s" %
+                                 (self.vm0_intf, vlan_id), "#", 10)
+
+        out = self.vm0_dut.send_expect("ls /proc/net/vlan ", "#", 10)
+        self.verify("%s.%s" % (self.vm0_intf, vlan_id)
+                    in out, "take vlan id failure")
+
+        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
+        self.send_packet(self.vm0_mac, '4096', tran_type='vlan')
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("\s*(\d*) packet captured", out)
+        self.verify('0' == packet[0], "test_vlan1 error")
+
+        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
+        self.send_packet(self.vm0_mac, vlan_id, tran_type='vlan')
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("\s*(\d*) packet captured", out)
+        self.verify('1' == packet[0], "test_vlan2 error")
+
+        self.vm0_dut.send_expect("vconfig rem %s.%s" %
+                                 (self.vm0_intf, vlan_id), "#", 10)
+        out = self.vm0_dut.send_expect("ls /proc/net/vlan ", "#", 10)
+        self.verify("%s.%s" % (self.vm0_intf, vlan_id)
+                    not in out, "vlan error")
+
+        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
+        self.send_packet(self.vm0_mac, vlan_id, tran_type='vlan')
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("\s*(\d*) packet captured", out)
+        self.verify('0' == packet[0], "test_vlan3 error")
+        self.dut_testpmd.quit()
+
+    def test_packet_statistic(self):
+        """
+        verify packet statistic
+        """
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        out = self.vm0_dut.send_expect(
+            "ethtool -S %s" % self.vm0_intf, "#", 10)
+        packet_before = re.findall("rx_packets:\s*(\d*)", out)
+        self.send_packet(self.vm0_mac, num=100)
+        out = self.vm0_dut.send_expect(
+            "ethtool -S %s" % self.vm0_intf, "#", 10)
+        packet_after = re.findall("rx_packets:\s*(\d*)", out)
+        self.verify(packet_after[0] > packet_before[
+                    0], "packet_statistic error")
+        self.dut_testpmd.quit()
+
+    def test_mtu(self):
+        """
+        verify mtu change
+        """
+        self.vm0_dut.send_expect("ifconfig %s" % self.vm0_intf, "mtu 1500", 10)
+        self.vm0_dut.send_expect("ifconfig %s up" %
+                                 self.vm0_intf, "mtu 1500", 10)
+
+        self.dut.send_expect("ifconfig %s" % self.intf, "mtu 1500", 10)
+
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+
+        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
+        self.send_packet(self.vm0_mac, pkt_lens=2000)
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("\s*(\d*) packet captured", out)
+        self.verify('0' == packet[0], "mtu1 error")
+
+        self.send_packet(self.dmac, pkt_lens=2000)
+        out = self.dut_testpmd.execute_cmd('show port stats 0')
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("RX-packets:\s*(\d*)", out)
+        self.verify('0' == packet[0], "mtu1 error")
+
+        self.dut_testpmd.execute_cmd('port stop all')
+        self.dut_testpmd.execute_cmd('port config mtu 0 3000')
+        self.dut_testpmd.execute_cmd('port start all')
+
+        self.send_packet(self.dmac, pkt_lens=2000)
+        out = self.dut_testpmd.execute_cmd('show port stats 0')
+        packet = re.findall("RX-packets:\s*(\d*)", out)
+        self.verify('1' == packet[0], "mtu1 error")
+
+        self.vm0_dut.send_expect("ifconfig %s mtu 3000" %
+                                 self.vm0_intf, "#", 10)
+        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
+        self.send_packet(self.vm0_mac, pkt_lens=2000)
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        packet = re.findall("\s*(\d*) packet captured", out)
+        self.verify('1' == packet[0], "mtu1 error")
+
+        self.dut_testpmd.execute_cmd('port stop all')
+        self.dut_testpmd.execute_cmd('port config mtu 0 1500')
+        self.dut_testpmd.execute_cmd('port start all')
+
+        self.vm0_dut.send_expect("ifconfig %s mtu 1500" %
+                                 self.vm0_intf, "#", 10)
+
+        self.dut_testpmd.quit()
+
+    def test_promisc_mode(self):
+        """
+        verify Enable/disable promisc mode
+        """
+        self.verify(self.nic in ["niantic"],
+                    "%s NIC not support tcpid " % self.nic)
+
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+
+        self.dut_testpmd.execute_cmd('set promisc all on')
+        self.dut_testpmd.execute_cmd('set fwd rxonly')
+        self.dut_testpmd.execute_cmd('set verbose 1')
+        self.dut_testpmd.execute_cmd('start')
+        self.vm0_dut.send_expect("tcpdump -i %s -n -e -vv" %
+                                 self.vm0_intf, "tcpdump", 10)
+        random_mac = '33:33:00:00:00:16'
+        self.send_packet(random_mac)
+        time.sleep(.5)
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        self.verify(random_mac in out, "promisc_mode failure")
+
+        self.dut_testpmd.execute_cmd('set promisc all off')
+        self.vm0_dut.send_expect("tcpdump -i %s -p -n -e -vv" %
+                                 self.vm0_intf, "tcpdump", 10)
+        self.send_packet(random_mac)
+        time.sleep(.5)
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        self.verify(random_mac not in out, "disable promisc_mode failure")
+
+        self.vm0_dut.send_expect(
+            "tcpdump -i %s -p -n -e -vv ./getPackageByTcpdump.cap" % self.vm0_intf, "tcpdump", 10)
+        self.send_packet(self.vm0_mac)
+        time.sleep(.5)
+        out = self.vm0_dut.send_expect("^C", "#", 10)
+        self.verify(self.vm0_mac in out, "promisc_mode error")
+
+        self.dut_testpmd.quit()
+
+    def test_rss(self):
+        """
+        verify kernel VF each queue can receive packets
+        """
+        self.verify(self.nic in ["niantic"],
+                    "%s NIC not support tcpid " % self.nic)
+        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        out = self.vm0_dut.send_expect(
+            "ethtool -l %s" % self.vm0_intf, "#", 10)
+        qeumu_num = re.findall("Combined:\s*(\d*)", out)
+        out = self.vm0_dut.send_expect(
+            "ethtool -S %s" % self.vm0_intf, "#", 10)
+        packet = re.findall("rx_packets:\s*(\d*)", out)
+        for i in xrange(5):
+            mythread = threading.Thread(target=self.send_packet(self.vm0_mac))
+            mythread.start()
+        out = self.vm0_dut.send_expect(
+            "ethtool -S %s" % self.vm0_intf, "#", 10)
+        packet = re.findall("rx_packets:\s*(\d*)", out)
+        self.verify(packet[0] > '0', "rss2 error")
+
+        self.dut_testpmd.quit()
+
+    def test_dpf_kvf_dvf(self):
+        """
+        Check DPDK VF0 and kernel VF1 don't impact each other and no performance drop
+        """
+        out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        self.verify("Port %s Link Up" %
+                    self.dut_ports[0] in out, "reset1 error")
+        self.vm0_dut.send_expect(
+            "ifconfig %s up " % self.vm0_dut.ports_info[0]['intf'], "#", 10)
+        self.vm0_dut.send_expect(
+            "ifconfig %s up " % self.vm0_dut.ports_info[1]['intf'], "#", 10)
+        self.vm0_dut.send_expect(
+            "./usertools/dpdk-devbind.py -b igb_uio %s" % self.vm0_dut.ports_info[1]['intf'], "#", 10)
+        self.vm0_testpmd.start_testpmd("Default")
+        self.vm0_testpmd.execute_cmd('set promisc all on')
+        self.vm0_testpmd.execute_cmd('set fwd rxonly')
+        self.vm0_testpmd.execute_cmd('set verbose 1')
+        self.vm0_testpmd.execute_cmd('start')
+        mynewvmsession = self.vm0_dut.new_session()
+        self.mynewvmsession.send_expect(
+            "tcpdump -i %s -n -e -vv -w ./getPackageByTcpdump.cap" % self.vm0_intf, "#", 10)
+        self.send_packet(self.vm0_mac)
+        out = self.mynewvmsession.send_expect(
+            "tcpdump -nn -e -v -r ./getPackageByTcpdump.cap", "#", 10)
+        self.verify(self.vm0_mac in out, "promisc_mode error")
+
+        self.vm0_testpmd.quit()
+        self.dut_testpmd.quit()
+
+    def test_dpf_2kvf_2dvf_2vm(self):
+        """
+        Check DPDK PF 2kernel VFs 2DPDK VFs 2VMs link change impact on other VFs
+        """
+        out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        self.verify("Port %s Link Up" %
+                    self.dut_ports[0] in out, "reset1 error")
+        for vm0_intf in self.vm0_dut.ports_info:
+            self.vm0_dut.send_expect(
+                "ifconfig %s up " % vm0_intf['intf'], "#", 10)
+        for vm1_intf in self.vm1_dut.ports_info:
+            self.vm0_dut.send_expect(
+                "ifconfig %s up " % vm1_intf['intf'], "#", 10)
+        self.vm0_dut.send_expect(
+            "./usertools/dpdk-devbind.py -b igb_uio %s %s" % (self.vm0_dut.ports_info[0]['pci'], self.vm0_dut.ports_info[1]['pci']), "#", 10)
+        self.vm0_dut.send_expect(
+            "./usertools/dpdk-devbind.py -b igb_uio %s" % (self.vm1_dut.ports_info[0]['pci']), "#", 10)
+
+        self.vm0_testpmd.start_testpmd("Default")
+        self.vm0_testpmd.execute_cmd('set promisc all on')
+        self.vm0_testpmd.execute_cmd('set fwd rxonly')
+        self.vm0_testpmd.execute_cmd('set verbose 1')
+        self.vm0_testpmd.execute_cmd('start')
+
+        self.vm1_testpmd.start_testpmd("Default")
+        self.vm1_testpmd.execute_cmd('set promisc all on')
+        self.vm1_testpmd.execute_cmd('set fwd rxonly')
+        self.vm1_testpmd.execute_cmd('set verbose 1')
+        self.vm1_testpmd.execute_cmd('start')
+
+        mynewvmsession = self.vm0_dut.new_session()
+        self.mynewvmsession.send_expect(
+            "tcpdump -i %s -n -e -vv -w ./getPackageByTcpdump.cap" % self.vm0_intf, "tcpdump", 10)
+        self.send_packet(self.vm0_mac)
+        out = self.mynewvmsession.send_expect(
+            "tcpdump -nn -e -v -r ./getPackageByTcpdump.cap", "tcpdump", 10)
+        self.verify(self.vm0_mac in out, "promisc_mode error")
+
+        self.vm0_testpmd.quit()
+        self.dut_testpmd.quit()
+
+    def test_stress(self):
+        """
+        Load kernel driver stress
+        """
+        out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
+        self.verify("Port %s Link Up" %
+                    self.dut_ports[0] in out, "reset1 error")
+        for i in xrange(5):
+            out = self.vm0_dut.send_expect("rmmod ixgbevf", "#", 10)
+            print out
+            self.verify('error' not in out,
+                        "stress error for rmmod ixgbevf:%s" % out)
+            out = self.vm0_dut.send_expect(
+                "insmod /root/i40evf-2.0.16/src/ixgbevf.ko", "#", 10)
+            self.verify(
+                'error' not in out, "stress error for insmod /root/i40evf-2.0.16/src/ixgbevf.ko:%s" % out)
+        self.dut_testpmd.quit()
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        self.vm0_dut.kill_all()
+        self.vm1_dut.kill_all()
+        self.dut.kill_all()
+        time.sleep(2)
+        pass
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        pass
-- 
1.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH V1] add test suite vf kernel
  2017-03-13  8:52 [dts] [PATCH V1] add test suite vf kernel xu,gang
@ 2017-03-14  3:02 ` Liu, Yong
  0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2017-03-14  3:02 UTC (permalink / raw)
  To: Xu, GangX, dts; +Cc: Xu, GangX

Thanks Gang, some comments below.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of xu,gang
> Sent: Monday, March 13, 2017 4:52 PM
> To: dts@dpdk.org
> Cc: Xu, GangX <gangx.xu@intel.com>
> Subject: [dts] [PATCH V1] add test suite vf kernel
> 
> Signed-off-by: xu,gang <gangx.xu@intel.com>
> ---
>  tests/TestSuite_vf_kernel.py | 590
> +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 590 insertions(+)
>  create mode 100644 tests/TestSuite_vf_kernel.py
> 
> diff --git a/tests/TestSuite_vf_kernel.py b/tests/TestSuite_vf_kernel.py
> new file mode 100644
> index 0000000..444ffbf
> --- /dev/null
> +++ b/tests/TestSuite_vf_kernel.py
> @@ -0,0 +1,590 @@
> +# 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 VF kernel
> +"""
> +
> +import utils
> +import string
> +import time
> +import re
> +import random
> +import threading
> +from test_case import TestCase
> +from qemu_kvm import QEMUKvm
> +from pmd_output import PmdOutput
> +from packet import Packet, sniff_packets, load_sniff_packets
> +
> +
> +class TestVfKernel(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) >= 1, "Insufficient ports")
> +        self.cores = self.dut.get_core_list("1S/4C/1T")
> +        self.coremask = utils.create_mask(self.cores)
> +
> +        self.dmac = self.dut.get_mac_address(self.dut_ports[0])
> +        txport = self.tester.get_local_port(self.dut_ports[0])
> +        self.tester_intf = self.tester.get_interface(txport)
> +
> +        self.intf = self.dut.ports_info[self.dut_ports[0]]['intf']
> +        self.pci =
> self.dut.ports_info[self.dut_ports[0]]['pci'].split(':')
> +
> +        self.IXGBE = '3.15.1-k'
> +        self.IXGBEVF = '2.11.3-k'
> +        self.IXGBE_FIRMWARE = '0x61bf0001'
> +
> +        self.I40E = '2.0.15'
> +        self.I40EVF = '2.0.13'
> +        self.I40E_FIRMWARE = '5.50 0x80002c0c 1.3908.0'
> +

If hard code ixgbe and i40e driver verison, it can only work on your platform. Is that what expected?

> +        self.verify_version()
> +        self.dut.send_expect("killall qemu-system-x86_64", "#", 10)

Please not kill qemu process, user may use it for other purpose. And our framework will try to cleanup qemu process.

> +        self.setup_vm_env()
> +        self.get_vm_intf()
> +
> +        self.vm0_mac = self.vm0_dut.get_mac_address(0)
> +        self.vm1_mac = self.vm1_dut.get_mac_address(0)
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        self.dut.kill_all()
> +        time.sleep(2)
> +        pass
> +
> +    def verify_version(self):
> +        """
> +        verify the dut version
> +        """
> +        self.dut.restore_interfaces_linux()
> +        if self.kdriver == "ixgbe":
> +            out = self.dut.send_expect("ethtool -i %s" % self.intf, "# ",
> 60)
> +            self.verify(self.IXGBE in out, "%s does not ixgbe %s test" %
> +                        (self.IXGBE, self.nic))
> +            self.verify(self.IXGBE_FIRMWARE in out, "%s does not
> firmware %s test" % (
> +                self.IXGBE_FIRMWARE, self.nic))
> +            put = self.dut.send_expect("modinfo %svf" % self.kdriver, "#
> ", 60)
> +            self.verify(self.IXGBEVF in put, "%s does not ixgbevf %s
> test" % (
> +                self.IXGBEVF, self.nic))
> +        elif self.kdriver == "i40e":
> +            out = self.dut.send_expect("ethtool -i %s" % self.intf, "# ",
> 60)
> +            self.verify(self.I40E in out and self.I40E_FIRMWARE in out,
> +                        "Temporarily does not support %s test" % self.nic)
> +            put = self.dut.send_expect("modinfo %svf" % self.kdriver, "#
> ", 60)
> +            self.verify(self.I40EVF in put,
> +                        "Temporarily does not support %s test" % self.nic)
> +        self.bind_interfaces_linux()
> +
> +    def get_vm_intf(self):
> +        if self.vm0_dut is not None:
> +            self.vm0_intf = self.vm0_dut.ports_info[0]['intf']
> +            self.verify(self.vm0_intf != 'N/A', "erroe intf")
> +        if self.vm1_dut is not None:
> +            self.vm1_intf = self.vm1_dut.ports_info[0]['intf']
> +            self.verify(self.vm1_intf != 'N/A', "erroe intf")
> +
> +    def setup_vm_env(self):
> +        """
> +        Start One VM with one virtio device
> +        """
> +        self.dut.generate_sriov_vfs_by_port(
> +            self.dut_ports[0], 6, driver='igb_uio')
> +        self.sriov_vfs_port = self.dut.ports_info[
> +            self.dut_ports[0]]['vfs_port']
> +        self.dut.send_expect("rmmod %svf" % self.kdriver, "# ")
> +        self.dut_testpmd = PmdOutput(self.dut)
> +        vf0_prop_1 = {'opt_host': self.sriov_vfs_port[0].pci}
> +        vf0_prop_2 = {'opt_host': self.sriov_vfs_port[1].pci}
> +        vf0_prop_3 = {'opt_host': self.sriov_vfs_port[2].pci}
> +        vf0_prop_4 = {'opt_host': self.sriov_vfs_port[3].pci}
> +        self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_kernel')
> +        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_1)
> +        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_2)
> +        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_3)
> +        self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_4)
> +
> +        try:
> +            self.vm0_dut = self.vm0.start()
> +            if self.vm0_dut is None:
> +                raise Exception("Set up VM ENV failed")
> +        except Exception as e:
> +            self.destroy_vm_env()
> +            self.logger.error("Failure for %s" % str(e))
> +
> +        vf1_prop_5 = {'opt_host': self.sriov_vfs_port[4].pci}
> +        vf1_prop_6 = {'opt_host': self.sriov_vfs_port[5].pci}
> +        self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_kernel')
> +        self.vm1.set_vm_device(driver='pci-assign', **vf1_prop_5)
> +        self.vm1.set_vm_device(driver='pci-assign', **vf1_prop_6)
> +
> +        try:
> +            self.vm1_dut = self.vm1.start()
> +            if self.vm1_dut is None:
> +                raise Exception("Set up VM1 ENV failed!")
> +        except Exception as e:
> +            self.destroy_vm_env()
> +            raise Exception(e)
> +        self.vm0_testpmd = PmdOutput(self.vm0_dut)
> +        self.vm1_testpmd = PmdOutput(self.vm1_dut)
> +        self.vm0_dut.restore_interfaces_linux()
> +        self.vm1_dut.restore_interfaces_linux()
> +        self.env_done = True
> +
> +    def destroy_vm_env(self):
> +        """
> +        destroy vm environment
> +        """
> +        if getattr(self, 'vm0', None):
> +            self.vm0_dut.kill_all()
> +            self.vm0_dut_ports = None
> +            # destroy vm0
> +            self.vm0.stop()
> +            self.vm0 = None
> +
> +        if getattr(self, 'vm1', None):
> +            self.vm1_dut.kill_all()
> +            self.vm1_dut_ports = None
> +            # destroy vm1
> +            self.vm1.stop()
> +            self.vm1 = None
> +
> +        if getattr(self, 'used_dut_port', None):
> +            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> +            port = self.dut.ports_info[self.used_dut_port]['port']
> +            self.used_dut_port = None
> +
> +        self.env_done = False
> +
> +    def send_packet(self, mac, vlan_id='', pkt_lens=64, num=1,
> tran_type=''):
> +        """
> +        Send a packet to port
> +        """
> +        if tran_type == "vlan":
> +            pkt = Packet(pkt_type='VLAN_UDP', pkt_len=pkt_lens)
> +            pkt.config_layer('ether', {'dst': mac})
> +            pkt.config_layer('vlan', {'vlan': vlan_id})
> +            pkt.send_pkt(tx_port=self.tester_intf, count=num)
> +            time.sleep(.5)
> +        else:
> +            pkt = Packet(pkt_type='TCP', pkt_len=pkt_lens)
> +            pkt.config_layer('ether', {'dst': mac})
> +            pkt.send_pkt(tx_port=self.tester_intf, count=num)
> +            time.sleep(.5)
> +
> +    def test_link(self):
> +        """
> +        verify the link state
> +        """
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        for time in range(2):
> +            self.vm0_dut.send_expect(
> +                "ifconfig %s up" % self.vm0_intf, "#", 10)
> +            out = self.vm0_dut.send_expect(
> +                "ifconfig %s" % self.vm0_intf, "#", 10)
> +            self.verify("UP" in out, "up error")
> +            self.vm0_dut.send_expect("ifconfig %s down" %
> +                                     self.vm0_intf, "#", 10)
> +            out = self.vm0_dut.send_expect(
> +                "ifconfig %s" % self.vm0_intf, "#", 10)
> +            self.verify("UP" not in out, "down error")
> +        self.dut_testpmd.quit()
> +
> +    def test_ping(self):
> +        """
> +        verify the ping state
> +        """
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +
> +        for i in range(3):
> +            self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf,
> "#", 10)
> +            self.tester.send_expect("ifconfig %s up " %
> +                                    self.tester_intf, "#", 10)
> +
> +            self.vm0_dut.send_expect("ifconfig %s 5.5.5.7" %
> +                                     self.vm0_intf, "#", 10)
> +            self.tester.send_expect("ifconfig %s 5.5.5.9" %
> +                                    self.tester_intf, "#", 10)
> +            self.tester.send_expect("ping 5.5.5.7", "PING", 10)
> +            time.sleep(10)
> +            out = self.tester.send_expect("^C", "#", 10)
> +            packet = re.findall("\s*(\d*)% packet loss,", out)
> +            self.verify(packet[0] == '0', "can't ping successfully to
> vm0")
> +
> +            self.tester.send_expect("ifconfig %s down" %
> +                                    self.tester_intf, "#", 10)
> +            self.vm0_dut.send_expect("ifconfig %s down" %
> +                                     self.vm0_intf, "#", 10)
> +
> +        self.dut_testpmd.quit()
> +
> +    def test_reset(self):
> +        """
> +        verify reset the vf1 impact on VF0
> +        """
> +        for i in range(2):
> +            out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --
> txq=4")
> +            self.verify("Port %s Link Up" % self.dut_ports[
> +                        0] in out, "PF link down error")
> +
> +            self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf,
> "#", 20)
> +            self.vm1_dut.send_expect("ifconfig %s up" % self.vm1_intf,
> "#", 20)
> +
> +            self.vm1_dut.send_expect("ifconfig %s down" %
> +                                     self.vm1_intf, "#", 10)
> +            out = self.vm0_dut.send_expect(
> +                "ifconfig %s" % self.vm0_intf, "#", 10)
> +            self.verify("UP"in out, "VF1 link change impact on VF0")
> +
> +            self.vm1_dut.send_expect("rmmod ixgbevf", "#", 10)

Why not just unbind from ixgbevf driver? 

> +            out = self.vm0_dut.send_expect(
> +                "ifconfig %s" % self.vm0_intf, "#", 10)
> +            self.verify("UP"in out, "VF1 kernel driver change impact on
> VF0")
> +
> +            self.vm0_dut.send_expect("tcpdump -i %s" %
> +                                     self.vm0_intf, "listening on", 10)
> +            self.send_packet(self.vm0_mac)
> +            out = self.vm0_dut.send_expect("^C", "#", 10)
> +            packet = re.findall("\s*(\d*) packet captured", out)
> +            self.verify('1' == packet[0], "VF0 rx_package failure")
> +
> +            self.vm1_dut.restore_interfaces_linux()
> +            out = self.vm0_dut.send_expect(
> +                "ifconfig %s" % self.vm0_intf, "#", 10)
> +            self.verify("UP"in out, "VF0 link change impact on VF1")
> +
> +            self.vm0_dut.send_expect("tcpdump -i %s" %
> +                                     self.vm0_intf, "listening on", 10)
> +            self.send_packet(self.vm0_mac)
> +            out = self.vm0_dut.send_expect("^C", "#", 10)
> +            packet = re.findall("\s*(\d*) packet captured", out)
> +            self.verify('1' == packet[0], "VF1 rx_package failure")
> +            self.dut_testpmd.quit()
> +
> +    def test_address(self):
> +        """
> +        verify add/delete IP/MAC address
> +        """
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        self.vm0_dut.send_expect(
> +            "ifconfig %s up" % self.vm0_intf, "#", 10)
> +        self.vm0_dut.send_expect(
> +            "ifconfig %s add efdd::9fc8:6a6d:c232:f1c0" % self.vm0_intf,
> "#", 10)
> +        self.vm0_dut.send_expect(
> +            "ifconfig %s del efdd::9fc8:6a6d:c232:f1c0" % self.vm0_intf,
> "#", 10)
> +        self.vm0_dut.send_expect(
> +            "ifconfig %s hw ether 00:AA:BB:CC:dd:EE" % self.vm0_intf, "#",
> 10)
> +        self.vm0_dut.send_expect("tcpdump -i %s" %
> +                                 self.vm0_intf, "tcpdump", 10)
> +        self.send_packet('00:AA:BB:CC:dd:EE')
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("\s*(\d*) packet captured", out)
> +        self.verify(packet[0] == '1', "address error")
> +        self.dut_testpmd.quit()
> +
> +    def test_vlan(self):
> +        """
> +        verify add/delete vlan
> +        """
> +        vlan_id = random.randint(0, 4095)
> +
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        self.vm0_dut.send_expect("modprobe 8021q", "#", 10)
> +        self.vm0_dut.send_expect("vconfig add %s %s" %
> +                                 (self.vm0_intf, vlan_id), "#", 10)
> +
> +        out = self.vm0_dut.send_expect("ls /proc/net/vlan ", "#", 10)
> +        self.verify("%s.%s" % (self.vm0_intf, vlan_id)
> +                    in out, "take vlan id failure")
> +
> +        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
> +        self.send_packet(self.vm0_mac, '4096', tran_type='vlan')
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("\s*(\d*) packet captured", out)
> +        self.verify('0' == packet[0], "test_vlan1 error")
> +
> +        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
> +        self.send_packet(self.vm0_mac, vlan_id, tran_type='vlan')
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("\s*(\d*) packet captured", out)
> +        self.verify('1' == packet[0], "test_vlan2 error")
> +
> +        self.vm0_dut.send_expect("vconfig rem %s.%s" %
> +                                 (self.vm0_intf, vlan_id), "#", 10)
> +        out = self.vm0_dut.send_expect("ls /proc/net/vlan ", "#", 10)
> +        self.verify("%s.%s" % (self.vm0_intf, vlan_id)
> +                    not in out, "vlan error")
> +
> +        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
> +        self.send_packet(self.vm0_mac, vlan_id, tran_type='vlan')
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("\s*(\d*) packet captured", out)
> +        self.verify('0' == packet[0], "test_vlan3 error")
> +        self.dut_testpmd.quit()
> +
> +    def test_packet_statistic(self):
> +        """
> +        verify packet statistic
> +        """
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        out = self.vm0_dut.send_expect(
> +            "ethtool -S %s" % self.vm0_intf, "#", 10)
> +        packet_before = re.findall("rx_packets:\s*(\d*)", out)
> +        self.send_packet(self.vm0_mac, num=100)
> +        out = self.vm0_dut.send_expect(
> +            "ethtool -S %s" % self.vm0_intf, "#", 10)
> +        packet_after = re.findall("rx_packets:\s*(\d*)", out)
> +        self.verify(packet_after[0] > packet_before[
> +                    0], "packet_statistic error")
> +        self.dut_testpmd.quit()
> +
> +    def test_mtu(self):
> +        """
> +        verify mtu change
> +        """
> +        self.vm0_dut.send_expect("ifconfig %s" % self.vm0_intf, "mtu
> 1500", 10)
> +        self.vm0_dut.send_expect("ifconfig %s up" %
> +                                 self.vm0_intf, "mtu 1500", 10)
> +
> +        self.dut.send_expect("ifconfig %s" % self.intf, "mtu 1500", 10)
> +
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +
> +        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
> +        self.send_packet(self.vm0_mac, pkt_lens=2000)
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("\s*(\d*) packet captured", out)
> +        self.verify('0' == packet[0], "mtu1 error")
> +
> +        self.send_packet(self.dmac, pkt_lens=2000)
> +        out = self.dut_testpmd.execute_cmd('show port stats 0')
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("RX-packets:\s*(\d*)", out)
> +        self.verify('0' == packet[0], "mtu1 error")
> +
> +        self.dut_testpmd.execute_cmd('port stop all')
> +        self.dut_testpmd.execute_cmd('port config mtu 0 3000')
> +        self.dut_testpmd.execute_cmd('port start all')
> +
> +        self.send_packet(self.dmac, pkt_lens=2000)
> +        out = self.dut_testpmd.execute_cmd('show port stats 0')
> +        packet = re.findall("RX-packets:\s*(\d*)", out)
> +        self.verify('1' == packet[0], "mtu1 error")
> +
> +        self.vm0_dut.send_expect("ifconfig %s mtu 3000" %
> +                                 self.vm0_intf, "#", 10)
> +        self.vm0_dut.send_expect("tcpdump -i %s" % self.vm0_intf, "#", 10)
> +        self.send_packet(self.vm0_mac, pkt_lens=2000)
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        packet = re.findall("\s*(\d*) packet captured", out)
> +        self.verify('1' == packet[0], "mtu1 error")
> +
> +        self.dut_testpmd.execute_cmd('port stop all')
> +        self.dut_testpmd.execute_cmd('port config mtu 0 1500')
> +        self.dut_testpmd.execute_cmd('port start all')
> +
> +        self.vm0_dut.send_expect("ifconfig %s mtu 1500" %
> +                                 self.vm0_intf, "#", 10)
> +
> +        self.dut_testpmd.quit()
> +
> +    def test_promisc_mode(self):
> +        """
> +        verify Enable/disable promisc mode
> +        """
> +        self.verify(self.nic in ["niantic"],
> +                    "%s NIC not support tcpid " % self.nic)
> +
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +
> +        self.dut_testpmd.execute_cmd('set promisc all on')
> +        self.dut_testpmd.execute_cmd('set fwd rxonly')
> +        self.dut_testpmd.execute_cmd('set verbose 1')
> +        self.dut_testpmd.execute_cmd('start')
> +        self.vm0_dut.send_expect("tcpdump -i %s -n -e -vv" %
> +                                 self.vm0_intf, "tcpdump", 10)
> +        random_mac = '33:33:00:00:00:16'
> +        self.send_packet(random_mac)
> +        time.sleep(.5)
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        self.verify(random_mac in out, "promisc_mode failure")
> +
> +        self.dut_testpmd.execute_cmd('set promisc all off')
> +        self.vm0_dut.send_expect("tcpdump -i %s -p -n -e -vv" %
> +                                 self.vm0_intf, "tcpdump", 10)
> +        self.send_packet(random_mac)
> +        time.sleep(.5)
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        self.verify(random_mac not in out, "disable promisc_mode failure")
> +
> +        self.vm0_dut.send_expect(
> +            "tcpdump -i %s -p -n -e -vv ./getPackageByTcpdump.cap" %
> self.vm0_intf, "tcpdump", 10)
> +        self.send_packet(self.vm0_mac)
> +        time.sleep(.5)
> +        out = self.vm0_dut.send_expect("^C", "#", 10)
> +        self.verify(self.vm0_mac in out, "promisc_mode error")
> +
> +        self.dut_testpmd.quit()
> +
> +    def test_rss(self):
> +        """
> +        verify kernel VF each queue can receive packets
> +        """
> +        self.verify(self.nic in ["niantic"],
> +                    "%s NIC not support tcpid " % self.nic)
> +        self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        out = self.vm0_dut.send_expect(
> +            "ethtool -l %s" % self.vm0_intf, "#", 10)
> +        qeumu_num = re.findall("Combined:\s*(\d*)", out)
> +        out = self.vm0_dut.send_expect(
> +            "ethtool -S %s" % self.vm0_intf, "#", 10)
> +        packet = re.findall("rx_packets:\s*(\d*)", out)
> +        for i in xrange(5):
> +            mythread =
> threading.Thread(target=self.send_packet(self.vm0_mac))
> +            mythread.start()
> +        out = self.vm0_dut.send_expect(
> +            "ethtool -S %s" % self.vm0_intf, "#", 10)
> +        packet = re.findall("rx_packets:\s*(\d*)", out)
> +        self.verify(packet[0] > '0', "rss2 error")
> +
> +        self.dut_testpmd.quit()
> +
> +    def test_dpf_kvf_dvf(self):
> +        """
> +        Check DPDK VF0 and kernel VF1 don't impact each other and no
> performance drop
> +        """
> +        out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        self.verify("Port %s Link Up" %
> +                    self.dut_ports[0] in out, "reset1 error")
> +        self.vm0_dut.send_expect(
> +            "ifconfig %s up " % self.vm0_dut.ports_info[0]['intf'], "#",
> 10)
> +        self.vm0_dut.send_expect(
> +            "ifconfig %s up " % self.vm0_dut.ports_info[1]['intf'], "#",
> 10)
> +        self.vm0_dut.send_expect(
> +            "./usertools/dpdk-devbind.py -b igb_uio %s" %
> self.vm0_dut.ports_info[1]['intf'], "#", 10)
> +        self.vm0_testpmd.start_testpmd("Default")
> +        self.vm0_testpmd.execute_cmd('set promisc all on')
> +        self.vm0_testpmd.execute_cmd('set fwd rxonly')
> +        self.vm0_testpmd.execute_cmd('set verbose 1')
> +        self.vm0_testpmd.execute_cmd('start')
> +        mynewvmsession = self.vm0_dut.new_session()
> +        self.mynewvmsession.send_expect(
> +            "tcpdump -i %s -n -e -vv -w ./getPackageByTcpdump.cap" %
> self.vm0_intf, "#", 10)
> +        self.send_packet(self.vm0_mac)
> +        out = self.mynewvmsession.send_expect(
> +            "tcpdump -nn -e -v -r ./getPackageByTcpdump.cap", "#", 10)
> +        self.verify(self.vm0_mac in out, "promisc_mode error")
> +
> +        self.vm0_testpmd.quit()
> +        self.dut_testpmd.quit()
> +
> +    def test_dpf_2kvf_2dvf_2vm(self):
> +        """
> +        Check DPDK PF 2kernel VFs 2DPDK VFs 2VMs link change impact on
> other VFs
> +        """
> +        out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        self.verify("Port %s Link Up" %
> +                    self.dut_ports[0] in out, "reset1 error")
> +        for vm0_intf in self.vm0_dut.ports_info:
> +            self.vm0_dut.send_expect(
> +                "ifconfig %s up " % vm0_intf['intf'], "#", 10)
> +        for vm1_intf in self.vm1_dut.ports_info:
> +            self.vm0_dut.send_expect(
> +                "ifconfig %s up " % vm1_intf['intf'], "#", 10)
> +        self.vm0_dut.send_expect(
> +            "./usertools/dpdk-devbind.py -b igb_uio %s %s" %
> (self.vm0_dut.ports_info[0]['pci'], self.vm0_dut.ports_info[1]['pci']),
> "#", 10)
> +        self.vm0_dut.send_expect(
> +            "./usertools/dpdk-devbind.py -b igb_uio %s" %
> (self.vm1_dut.ports_info[0]['pci']), "#", 10)
> +
> +        self.vm0_testpmd.start_testpmd("Default")
> +        self.vm0_testpmd.execute_cmd('set promisc all on')
> +        self.vm0_testpmd.execute_cmd('set fwd rxonly')
> +        self.vm0_testpmd.execute_cmd('set verbose 1')
> +        self.vm0_testpmd.execute_cmd('start')
> +
> +        self.vm1_testpmd.start_testpmd("Default")
> +        self.vm1_testpmd.execute_cmd('set promisc all on')
> +        self.vm1_testpmd.execute_cmd('set fwd rxonly')
> +        self.vm1_testpmd.execute_cmd('set verbose 1')
> +        self.vm1_testpmd.execute_cmd('start')
> +
> +        mynewvmsession = self.vm0_dut.new_session()
> +        self.mynewvmsession.send_expect(
> +            "tcpdump -i %s -n -e -vv -w ./getPackageByTcpdump.cap" %
> self.vm0_intf, "tcpdump", 10)
> +        self.send_packet(self.vm0_mac)
> +        out = self.mynewvmsession.send_expect(
> +            "tcpdump -nn -e -v -r ./getPackageByTcpdump.cap", "tcpdump",
> 10)
> +        self.verify(self.vm0_mac in out, "promisc_mode error")
> +
> +        self.vm0_testpmd.quit()
> +        self.dut_testpmd.quit()
> +
> +    def test_stress(self):
> +        """
> +        Load kernel driver stress
> +        """
> +        out = self.dut_testpmd.start_testpmd("Default", "--rxq=4 --txq=4")
> +        self.verify("Port %s Link Up" %
> +                    self.dut_ports[0] in out, "reset1 error")
> +        for i in xrange(5):
> +            out = self.vm0_dut.send_expect("rmmod ixgbevf", "#", 10)
> +            print out
> +            self.verify('error' not in out,
> +                        "stress error for rmmod ixgbevf:%s" % out)
> +            out = self.vm0_dut.send_expect(
> +                "insmod /root/i40evf-2.0.16/src/ixgbevf.ko", "#", 10)
> +            self.verify(
> +                'error' not in out, "stress error for insmod
> /root/i40evf-2.0.16/src/ixgbevf.ko:%s" % out)

Please remove hard code here, kernel driver should be pre-configured on vm.

> +        self.dut_testpmd.quit()
> +
> +    def tear_down(self):
> +        """
> +        Run after each test case.
> +        """
> +        self.vm0_dut.kill_all()
> +        self.vm1_dut.kill_all()
> +        self.dut.kill_all()
> +        time.sleep(2)
> +        pass
> +
> +    def tear_down_all(self):
> +        """
> +        Run after each test suite.
> +        """
> +        pass
> --
> 1.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-14  3:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13  8:52 [dts] [PATCH V1] add test suite vf kernel xu,gang
2017-03-14  3:02 ` Liu, Yong

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).