test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] tests/vm2vm_virtio_pmd: update testcase according to plan
@ 2019-07-15 23:21 lihong
  2019-08-07  3:43 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: lihong @ 2019-07-15 23:21 UTC (permalink / raw)
  To: dts; +Cc: lihong

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 tests/TestSuite_vm2vm_virtio_pmd.py | 153 ++++++++++++++++++++++++++++++------
 1 file changed, 128 insertions(+), 25 deletions(-)

diff --git a/tests/TestSuite_vm2vm_virtio_pmd.py b/tests/TestSuite_vm2vm_virtio_pmd.py
index 9a62ac8..ca97d4d 100644
--- a/tests/TestSuite_vm2vm_virtio_pmd.py
+++ b/tests/TestSuite_vm2vm_virtio_pmd.py
@@ -33,12 +33,16 @@
 DPDK Test suite.
 
 Test cases for Vhost-user/Virtio-pmd VM2VM
+Test cases for vhost/virtio-pmd(0.95/1.0) VM2VM test with 3 rx/tx paths,
+includes mergeable, normal, vector_rx.
+About mergeable path check the large packet payload.
 """
 import re
 import time
 import utils
 from virt_common import VM
 from test_case import TestCase
+from packet import load_pcapfile
 
 
 class TestVM2VMVirtioPMD(TestCase):
@@ -53,13 +57,14 @@ class TestVM2VMVirtioPMD(TestCase):
         self.coremask = utils.create_mask(self.cores)
         self.memory_channel = self.dut.get_memory_channels()
         self.vm_num = 2
+        self.dump_pcap = "/root/pdump-rx.pcap"
 
     def set_up(self):
         """
         run before each test case.
         """
         self.table_header = ["FrameSize(B)", "Mode",
-                            "Throughput(Mpps)", "Path"]
+                            "Throughput(Mpps)", "Queue Number", "Path"]
         self.result_table_create(self.table_header)
         self.dut.send_expect("killall -s INT testpmd", "#")
         self.dut.send_expect("killall -s INT qemu-system-x86_64", "#")
@@ -68,6 +73,20 @@ class TestVM2VMVirtioPMD(TestCase):
         self.vm_dut = []
         self.vm = []
 
+    def enable_pcap_lib_in_dpdk(self, client_dut):
+        """
+        enable pcap lib in dpdk code and recompile
+        """
+        client_dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=n$/CONFIG_RTE_LIBRTE_PMD_PCAP=y/' config/common_base", "#")
+        client_dut.build_install_dpdk(self.target)
+
+    def disable_pcap_lib_in_dpdk(self, client_dut):
+        """
+        reset pcap lib in dpdk and recompile
+        """
+        client_dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_PCAP=y$/CONFIG_RTE_LIBRTE_PMD_PCAP=n/' config/common_base", "#")
+        client_dut.build_install_dpdk(self.target)
+
     def start_vhost_testpmd(self):
         """
         launch the testpmd on vhost side
@@ -84,22 +103,32 @@ class TestVM2VMVirtioPMD(TestCase):
         self.vhost.send_expect("set fwd mac", "testpmd> ", 30)
         self.vhost.send_expect("start", "testpmd> ", 30)
 
-    def start_vm_testpmd(self, vm_client, path_mode):
+    def start_vm_testpmd(self, vm_client, path_mode, extern_param=""):
         """
         launch the testpmd in vm
         """
         if path_mode == "mergeable":
-            command = self.dut.target + "/app/testpmd " + \
-                        "-c 0x3 -n 4 -- -i --tx-offloads=0x00 " + \
-                        "--enable-hw-vlan-strip --txd=1024 --rxd=1024"
+            command = self.dut.target + "/app/testpmd -c 0x3 -n 4 " + \
+                        "--file-prefix=virtio -- -i --tx-offloads=0x00 " + \
+                        "--enable-hw-vlan-strip --txd=1024 --rxd=1024 %s"
         elif path_mode == "normal":
-            command = self.dut.target + "/app/testpmd " + \
-                        "-c 0x3 -n 4 -- -i --tx-offloads=0x00 " + \
-                        "--enable-hw-vlan-strip --txd=1024 --rxd=1024"
+            command = self.dut.target + "/app/testpmd -c 0x3 -n 4 " + \
+                        "--file-prefix=virtio -- -i --tx-offloads=0x00 " + \
+                        "--enable-hw-vlan-strip --txd=1024 --rxd=1024 %s"
         elif path_mode == "vector_rx":
-            command = self.dut.target + "/app/testpmd " + \
-                        "-c 0x3 -n 4 -- -i --txd=1024 --rxd=1024"
-        vm_client.send_expect(command, "testpmd> ", 20)
+            command = self.dut.target + "/app/testpmd -c 0x3 -n 4 " + \
+                        "--file-prefix=virtio -- -i --txd=1024 --rxd=1024 %s"
+        vm_client.send_expect(command % extern_param, "testpmd> ", 20)
+
+    def launch_pdump_in_vm(self, vm_client):
+        """
+        bootup pdump in VM
+        """
+        self.vm_dump = vm_client.new_session(suite="pdump")
+        command_line = self.target + "/app/dpdk-pdump " + \
+                    "-v --file-prefix=virtio -- " + \
+                    "--pdump  'port=0,queue=*,rx-dev=%s,mbuf-size=8000'"
+        self.vm_dump.send_expect(command_line % self.dump_pcap, 'Port')
 
     def start_vms(self, mode=0, mergeable=True):
         """
@@ -153,6 +182,7 @@ class TestVM2VMVirtioPMD(TestCase):
         results_row = [frame_size]
         results_row.append(case_info)
         results_row.append(Mpps)
+        results_row.append(1)
         results_row.append(path)
         self.result_table_add(results_row)
 
@@ -170,34 +200,51 @@ class TestVM2VMVirtioPMD(TestCase):
         self.update_table_info(mode, 64, Mpps, path)
         self.result_table_print()
 
+    def check_packet_payload_valid(self, vm_dut):
+        """
+        check the payload is valid
+        """
+        # stop pdump
+        self.vm_dump.send_expect('^c', '# ', 60)
+        # quit testpmd
+        vm_dut.send_expect('quit', '#', 60)
+        time.sleep(2)
+        vm_dut.session.copy_file_from(src="%s" % self.dump_pcap, dst="%s" % self.dump_pcap)
+        pkts = load_pcapfile(self.dump_pcap)
+        self.verify(len(pkts) == 10, "The vm0 do not capture all the packets")
+        data = str(pkts[0].pktgen.pkt['Raw'])
+        for i in range(1, 10):
+            value = str(pkts[i].pktgen.pkt['Raw'])
+            self.verify(data == value, "the payload in receive packets has been changed")
+
     def stop_all_apps(self):
         for i in range(len(self.vm)):
             self.vm_dut[i].send_expect("quit", "#", 20)
             self.vm[i].stop()
         self.vhost.send_expect("quit", "#", 30)
 
-    def test_vhost_vm2vm_virito_pmd_with_mergeable_path(self):
+    def test_vhost_vm2vm_virtio_pmd_with_normal_path(self):
         """
-        vhost-user + virtio-pmd with mergeable path
+        vhost-user + virtio-pmd with normal path
         """
-        path_mode = "mergeable"
+        path_mode = "normal"
         self.start_vhost_testpmd()
-        self.start_vms(mode=0, mergeable=True)
+        self.start_vms(mode=0, mergeable=False)
         self.start_vm_testpmd(self.vm_dut[0], path_mode)
         self.start_vm_testpmd(self.vm_dut[1], path_mode)
-        self.send_and_verify(mode="virtio 0.95", path=path_mode)
+        self.send_and_verify(mode="virtio 0.95 normal path", path=path_mode)
         self.stop_all_apps()
 
-    def test_vhost_vm2vm_virtio_pmd_with_normal_path(self):
+    def test_vhost_vm2vm_virito_10_pmd_with_normal_path(self):
         """
-        vhost-user + virtio-pmd with normal path
+        vhost-user + virtio1.0-pmd with normal path
         """
         path_mode = "normal"
         self.start_vhost_testpmd()
-        self.start_vms(mode=0, mergeable=False)
+        self.start_vms(mode=1, mergeable=False)
         self.start_vm_testpmd(self.vm_dut[0], path_mode)
         self.start_vm_testpmd(self.vm_dut[1], path_mode)
-        self.send_and_verify(mode="virtio 0.95", path=path_mode)
+        self.send_and_verify(mode="virtio 1.0 normal path", path=path_mode)
         self.stop_all_apps()
 
     def test_vhost_vm2vm_virtio_pmd_with_vector_rx_path(self):
@@ -209,19 +256,75 @@ class TestVM2VMVirtioPMD(TestCase):
         self.start_vms(mode=0, mergeable=False)
         self.start_vm_testpmd(self.vm_dut[0], path_mode)
         self.start_vm_testpmd(self.vm_dut[1], path_mode)
-        self.send_and_verify(mode="virtio 0.95", path=path_mode)
+        self.send_and_verify(mode="virtio 0.95 vector_rx", path=path_mode)
+        self.stop_all_apps()
+
+    def test_vhost_vm2vm_virtioi10_pmd_with_vector_rx_path(self):
+        """
+        vhost-user + virtio1.0-pmd with vector_rx path
+        """
+        path_mode = "vector_rx"
+        self.start_vhost_testpmd()
+        self.start_vms(mode=1, mergeable=False)
+        self.start_vm_testpmd(self.vm_dut[0], path_mode)
+        self.start_vm_testpmd(self.vm_dut[1], path_mode)
+        self.send_and_verify(mode="virtio 1.0 vector_rx", path=path_mode)
+        self.stop_all_apps()
+
+    def test_vhost_vm2vm_virito_pmd_with_mergeable_path(self):
+        """
+        vhost-user + virtio-pmd with mergeable path test with payload check
+        """
+        path_mode = "mergeable"
+        extern_param = '--max-pkt-len=9600'
+        self.start_vhost_testpmd()
+        self.start_vms(mode=0, mergeable=True)
+        # enable pcap in VM0
+        self.enable_pcap_lib_in_dpdk(self.vm_dut[0])
+        # git the vm enough huge to run pdump
+        self.vm_dut[0].set_huge_pages(2048)
+        # start testpmd and pdump in VM0
+        self.start_vm_testpmd(self.vm_dut[0], path_mode, extern_param)
+        self.vm_dut[0].send_expect('set fwd rxonly', 'testpmd> ', 30)
+        self.vm_dut[0].send_expect('start', 'testpmd> ', 30)
+        self.launch_pdump_in_vm(self.vm_dut[0])
+        # start testpmd in VM1 and start to send packet
+        self.start_vm_testpmd(self.vm_dut[1], path_mode, extern_param)
+        self.vm_dut[1].send_expect('set txpkts 2000,2000,2000,2000', 'testpmd> ', 30)
+        self.vm_dut[1].send_expect('set burst 1', 'testpmd> ', 30)
+        self.vm_dut[1].send_expect('start tx_first 10', 'testpmd> ', 30)
+         # check the packet in vm0
+        self.check_packet_payload_valid(self.vm_dut[0])
+        # reset the evn in vm
+        self.disable_pcap_lib_in_dpdk(self.vm_dut[0])
         self.stop_all_apps()
 
     def test_vhost_vm2vm_virito_10_pmd_with_mergeable_path(self):
         """
-        vhost-user + virtio1.0-pmd with mergeable path
+        vhost-user + virtio1.0-pmd with mergeable path test with payload check
         """
         path_mode = "mergeable"
+        extern_param = '--max-pkt-len=9600'
         self.start_vhost_testpmd()
         self.start_vms(mode=1, mergeable=True)
-        self.start_vm_testpmd(self.vm_dut[0], path_mode)
-        self.start_vm_testpmd(self.vm_dut[1], path_mode)
-        self.send_and_verify(mode="virtio 1.0", path=path_mode)
+        # enable pcap in VM0
+        self.enable_pcap_lib_in_dpdk(self.vm_dut[0])
+        # git the vm enough huge to run pdump
+        self.vm_dut[0].set_huge_pages(2048)
+        # start testpmd and pdump in VM0
+        self.start_vm_testpmd(self.vm_dut[0], path_mode, extern_param)
+        self.vm_dut[0].send_expect('set fwd rxonly', 'testpmd> ', 30)
+        self.vm_dut[0].send_expect('start', 'testpmd> ', 30)
+        self.launch_pdump_in_vm(self.vm_dut[0])
+        # start testpmd in VM1 and start to send packet
+        self.start_vm_testpmd(self.vm_dut[1], path_mode, extern_param)
+        self.vm_dut[1].send_expect('set txpkts 2000,2000,2000,2000', 'testpmd> ', 30)
+        self.vm_dut[1].send_expect('set burst 1', 'testpmd> ', 30)
+        self.vm_dut[1].send_expect('start tx_first 10', 'testpmd> ', 30)
+         # check the packet in vm0
+        self.check_packet_payload_valid(self.vm_dut[0])
+        # reset the evn in vm
+        self.disable_pcap_lib_in_dpdk(self.vm_dut[0])
         self.stop_all_apps()
 
     def tear_down(self):
-- 
2.7.4


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

end of thread, other threads:[~2019-08-07  3:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15 23:21 [dts] [PATCH V1] tests/vm2vm_virtio_pmd: update testcase according to plan lihong
2019-08-07  3:43 ` Tu, Lijuan

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