test suite reviews and discussions
 help / color / Atom feed
* [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case
@ 2019-09-19 10:07 zhu wenhui
  2019-09-21 13:33 ` Wang, Yinan
  2019-09-24  9:19 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: zhu wenhui @ 2019-09-19 10:07 UTC (permalink / raw)
  To: dts; +Cc: zhu wenhui

Add new cases.

Signed-off-by: zhu wenhui <wenhuix.zhu@intel.com>
---
 ...stSuite_virtio_user_as_exceptional_path.py | 159 ++++++++++++++----
 1 file changed, 125 insertions(+), 34 deletions(-)

diff --git a/tests/TestSuite_virtio_user_as_exceptional_path.py b/tests/TestSuite_virtio_user_as_exceptional_path.py
index 0330f7e..2ca29ed 100644
--- a/tests/TestSuite_virtio_user_as_exceptional_path.py
+++ b/tests/TestSuite_virtio_user_as_exceptional_path.py
@@ -38,8 +38,9 @@ import re
 import time
 import utils
 from test_case import TestCase
+from settings import HEADER_SIZE
 import vhost_peer_conf as peer
-
+from pktgen import PacketGeneratorHelper
 
 class TestVirtioUserAsExceptionalPath(TestCase):
 
@@ -47,14 +48,42 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         # Get and verify the ports
         self.dut_ports = self.dut.get_ports()
         self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
-        # Get the port's socket and get the core for testpmd
-        self.pf = self.dut_ports[0]
-        netdev = self.dut.ports_info[self.pf]['port']
+        self.memory_channel = self.dut.get_memory_channels()
+        self.pci0 = self.dut.ports_info[0]['pci']
+        pf_info = self.dut_ports[0]
+        netdev = self.dut.ports_info[pf_info]['port']
         self.socket = netdev.get_nic_socket()
+        self.virtio_ip1 = "2.2.2.1"
+        self.virtio_ip2 = "2.2.2.21"
+        self.virtio_mac = "52:54:00:00:00:01"
+        self.out_path = '/tmp'
+
+        out = self.tester.send_expect('ls -d %s' % self.out_path, '# ')
+        if 'No such file or directory' in out:
+            self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')
+        # set diff arg about mem_socket base on socket number
+        if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
+            self.socket_mem = '1024'
+        else:
+            self.socket_mem = '1024,1024'
+        self.pktgen_helper = PacketGeneratorHelper()
+        self.peer_pci_setup = False
+        self.prepare_dpdk()
+
+    def set_up(self):
+        #
+        # Run before each test case.
+        #
+        # Clean the execution ENV
+        self.dut.send_expect("rm -rf ./vhost-net*", "#")
+        self.dut.send_expect("killall -s INT testpmd", "#")
+        self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
+        self.dut.send_expect("modprobe vhost-net", "#")
+        self.peer_pci_setup = False
+
+    def get_pci_info_from_cfg(self):
+        # Get the port's socket and get the core for testpmd
         self.cores = self.dut.get_core_list("1S/2C/1T", socket=self.socket)
-        self.virtio_ip1 = "1.1.1.2"
-        self.virtio_mac1 = "52:54:00:00:00:01"
-        self.memory_channel = self.dut.get_memory_channels()
 
         self.pci = peer.get_pci_info()
         self.pci_drv = peer.get_pci_driver_info()
@@ -71,24 +100,32 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         self.dut.send_expect(
             "./usertools/dpdk-devbind.py -b igb_uio %s" %
             self.pci, '#', 30)
+        self.peer_pci_setup = True
 
-        # set diff arg about mem_socket base on socket number
-        if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
-            self.socket_mem = '1024'
+    def launch_testpmd_vhost(self):
+        if self.queue == 1:
+            comment = ""
+            cores_number = 3
         else:
-            self.socket_mem = '1024,1024'
-
-        self.prepare_dpdk()
-
-    def set_up(self):
-        #
-        # Run before each test case.
-        #
-        # Clean the execution ENV
-        self.dut.send_expect("rm -rf ./vhost-net*", "#")
-        self.dut.send_expect("killall -s INT testpmd", "#")
-        self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
-        self.dut.send_expect("modprobe vhost-net", "#")
+            comment = " --txq=2 --rxq=2 --nb-cores=1"
+            cores_number = 4
+        cores_config = '1S/%sC/1T' % cores_number
+        cores_list = self.dut.get_core_list(cores_config, socket=self.socket)
+        self.verify(len(cores_list) >= cores_number, "Failed to get cores list")
+        core_mask = utils.create_mask(cores_list[0:2])
+        self.testcmd = self.target + "/app/testpmd -c %s -n %d -w %s  --socket-mem %s" \
+                        + " --vdev=virtio_user0,mac=%s,path=/dev/vhost-net,"\
+                        "queue_size=1024,queues=%s -- -i --rxd=1024 --txd=1024 %s"
+        self.testcmd_start = self.testcmd % (core_mask, self.memory_channel,
+                self.pci0, self.socket_mem, self.virtio_mac, self.queue, comment)
+        self.vhost_user = self.dut.new_session(suite="user")
+        self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120)
+        self.vhost_user.send_expect("start", "testpmd>", 120)
+        vhost_pid = self.dut.send_expect("ps -aux | grep vhost | grep -v grep | awk '{print $2}'", "# ")
+        vhost_pid_list = vhost_pid.split("\r\n")
+        self.dut.send_expect("taskset -pc %s %s" % (cores_list[-1], vhost_pid_list[1]), "# ")
+        if self.queue == 2:
+            self.dut.send_expect("taskset -pc %s %s" % (cores_list[-2], vhost_pid_list[2]), "# ")
 
     def launch_testpmd_exception_path(self):
         self.testcmd = self.target + "/app/testpmd -c %s -n %d --socket-mem %s --legacy-mem" \
@@ -96,7 +133,7 @@ class TestVirtioUserAsExceptionalPath(TestCase):
                 + " --rxd=1024 --txd=1024"
         self.coremask = utils.create_mask(self.cores)
         self.testcmd_start = self.testcmd % (self.coremask, self.memory_channel,
-                                    self.socket_mem, self.virtio_mac1)
+                                    self.socket_mem, self.virtio_mac)
         self.vhost_user = self.dut.new_session(suite="user")
         self.vhost_user.send_expect("modprobe vhost-net", "#", 120)
         self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120)
@@ -115,6 +152,12 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         self.vhost_user.send_expect("port start 1", "testpmd> ", 120)
         self.vhost_user.send_expect("start", "testpmd> ", 120)
 
+    def set_route_table(self):
+        self.dut.send_expect("ifconfig tap0 up", "#")
+        self.dut.send_expect("ifconfig tap0 2.2.2.2/24 up", "#")
+        self.dut.send_expect("route add -net 2.2.2.0/24 gw 2.2.2.1 dev tap0", "#")
+        self.dut.send_expect("arp -s 2.2.2.1 %s" % self.virtio_mac, "#")
+
     def prepare_tap_device(self):
         self.dut.send_expect("ifconfig tap0 up", "#")
         self.dut.send_expect("ifconfig tap0 1.1.1.2", "#")
@@ -146,6 +189,7 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         self.dut.send_expect(
             "sed -i '/parse_ethernet(eth_hdr, &info/i\#endif' ./app/test-pmd/csumonly.c", "#")
         self.dut.build_install_dpdk(self.dut.target)
+        time.sleep(3)
 
     def unprepare_dpdk(self):
         # Recovery the DPDK code to original
@@ -172,7 +216,37 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         self.output_result = "Iperf throughput is %s" % iperfdata[-1]
         self.logger.info(self.output_result)
 
+    def send_and_verify_loss(self):
+        header_row = ["Frame Size", "zero_loss_rate", "tx_pkts", "rx_pkts", "queue"]
+        self.result_table_create(header_row)
+        frame_size = 64
+        tgen_input = []
+        port = self.tester.get_local_port(self.dut_ports[0])
+        payload = frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - HEADER_SIZE['tcp']
+        flow1 = 'Ether(dst="%s")/IP(dst="%s", src="%s")/TCP()/("X"*%d)' % \
+                (self.virtio_mac, self.virtio_ip2, self.virtio_ip1, payload)
+        self.tester.scapy_append('wrpcap("%s/exceptional_path.pcap", %s)' % (self.out_path, flow1))
+        self.tester.scapy_execute()
+        tgen_input.append((port, port, "%s/exceptional_path.pcap" % self.out_path))
+        for rate_value in range(20, -1, -1):
+            rate_value = rate_value * 0.5
+            vm_config = {'mac': {'dst': {'range': 1, 'step': 1, 'action': 'inc'}, }, }
+            self.tester.pktgen.clear_streams()
+            streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, rate_value, vm_config, self.tester.pktgen)
+            options = {'duration': 5, 'rate': rate_value, 'delay': 5}
+            result = self.tester.pktgen.measure_loss(stream_ids=streams, options=options)
+            tx_pkts = result[1]
+            rx_pkts = result[2]
+            if tx_pkts - rx_pkts <= 20:
+                break
+        data_row = [frame_size, rate_value, tx_pkts, rx_pkts, self.queue]
+        self.result_table_add(data_row)
+        self.result_table_print()
+        self.vhost_user.send_expect("quit", "#")
+        self.verify(rate_value > 0, "The received package did not reach the expected value")
+
     def test_vhost_exception_path_TAP_original(self):
+        self.get_pci_info_from_cfg()
         self.config_kernel_nic_host()
         self.launch_testpmd_exception_path()
         self.dut.get_session_output(timeout=2)
@@ -195,6 +269,7 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         self.dut.close_session(self.iperf)
 
     def test_vhost_exception_path_NIC_original(self):
+        self.get_pci_info_from_cfg()
         self.config_kernel_nic_host()
         self.launch_testpmd_exception_path()
         time.sleep(5)
@@ -216,27 +291,43 @@ class TestVirtioUserAsExceptionalPath(TestCase):
         self.dut.send_expect("ip netns del ns1", "#")
         self.dut.close_session(self.iperf)
 
+    def test_perf_vhost_single_queue(self):
+        self.queue = 1
+        self.launch_testpmd_vhost()
+        self.set_route_table()
+        self.send_and_verify_loss()
+
+    def test_perf_vhost_multiple_queue(self):
+        self.queue = 2
+        self.launch_testpmd_vhost()
+        self.set_route_table()
+        self.send_and_verify_loss()
+
     def tear_down(self):
         #
         # Run after each test case.
         #
+        self.dut.kill_all()
+        self.dut.close_session(self.vhost_user)
         self.dut.send_expect("killall -s INT testpmd", "#")
         self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
         self.dut.send_expect("rm -rf ./vhost-net", "#")
         time.sleep(2)
-        self.dut.send_expect(
-            "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ', 30)
-        self.dut.send_expect(
-            "./usertools/dpdk-devbind.py -b %s %s" %
-            (self.pci_drv, self.peer_pci), '# ', 30)
+        if self.peer_pci_setup:
+            self.dut.send_expect(
+                "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ', 30)
+            self.dut.send_expect(
+                "./usertools/dpdk-devbind.py -b %s %s" %
+                (self.pci_drv, self.peer_pci), '# ', 30)
 
     def tear_down_all(self):
         """
         Run after each test suite.
         """
         self.unprepare_dpdk()
-        self.dut.send_expect(
-            "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
-        self.dut.send_expect(
-            "./usertools/dpdk-devbind.py -b %s %s" %
-            (self.pci_drv, self.pci), '# ', 30)
+        if self.peer_pci_setup:
+            self.dut.send_expect(
+                "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
+            self.dut.send_expect(
+                "./usertools/dpdk-devbind.py -b %s %s" %
+                (self.pci_drv, self.pci), '# ', 30)
-- 
2.17.2


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

* Re: [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case
  2019-09-19 10:07 [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case zhu wenhui
@ 2019-09-21 13:33 ` Wang, Yinan
  2019-09-24  9:19 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Wang, Yinan @ 2019-09-21 13:33 UTC (permalink / raw)
  To: Zhu, WenhuiX, dts; +Cc: Zhu, WenhuiX

Acked-by: Wang, Yinan <yinan.wang@intel.com>

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhu wenhui
> Sent: 2019^[$BG/^[(B9^[$B7n^[(B19^[$BF|^[(B 18:08
> To: dts@dpdk.org
> Cc: Zhu, WenhuiX <wenhuix.zhu@intel.com>
> Subject: [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case
> 
> Add new cases.
> 
> Signed-off-by: zhu wenhui <wenhuix.zhu@intel.com>
> ---
>  ...stSuite_virtio_user_as_exceptional_path.py | 159 ++++++++++++++----
>  1 file changed, 125 insertions(+), 34 deletions(-)
> 
> diff --git a/tests/TestSuite_virtio_user_as_exceptional_path.py
> b/tests/TestSuite_virtio_user_as_exceptional_path.py
> index 0330f7e..2ca29ed 100644
> --- a/tests/TestSuite_virtio_user_as_exceptional_path.py
> +++ b/tests/TestSuite_virtio_user_as_exceptional_path.py
> @@ -38,8 +38,9 @@ import re
>  import time
>  import utils
>  from test_case import TestCase
> +from settings import HEADER_SIZE
>  import vhost_peer_conf as peer
> -
> +from pktgen import PacketGeneratorHelper
> 
>  class TestVirtioUserAsExceptionalPath(TestCase):
> 
> @@ -47,14 +48,42 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          # Get and verify the ports
>          self.dut_ports = self.dut.get_ports()
>          self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
> -        # Get the port's socket and get the core for testpmd
> -        self.pf = self.dut_ports[0]
> -        netdev = self.dut.ports_info[self.pf]['port']
> +        self.memory_channel = self.dut.get_memory_channels()
> +        self.pci0 = self.dut.ports_info[0]['pci']
> +        pf_info = self.dut_ports[0]
> +        netdev = self.dut.ports_info[pf_info]['port']
>          self.socket = netdev.get_nic_socket()
> +        self.virtio_ip1 = "2.2.2.1"
> +        self.virtio_ip2 = "2.2.2.21"
> +        self.virtio_mac = "52:54:00:00:00:01"
> +        self.out_path = '/tmp'
> +
> +        out = self.tester.send_expect('ls -d %s' % self.out_path, '# ')
> +        if 'No such file or directory' in out:
> +            self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')
> +        # set diff arg about mem_socket base on socket number
> +        if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
> +            self.socket_mem = '1024'
> +        else:
> +            self.socket_mem = '1024,1024'
> +        self.pktgen_helper = PacketGeneratorHelper()
> +        self.peer_pci_setup = False
> +        self.prepare_dpdk()
> +
> +    def set_up(self):
> +        #
> +        # Run before each test case.
> +        #
> +        # Clean the execution ENV
> +        self.dut.send_expect("rm -rf ./vhost-net*", "#")
> +        self.dut.send_expect("killall -s INT testpmd", "#")
> +        self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
> +        self.dut.send_expect("modprobe vhost-net", "#")
> +        self.peer_pci_setup = False
> +
> +    def get_pci_info_from_cfg(self):
> +        # Get the port's socket and get the core for testpmd
>          self.cores = self.dut.get_core_list("1S/2C/1T", socket=self.socket)
> -        self.virtio_ip1 = "1.1.1.2"
> -        self.virtio_mac1 = "52:54:00:00:00:01"
> -        self.memory_channel = self.dut.get_memory_channels()
> 
>          self.pci = peer.get_pci_info()
>          self.pci_drv = peer.get_pci_driver_info() @@ -71,24 +100,32 @@ class
> TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.send_expect(
>              "./usertools/dpdk-devbind.py -b igb_uio %s" %
>              self.pci, '#', 30)
> +        self.peer_pci_setup = True
> 
> -        # set diff arg about mem_socket base on socket number
> -        if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
> -            self.socket_mem = '1024'
> +    def launch_testpmd_vhost(self):
> +        if self.queue == 1:
> +            comment = ""
> +            cores_number = 3
>          else:
> -            self.socket_mem = '1024,1024'
> -
> -        self.prepare_dpdk()
> -
> -    def set_up(self):
> -        #
> -        # Run before each test case.
> -        #
> -        # Clean the execution ENV
> -        self.dut.send_expect("rm -rf ./vhost-net*", "#")
> -        self.dut.send_expect("killall -s INT testpmd", "#")
> -        self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
> -        self.dut.send_expect("modprobe vhost-net", "#")
> +            comment = " --txq=2 --rxq=2 --nb-cores=1"
> +            cores_number = 4
> +        cores_config = '1S/%sC/1T' % cores_number
> +        cores_list = self.dut.get_core_list(cores_config, socket=self.socket)
> +        self.verify(len(cores_list) >= cores_number, "Failed to get cores list")
> +        core_mask = utils.create_mask(cores_list[0:2])
> +        self.testcmd = self.target + "/app/testpmd -c %s -n %d -w %s
> --socket-mem %s" \
> +                        + "
> --vdev=virtio_user0,mac=%s,path=/dev/vhost-net,"\
> +                        "queue_size=1024,queues=%s -- -i --rxd=1024
> --txd=1024 %s"
> +        self.testcmd_start = self.testcmd % (core_mask,
> self.memory_channel,
> +                self.pci0, self.socket_mem, self.virtio_mac, self.queue,
> comment)
> +        self.vhost_user = self.dut.new_session(suite="user")
> +        self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120)
> +        self.vhost_user.send_expect("start", "testpmd>", 120)
> +        vhost_pid = self.dut.send_expect("ps -aux | grep vhost | grep -v grep
> | awk '{print $2}'", "# ")
> +        vhost_pid_list = vhost_pid.split("\r\n")
> +        self.dut.send_expect("taskset -pc %s %s" % (cores_list[-1],
> vhost_pid_list[1]), "# ")
> +        if self.queue == 2:
> +            self.dut.send_expect("taskset -pc %s %s" % (cores_list[-2],
> + vhost_pid_list[2]), "# ")
> 
>      def launch_testpmd_exception_path(self):
>          self.testcmd = self.target + "/app/testpmd -c %s -n %d
> --socket-mem %s --legacy-mem" \ @@ -96,7 +133,7 @@ class
> TestVirtioUserAsExceptionalPath(TestCase):
>                  + " --rxd=1024 --txd=1024"
>          self.coremask = utils.create_mask(self.cores)
>          self.testcmd_start = self.testcmd % (self.coremask,
> self.memory_channel,
> -                                    self.socket_mem, self.virtio_mac1)
> +                                    self.socket_mem, self.virtio_mac)
>          self.vhost_user = self.dut.new_session(suite="user")
>          self.vhost_user.send_expect("modprobe vhost-net", "#", 120)
>          self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120)
> @@ -115,6 +152,12 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.vhost_user.send_expect("port start 1", "testpmd> ", 120)
>          self.vhost_user.send_expect("start", "testpmd> ", 120)
> 
> +    def set_route_table(self):
> +        self.dut.send_expect("ifconfig tap0 up", "#")
> +        self.dut.send_expect("ifconfig tap0 2.2.2.2/24 up", "#")
> +        self.dut.send_expect("route add -net 2.2.2.0/24 gw 2.2.2.1 dev tap0",
> "#")
> +        self.dut.send_expect("arp -s 2.2.2.1 %s" % self.virtio_mac,
> + "#")
> +
>      def prepare_tap_device(self):
>          self.dut.send_expect("ifconfig tap0 up", "#")
>          self.dut.send_expect("ifconfig tap0 1.1.1.2", "#") @@ -146,6 +189,7
> @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.send_expect(
>              "sed -i '/parse_ethernet(eth_hdr,
> &info/i\#endif' ./app/test-pmd/csumonly.c", "#")
>          self.dut.build_install_dpdk(self.dut.target)
> +        time.sleep(3)
> 
>      def unprepare_dpdk(self):
>          # Recovery the DPDK code to original @@ -172,7 +216,37 @@ class
> TestVirtioUserAsExceptionalPath(TestCase):
>          self.output_result = "Iperf throughput is %s" % iperfdata[-1]
>          self.logger.info(self.output_result)
> 
> +    def send_and_verify_loss(self):
> +        header_row = ["Frame Size", "zero_loss_rate", "tx_pkts", "rx_pkts",
> "queue"]
> +        self.result_table_create(header_row)
> +        frame_size = 64
> +        tgen_input = []
> +        port = self.tester.get_local_port(self.dut_ports[0])
> +        payload = frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] -
> HEADER_SIZE['tcp']
> +        flow1 = 'Ether(dst="%s")/IP(dst="%s", src="%s")/TCP()/("X"*%d)' % \
> +                (self.virtio_mac, self.virtio_ip2, self.virtio_ip1, payload)
> +        self.tester.scapy_append('wrpcap("%s/exceptional_path.pcap", %s)' %
> (self.out_path, flow1))
> +        self.tester.scapy_execute()
> +        tgen_input.append((port, port, "%s/exceptional_path.pcap" %
> self.out_path))
> +        for rate_value in range(20, -1, -1):
> +            rate_value = rate_value * 0.5
> +            vm_config = {'mac': {'dst': {'range': 1, 'step': 1, 'action': 'inc'}, }, }
> +            self.tester.pktgen.clear_streams()
> +            streams =
> self.pktgen_helper.prepare_stream_from_tginput(tgen_input, rate_value,
> vm_config, self.tester.pktgen)
> +            options = {'duration': 5, 'rate': rate_value, 'delay': 5}
> +            result = self.tester.pktgen.measure_loss(stream_ids=streams,
> options=options)
> +            tx_pkts = result[1]
> +            rx_pkts = result[2]
> +            if tx_pkts - rx_pkts <= 20:
> +                break
> +        data_row = [frame_size, rate_value, tx_pkts, rx_pkts, self.queue]
> +        self.result_table_add(data_row)
> +        self.result_table_print()
> +        self.vhost_user.send_expect("quit", "#")
> +        self.verify(rate_value > 0, "The received package did not reach
> + the expected value")
> +
>      def test_vhost_exception_path_TAP_original(self):
> +        self.get_pci_info_from_cfg()
>          self.config_kernel_nic_host()
>          self.launch_testpmd_exception_path()
>          self.dut.get_session_output(timeout=2)
> @@ -195,6 +269,7 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.close_session(self.iperf)
> 
>      def test_vhost_exception_path_NIC_original(self):
> +        self.get_pci_info_from_cfg()
>          self.config_kernel_nic_host()
>          self.launch_testpmd_exception_path()
>          time.sleep(5)
> @@ -216,27 +291,43 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.send_expect("ip netns del ns1", "#")
>          self.dut.close_session(self.iperf)
> 
> +    def test_perf_vhost_single_queue(self):
> +        self.queue = 1
> +        self.launch_testpmd_vhost()
> +        self.set_route_table()
> +        self.send_and_verify_loss()
> +
> +    def test_perf_vhost_multiple_queue(self):
> +        self.queue = 2
> +        self.launch_testpmd_vhost()
> +        self.set_route_table()
> +        self.send_and_verify_loss()
> +
>      def tear_down(self):
>          #
>          # Run after each test case.
>          #
> +        self.dut.kill_all()
> +        self.dut.close_session(self.vhost_user)
>          self.dut.send_expect("killall -s INT testpmd", "#")
>          self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
>          self.dut.send_expect("rm -rf ./vhost-net", "#")
>          time.sleep(2)
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ', 30)
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -b %s %s" %
> -            (self.pci_drv, self.peer_pci), '# ', 30)
> +        if self.peer_pci_setup:
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ',
> 30)
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -b %s %s" %
> +                (self.pci_drv, self.peer_pci), '# ', 30)
> 
>      def tear_down_all(self):
>          """
>          Run after each test suite.
>          """
>          self.unprepare_dpdk()
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -b %s %s" %
> -            (self.pci_drv, self.pci), '# ', 30)
> +        if self.peer_pci_setup:
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -b %s %s" %
> +                (self.pci_drv, self.pci), '# ', 30)
> --
> 2.17.2


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

* Re: [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case
  2019-09-19 10:07 [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case zhu wenhui
  2019-09-21 13:33 ` Wang, Yinan
@ 2019-09-24  9:19 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2019-09-24  9:19 UTC (permalink / raw)
  To: Zhu, WenhuiX, dts; +Cc: Zhu, WenhuiX

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhu wenhui
> Sent: Thursday, September 19, 2019 6:08 PM
> To: dts@dpdk.org
> Cc: Zhu, WenhuiX <wenhuix.zhu@intel.com>
> Subject: [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new
> case
> 
> Add new cases.
> 
> Signed-off-by: zhu wenhui <wenhuix.zhu@intel.com>
> ---
>  ...stSuite_virtio_user_as_exceptional_path.py | 159 ++++++++++++++----
>  1 file changed, 125 insertions(+), 34 deletions(-)
> 
> diff --git a/tests/TestSuite_virtio_user_as_exceptional_path.py
> b/tests/TestSuite_virtio_user_as_exceptional_path.py
> index 0330f7e..2ca29ed 100644
> --- a/tests/TestSuite_virtio_user_as_exceptional_path.py
> +++ b/tests/TestSuite_virtio_user_as_exceptional_path.py
> @@ -38,8 +38,9 @@ import re
>  import time
>  import utils
>  from test_case import TestCase
> +from settings import HEADER_SIZE
>  import vhost_peer_conf as peer
> -
> +from pktgen import PacketGeneratorHelper
> 
>  class TestVirtioUserAsExceptionalPath(TestCase):
> 
> @@ -47,14 +48,42 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          # Get and verify the ports
>          self.dut_ports = self.dut.get_ports()
>          self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
> -        # Get the port's socket and get the core for testpmd
> -        self.pf = self.dut_ports[0]
> -        netdev = self.dut.ports_info[self.pf]['port']
> +        self.memory_channel = self.dut.get_memory_channels()
> +        self.pci0 = self.dut.ports_info[0]['pci']
> +        pf_info = self.dut_ports[0]
> +        netdev = self.dut.ports_info[pf_info]['port']
>          self.socket = netdev.get_nic_socket()
> +        self.virtio_ip1 = "2.2.2.1"
> +        self.virtio_ip2 = "2.2.2.21"
> +        self.virtio_mac = "52:54:00:00:00:01"
> +        self.out_path = '/tmp'
> +
> +        out = self.tester.send_expect('ls -d %s' % self.out_path, '# ')
> +        if 'No such file or directory' in out:
> +            self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')
> +        # set diff arg about mem_socket base on socket number
> +        if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
> +            self.socket_mem = '1024'
> +        else:
> +            self.socket_mem = '1024,1024'
> +        self.pktgen_helper = PacketGeneratorHelper()
> +        self.peer_pci_setup = False
> +        self.prepare_dpdk()
> +
> +    def set_up(self):
> +        #
> +        # Run before each test case.
> +        #
> +        # Clean the execution ENV
> +        self.dut.send_expect("rm -rf ./vhost-net*", "#")
> +        self.dut.send_expect("killall -s INT testpmd", "#")
> +        self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
> +        self.dut.send_expect("modprobe vhost-net", "#")
> +        self.peer_pci_setup = False
> +
> +    def get_pci_info_from_cfg(self):
> +        # Get the port's socket and get the core for testpmd
>          self.cores = self.dut.get_core_list("1S/2C/1T", socket=self.socket)
> -        self.virtio_ip1 = "1.1.1.2"
> -        self.virtio_mac1 = "52:54:00:00:00:01"
> -        self.memory_channel = self.dut.get_memory_channels()
> 
>          self.pci = peer.get_pci_info()
>          self.pci_drv = peer.get_pci_driver_info() @@ -71,24 +100,32 @@ class
> TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.send_expect(
>              "./usertools/dpdk-devbind.py -b igb_uio %s" %
>              self.pci, '#', 30)
> +        self.peer_pci_setup = True
> 
> -        # set diff arg about mem_socket base on socket number
> -        if len(set([int(core['socket']) for core in self.dut.cores])) == 1:
> -            self.socket_mem = '1024'
> +    def launch_testpmd_vhost(self):
> +        if self.queue == 1:
> +            comment = ""
> +            cores_number = 3
>          else:
> -            self.socket_mem = '1024,1024'
> -
> -        self.prepare_dpdk()
> -
> -    def set_up(self):
> -        #
> -        # Run before each test case.
> -        #
> -        # Clean the execution ENV
> -        self.dut.send_expect("rm -rf ./vhost-net*", "#")
> -        self.dut.send_expect("killall -s INT testpmd", "#")
> -        self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
> -        self.dut.send_expect("modprobe vhost-net", "#")
> +            comment = " --txq=2 --rxq=2 --nb-cores=1"
> +            cores_number = 4
> +        cores_config = '1S/%sC/1T' % cores_number
> +        cores_list = self.dut.get_core_list(cores_config, socket=self.socket)
> +        self.verify(len(cores_list) >= cores_number, "Failed to get cores list")
> +        core_mask = utils.create_mask(cores_list[0:2])
> +        self.testcmd = self.target + "/app/testpmd -c %s -n %d -w %s  --socket-
> mem %s" \
> +                        + " --vdev=virtio_user0,mac=%s,path=/dev/vhost-net,"\
> +                        "queue_size=1024,queues=%s -- -i --rxd=1024 --txd=1024 %s"
> +        self.testcmd_start = self.testcmd % (core_mask, self.memory_channel,
> +                self.pci0, self.socket_mem, self.virtio_mac, self.queue, comment)
> +        self.vhost_user = self.dut.new_session(suite="user")
> +        self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120)
> +        self.vhost_user.send_expect("start", "testpmd>", 120)
> +        vhost_pid = self.dut.send_expect("ps -aux | grep vhost | grep -v grep |
> awk '{print $2}'", "# ")
> +        vhost_pid_list = vhost_pid.split("\r\n")
> +        self.dut.send_expect("taskset -pc %s %s" % (cores_list[-1],
> vhost_pid_list[1]), "# ")
> +        if self.queue == 2:
> +            self.dut.send_expect("taskset -pc %s %s" % (cores_list[-2],
> + vhost_pid_list[2]), "# ")
> 
>      def launch_testpmd_exception_path(self):
>          self.testcmd = self.target + "/app/testpmd -c %s -n %d --socket-mem %s
> --legacy-mem" \ @@ -96,7 +133,7 @@ class
> TestVirtioUserAsExceptionalPath(TestCase):
>                  + " --rxd=1024 --txd=1024"
>          self.coremask = utils.create_mask(self.cores)
>          self.testcmd_start = self.testcmd % (self.coremask,
> self.memory_channel,
> -                                    self.socket_mem, self.virtio_mac1)
> +                                    self.socket_mem, self.virtio_mac)
>          self.vhost_user = self.dut.new_session(suite="user")
>          self.vhost_user.send_expect("modprobe vhost-net", "#", 120)
>          self.vhost_user.send_expect(self.testcmd_start, "testpmd> ", 120) @@ -
> 115,6 +152,12 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.vhost_user.send_expect("port start 1", "testpmd> ", 120)
>          self.vhost_user.send_expect("start", "testpmd> ", 120)
> 
> +    def set_route_table(self):
> +        self.dut.send_expect("ifconfig tap0 up", "#")
> +        self.dut.send_expect("ifconfig tap0 2.2.2.2/24 up", "#")
> +        self.dut.send_expect("route add -net 2.2.2.0/24 gw 2.2.2.1 dev tap0",
> "#")
> +        self.dut.send_expect("arp -s 2.2.2.1 %s" % self.virtio_mac,
> + "#")
> +
>      def prepare_tap_device(self):
>          self.dut.send_expect("ifconfig tap0 up", "#")
>          self.dut.send_expect("ifconfig tap0 1.1.1.2", "#") @@ -146,6 +189,7 @@
> class TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.send_expect(
>              "sed -i '/parse_ethernet(eth_hdr, &info/i\#endif' ./app/test-
> pmd/csumonly.c", "#")
>          self.dut.build_install_dpdk(self.dut.target)
> +        time.sleep(3)
> 
>      def unprepare_dpdk(self):
>          # Recovery the DPDK code to original @@ -172,7 +216,37 @@ class
> TestVirtioUserAsExceptionalPath(TestCase):
>          self.output_result = "Iperf throughput is %s" % iperfdata[-1]
>          self.logger.info(self.output_result)
> 
> +    def send_and_verify_loss(self):
> +        header_row = ["Frame Size", "zero_loss_rate", "tx_pkts", "rx_pkts",
> "queue"]
> +        self.result_table_create(header_row)
> +        frame_size = 64
> +        tgen_input = []
> +        port = self.tester.get_local_port(self.dut_ports[0])
> +        payload = frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] -
> HEADER_SIZE['tcp']
> +        flow1 = 'Ether(dst="%s")/IP(dst="%s", src="%s")/TCP()/("X"*%d)' % \
> +                (self.virtio_mac, self.virtio_ip2, self.virtio_ip1, payload)
> +        self.tester.scapy_append('wrpcap("%s/exceptional_path.pcap", %s)' %
> (self.out_path, flow1))
> +        self.tester.scapy_execute()
> +        tgen_input.append((port, port, "%s/exceptional_path.pcap" %
> self.out_path))
> +        for rate_value in range(20, -1, -1):
> +            rate_value = rate_value * 0.5
> +            vm_config = {'mac': {'dst': {'range': 1, 'step': 1, 'action': 'inc'}, }, }
> +            self.tester.pktgen.clear_streams()
> +            streams =
> self.pktgen_helper.prepare_stream_from_tginput(tgen_input, rate_value,
> vm_config, self.tester.pktgen)
> +            options = {'duration': 5, 'rate': rate_value, 'delay': 5}
> +            result = self.tester.pktgen.measure_loss(stream_ids=streams,
> options=options)
> +            tx_pkts = result[1]
> +            rx_pkts = result[2]
> +            if tx_pkts - rx_pkts <= 20:
> +                break
> +        data_row = [frame_size, rate_value, tx_pkts, rx_pkts, self.queue]
> +        self.result_table_add(data_row)
> +        self.result_table_print()
> +        self.vhost_user.send_expect("quit", "#")
> +        self.verify(rate_value > 0, "The received package did not reach
> + the expected value")
> +
>      def test_vhost_exception_path_TAP_original(self):
> +        self.get_pci_info_from_cfg()
>          self.config_kernel_nic_host()
>          self.launch_testpmd_exception_path()
>          self.dut.get_session_output(timeout=2)
> @@ -195,6 +269,7 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.close_session(self.iperf)
> 
>      def test_vhost_exception_path_NIC_original(self):
> +        self.get_pci_info_from_cfg()
>          self.config_kernel_nic_host()
>          self.launch_testpmd_exception_path()
>          time.sleep(5)
> @@ -216,27 +291,43 @@ class TestVirtioUserAsExceptionalPath(TestCase):
>          self.dut.send_expect("ip netns del ns1", "#")
>          self.dut.close_session(self.iperf)
> 
> +    def test_perf_vhost_single_queue(self):
> +        self.queue = 1
> +        self.launch_testpmd_vhost()
> +        self.set_route_table()
> +        self.send_and_verify_loss()
> +
> +    def test_perf_vhost_multiple_queue(self):
> +        self.queue = 2
> +        self.launch_testpmd_vhost()
> +        self.set_route_table()
> +        self.send_and_verify_loss()
> +
>      def tear_down(self):
>          #
>          # Run after each test case.
>          #
> +        self.dut.kill_all()
> +        self.dut.close_session(self.vhost_user)
>          self.dut.send_expect("killall -s INT testpmd", "#")
>          self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
>          self.dut.send_expect("rm -rf ./vhost-net", "#")
>          time.sleep(2)
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ', 30)
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -b %s %s" %
> -            (self.pci_drv, self.peer_pci), '# ', 30)
> +        if self.peer_pci_setup:
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -u %s" % (self.peer_pci), '# ', 30)
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -b %s %s" %
> +                (self.pci_drv, self.peer_pci), '# ', 30)
> 
>      def tear_down_all(self):
>          """
>          Run after each test suite.
>          """
>          self.unprepare_dpdk()
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
> -        self.dut.send_expect(
> -            "./usertools/dpdk-devbind.py -b %s %s" %
> -            (self.pci_drv, self.pci), '# ', 30)
> +        if self.peer_pci_setup:
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -u %s" % (self.pci), '# ', 30)
> +            self.dut.send_expect(
> +                "./usertools/dpdk-devbind.py -b %s %s" %
> +                (self.pci_drv, self.pci), '# ', 30)
> --
> 2.17.2


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 10:07 [dts] [PATCH V1] tests/virtio_user_as_exceptional_path:add new case zhu wenhui
2019-09-21 13:33 ` Wang, Yinan
2019-09-24  9:19 ` Tu, Lijuan

test suite reviews and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ http://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/ public-inbox