[V3] tests/vm2vm_virtio_pmd: optimization testsuite

Message ID 20230106033102.1722440-1-weix.ling@intel.com (mailing list archive)
State Accepted
Headers
Series [V3] tests/vm2vm_virtio_pmd: optimization testsuite |

Checks

Context Check Description
ci/Intel-dts-format-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-suite-test success Testing OK

Commit Message

Ling, WeiX Jan. 6, 2023, 3:31 a.m. UTC
  1.Modify testcase name to discriminate different virtio protocol version.
2.Delete unused function and steps.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_vm2vm_virtio_pmd.py | 235 +++++++++-------------------
 1 file changed, 75 insertions(+), 160 deletions(-)
  

Comments

Tu, Lijuan Jan. 10, 2023, 7:40 a.m. UTC | #1
On Fri,  6 Jan 2023 11:31:02 +0800, Wei Ling <weix.ling@intel.com> wrote:
> 1.Modify testcase name to discriminate different virtio protocol version.
> 2.Delete unused function and steps.
> 
> Signed-off-by: Wei Ling <weix.ling@intel.com>

Acked-by: Lijuan Tu <lijuan.tu@intel.com>
Applied, thanks
  

Patch

diff --git a/tests/TestSuite_vm2vm_virtio_pmd.py b/tests/TestSuite_vm2vm_virtio_pmd.py
index 5721e829..3f1d873a 100644
--- a/tests/TestSuite_vm2vm_virtio_pmd.py
+++ b/tests/TestSuite_vm2vm_virtio_pmd.py
@@ -14,23 +14,28 @@  from framework.virt_common import VM
 
 class TestVM2VMVirtioPMD(TestCase):
     def set_up_all(self):
+        """
+        Run at the start of each test suite.
+        """
         self.dut_ports = self.dut.get_ports()
-        self.bind_nic_driver(self.dut_ports)
-        self.memory_channel = self.dut.get_memory_channels()
+        self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
         self.vm_num = 2
         self.dump_pcap = "/root/pdump-rx.pcap"
-        socket_num = len(set([int(core["socket"]) for core in self.dut.cores]))
-        self.socket_mem = ",".join(["1024"] * socket_num)
         self.base_dir = self.dut.base_dir.replace("~", "/root")
-        self.vhost_user = self.dut.new_session(suite="vhost")
-        self.virtio_user0 = None
-        self.virtio_user1 = None
+        self.vhost_user = self.dut.new_session(suite="vhost-user")
+        self.virtio_user0 = self.dut.new_session(suite="virtio-user0")
+        self.virtio_user1 = self.dut.new_session(suite="virtio-user1")
+        self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user)
+        self.virtio_user0_pmd = PmdOutput(self.dut, self.virtio_user0)
+        self.virtio_user1_pmd = PmdOutput(self.dut, self.virtio_user1)
+        self.cores_list = self.dut.get_core_list(config="all", socket=self.ports_socket)
+        self.vhost_user_core = self.cores_list[0:2]
+        self.virtio_user0_core = self.cores_list[2:4]
+        self.virtio_user1_core = self.cores_list[4:6]
         self.pci_info = self.dut.ports_info[0]["pci"]
-        self.app_testpmd_path = self.dut.apps_name["test-pmd"]
-        self.app_pdump = self.dut.apps_name["pdump"]
-        self.testpmd_name = self.app_testpmd_path.split("/")[-1]
-        self.pmd_vhost = PmdOutput(self.dut, self.vhost_user)
-        self.vm_config = "vhost_sample"
+        self.testpmd_path = self.dut.apps_name["test-pmd"]
+        self.pdump_path = self.dut.apps_name["pdump"]
+        self.testpmd_name = self.testpmd_path.split("/")[-1]
 
     def set_up(self):
         """
@@ -50,33 +55,25 @@  class TestVM2VMVirtioPMD(TestCase):
         self.vm_dut = []
         self.vm = []
 
-    def get_core_list(self, cores_num):
-        """
-        create core mask
-        """
-        self.core_config = "1S/%dC/1T" % cores_num
-        self.cores_list = self.dut.get_core_list(self.core_config)
-        self.verify(
-            len(self.cores_list) >= cores_num,
-            "There has not enough cores to test this case %s" % self.running_case,
-        )
-
     def start_vhost_testpmd(self):
         """
-        launch the testpmd on vhost side
+        launch the testpmd on vhost-user side
         """
-        vhost_mask = self.cores_list[0:2]
-        testcmd = self.app_testpmd_path + " "
-        vdev1 = "--vdev 'net_vhost0,iface=%s/vhost-net0,queues=1' " % self.base_dir
-        vdev2 = "--vdev 'net_vhost1,iface=%s/vhost-net1,queues=1' " % self.base_dir
-        eal_params = self.dut.create_eal_parameters(
-            cores=vhost_mask, no_pci=True, prefix="vhost"
+        eal_param = (
+            "--vdev 'net_vhost0,iface=vhost-net0,queues=1' "
+            "--vdev 'net_vhost1,iface=vhost-net1,queues=1'"
         )
-        para = " -- -i --nb-cores=1 --txd=1024 --rxd=1024"
-        self.command_line = testcmd + eal_params + vdev1 + vdev2 + para
-        self.vhost_user.send_expect(self.command_line, "testpmd> ", 30)
-        self.vhost_user.send_expect("set fwd mac", "testpmd> ", 30)
-        self.vhost_user.send_expect("start", "testpmd> ", 30)
+        param = "--nb-cores=1 --txd=1024 --rxd=1024"
+        self.vhost_user_pmd.start_testpmd(
+            cores=self.vhost_user_core,
+            eal_param=eal_param,
+            param=param,
+            no_pci=True,
+            prefix="vhost-user",
+            fixed_prefix=True,
+        )
+        self.vhost_user_pmd.execute_cmd("set fwd mac")
+        self.vhost_user_pmd.execute_cmd("start")
 
     @property
     def check_2M_env(self):
@@ -89,46 +86,46 @@  class TestVM2VMVirtioPMD(TestCase):
         """
         launch the testpmd as virtio with vhost_net1
         """
-        self.virtio_user1 = self.dut.new_session(suite="virtio_user1")
-        virtio_mask = self.cores_list[2:4]
-        testcmd = self.app_testpmd_path + " "
-        vdev = (
-            "--vdev=net_virtio_user1,mac=00:01:02:03:04:05,path=./vhost-net1,queues=1,%s "
+        eal_param = (
+            "--vdev=net_virtio_user1,mac=00:01:02:03:04:05,path=vhost-net1,queues=1,%s "
             % path_mode
         )
-        eal_params = self.dut.create_eal_parameters(
-            cores=virtio_mask, no_pci=True, prefix="virtio", ports=[self.pci_info]
-        )
         if self.check_2M_env:
-            eal_params += " --single-file-segments"
-        para = " -- -i --nb-cores=1 --txd=1024 --rxd=1024 %s" % extern_param
-        command_line = testcmd + eal_params + vdev + para
-        self.virtio_user1.send_expect(command_line, "testpmd> ", 30)
-        self.virtio_user1.send_expect("set fwd rxonly", "testpmd> ", 30)
-        self.virtio_user1.send_expect("start", "testpmd> ", 30)
+            eal_param += " --single-file-segments"
+        param = "--nb-cores=1 --txd=1024 --rxd=1024 %s" % extern_param
+        self.virtio_user1_pmd.start_testpmd(
+            cores=self.virtio_user1_core,
+            eal_param=eal_param,
+            param=param,
+            no_pci=True,
+            prefix="virtio-user1",
+            fixed_prefix=True,
+        )
+        self.virtio_user1_pmd.execute_cmd("set fwd rxonly")
+        self.virtio_user1_pmd.execute_cmd("start")
 
     def start_virtio_testpmd_with_vhost_net0(self, path_mode, extern_param):
         """
         launch the testpmd as virtio with vhost_net0
         """
-        self.virtio_user0 = self.dut.new_session(suite="virtio_user0")
-        virtio_mask = self.cores_list[4:6]
-        testcmd = self.app_testpmd_path + " "
-        vdev = (
-            "--vdev=net_virtio_user0,mac=00:01:02:03:04:05,path=./vhost-net0,queues=1,%s "
+        eal_param = (
+            "--vdev=net_virtio_user0,mac=00:01:02:03:04:05,path=vhost-net0,queues=1,%s "
             % path_mode
         )
-        eal_params = self.dut.create_eal_parameters(
-            cores=virtio_mask, no_pci=True, prefix="virtio0", ports=[self.pci_info]
-        )
         if self.check_2M_env:
-            eal_params += " --single-file-segments "
-        para = " -- -i --nb-cores=1 --txd=1024 --rxd=1024 %s" % extern_param
-        command_line = testcmd + eal_params + vdev + para
-        self.virtio_user0.send_expect(command_line, "testpmd> ", 30)
-        self.virtio_user0.send_expect("set txpkts 2000,2000,2000,2000", "testpmd> ", 30)
-        self.virtio_user0.send_expect("set burst 1", "testpmd> ", 30)
-        self.virtio_user0.send_expect("start tx_first 10", "testpmd> ", 30)
+            eal_param += " --single-file-segments"
+        param = "--nb-cores=1 --txd=1024 --rxd=1024 %s" % extern_param
+        self.virtio_user0_pmd.start_testpmd(
+            cores=self.virtio_user0_core,
+            eal_param=eal_param,
+            param=param,
+            no_pci=True,
+            prefix="virtio-user0",
+            fixed_prefix=True,
+        )
+        self.virtio_user0_pmd.execute_cmd("set txpkts 2000,2000,2000,2000")
+        self.virtio_user0_pmd.execute_cmd("set burst 1")
+        self.virtio_user0_pmd.execute_cmd("start tx_first 10")
 
     def start_vm_testpmd(
         self, vm_client, path_mode, extern_param="", virtio_net_pci=""
@@ -142,7 +139,7 @@  class TestVM2VMVirtioPMD(TestCase):
         w_pci_str = " ".join(w_pci_list)
         if path_mode == "mergeable":
             command = (
-                self.app_testpmd_path
+                self.testpmd_path
                 + " -c 0x3 -n 4 "
                 + "--file-prefix=virtio -- -i --tx-offloads=0x00 --rx-offloads=0x00002000 "
                 + "--enable-hw-vlan-strip "
@@ -151,7 +148,7 @@  class TestVM2VMVirtioPMD(TestCase):
             vm_client.send_expect(command % extern_param, "testpmd> ", 20)
         elif path_mode == "normal":
             command = (
-                self.app_testpmd_path
+                self.testpmd_path
                 + " -c 0x3 -n 4 "
                 + "--file-prefix=virtio -- -i --tx-offloads=0x00 "
                 + "--enable-hw-vlan-strip "
@@ -160,21 +157,19 @@  class TestVM2VMVirtioPMD(TestCase):
             vm_client.send_expect(command % extern_param, "testpmd> ", 20)
         elif path_mode == "vector_rx":
             command = (
-                self.app_testpmd_path
-                + " -c 0x3 -n 4 "
-                + "--file-prefix=virtio %s -- -i "
+                self.testpmd_path + " -c 0x3 -n 4 " + "--file-prefix=virtio %s -- -i "
             )
             command = command + "--txd=1024 --rxd=1024 %s"
             vm_client.send_expect(command % (w_pci_str, extern_param), "testpmd> ", 20)
 
     def launch_pdump_to_capture_pkt(self, client_dut, dump_port):
         """
-        bootup pdump in VM
+        launch pdump in VM
         """
         self.pdump_session = client_dut.new_session(suite="pdump")
         if hasattr(client_dut, "vm_name"):
             command_line = (
-                self.app_pdump
+                self.pdump_path
                 + " "
                 + "-v --file-prefix=virtio -- "
                 + "--pdump  '%s,queue=*,rx-dev=%s,mbuf-size=8000'"
@@ -184,7 +179,7 @@  class TestVM2VMVirtioPMD(TestCase):
             )
         else:
             command_line = (
-                self.app_pdump
+                self.pdump_path
                 + " "
                 + "-v --file-prefix=virtio_%s -- "
                 + "--pdump  '%s,queue=*,rx-dev=%s,mbuf-size=8000'"
@@ -198,17 +193,16 @@  class TestVM2VMVirtioPMD(TestCase):
         self,
         setting_args="",
         server_mode=False,
-        opt_queue=None,
-        vm_config="vhost_sample",
+        opt_queue=1,
     ):
         vm_params = {}
 
-        if opt_queue is not None:
+        if opt_queue > 1:
             vm_params["opt_queue"] = opt_queue
 
         for i in range(self.vm_num):
             vm_dut = None
-            vm_info = VM(self.dut, "vm%d" % i, vm_config)
+            vm_info = VM(self.dut, "vm%d" % i, "vhost_sample")
 
             vm_params["driver"] = "vhost-user"
             if not server_mode:
@@ -300,13 +294,12 @@  class TestVM2VMVirtioPMD(TestCase):
             self.dut.close_session(self.virtio_user0)
             self.virtio_user0 = None
 
-    def test_vm2vm_vhost_user_virtio095_pmd_with_vector_rx_path(self):
+    def test_vm2vm_vhost_user_virtio95_pmd_with_vector_rx_path(self):
         """
         Test Case 1: VM2VM vhost-user/virtio0.95-pmd with vector_rx path
         """
         path_mode = "vector_rx"
         setting_args = "disable-modern=true,mrg_rxbuf=off,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         self.start_vm_testpmd(
@@ -321,13 +314,12 @@  class TestVM2VMVirtioPMD(TestCase):
         )
         self.send_and_verify(mode="virtio 0.95 vector_rx", path=path_mode)
 
-    def test_vm2vm_vhost_user_virtio095_pmd_with_normal_path(self):
+    def test_vm2vm_vhost_user_virtio95_pmd_with_normal_path(self):
         """
         Test Case 2: VM2VM vhost-user/virtio0.95-pmd with normal path
         """
         setting_args = "disable-modern=true,mrg_rxbuf=off,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on"
         path_mode = "normal"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         self.start_vm_testpmd(self.vm_dut[0], path_mode)
@@ -340,7 +332,6 @@  class TestVM2VMVirtioPMD(TestCase):
         """
         path_mode = "vector_rx"
         setting_args = "disable-modern=false,mrg_rxbuf=off,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         self.start_vm_testpmd(
@@ -355,20 +346,19 @@  class TestVM2VMVirtioPMD(TestCase):
         )
         self.send_and_verify(mode="virtio 1.0 vector_rx", path=path_mode)
 
-    def test_vhost_vm2vm_virito_10_pmd_with_normal_path(self):
+    def test_vm2vm_vhost_user_virito10_pmd_with_normal_path(self):
         """
         Test Case 4: VM2VM vhost-user/virtio1.0-pmd with normal path
         """
         path_mode = "normal"
         setting_args = "disable-modern=false,mrg_rxbuf=off,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         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 normal path", path=path_mode)
 
-    def test_vm2vm_vhost_user_virtio095_pmd_with_mergeable_path_with_payload_valid_check(
+    def test_vm2vm_vhost_user_virtio95_pmd_with_mergeable_path_with_payload_valid_check(
         self,
     ):
         """
@@ -378,7 +368,6 @@  class TestVM2VMVirtioPMD(TestCase):
         setting_args = "disable-modern=true,mrg_rxbuf=on,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on"
         extern_param = "--max-pkt-len=9600"
         dump_port = "port=0"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         # start testpmd and pdump in VM0
@@ -404,7 +393,6 @@  class TestVM2VMVirtioPMD(TestCase):
         setting_args = "disable-modern=false,mrg_rxbuf=on,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on"
         extern_param = "--max-pkt-len=9600"
         dump_port = "port=0"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         # start testpmd and pdump in VM0
@@ -430,7 +418,6 @@  class TestVM2VMVirtioPMD(TestCase):
         setting_args = "disable-modern=false,mrg_rxbuf=on,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on,packed=on"
         extern_param = "--max-pkt-len=9600"
         dump_port = "port=0"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         # start testpmd and pdump in VM0
@@ -446,13 +433,12 @@  class TestVM2VMVirtioPMD(TestCase):
         # check the packet in vm0
         self.check_packet_payload_valid(self.vm_dut[0])
 
-    def test_vhost_vm2vm_virito_11_pmd_with_normal_path(self):
+    def test_vm2vm_vhost_user_virito11_pmd_with_normal_path(self):
         """
         Test Case 8: VM2VM vhost-user/virtio1.1-pmd with normal path
         """
         path_mode = "normal"
         setting_args = "disable-modern=false,mrg_rxbuf=off,csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on,packed=on"
-        self.get_core_list(2)
         self.start_vhost_testpmd()
         self.start_vms(setting_args=setting_args)
         self.start_vm_testpmd(self.vm_dut[0], path_mode)
@@ -487,77 +473,6 @@  class TestVM2VMVirtioPMD(TestCase):
         vm_dut.send_expect("clear port stats all", "testpmd> ", 30)
         vm_dut.send_expect("start", "testpmd> ", 30)
 
-    def prepare_test_env(
-        self,
-        no_pci=True,
-        client_mode=False,
-        enable_queues=1,
-        nb_cores=2,
-        setting_args="",
-        server_mode=False,
-        opt_queue=None,
-        rxq_txq=None,
-        vm_config="vhost_sample",
-    ):
-        self.start_vhost_testpmd_cbdma(
-            no_pci=no_pci,
-            client_mode=client_mode,
-            enable_queues=enable_queues,
-            nb_cores=nb_cores,
-            rxq_txq=rxq_txq,
-        )
-        self.start_vms(
-            setting_args=setting_args,
-            server_mode=server_mode,
-            opt_queue=opt_queue,
-            vm_config=vm_config,
-        )
-
-    def start_vhost_testpmd_cbdma(
-        self,
-        no_pci=True,
-        client_mode=False,
-        enable_queues=1,
-        nb_cores=2,
-        rxq_txq=None,
-    ):
-        """
-        launch the testpmd with different parameters
-        """
-        testcmd = self.app_testpmd_path + " "
-        if not client_mode:
-            vdev1 = "--vdev 'net_vhost0,iface=%s/vhost-net0,queues=%d' " % (
-                self.base_dir,
-                enable_queues,
-            )
-            vdev2 = "--vdev 'net_vhost1,iface=%s/vhost-net1,queues=%d' " % (
-                self.base_dir,
-                enable_queues,
-            )
-        else:
-            vdev1 = "--vdev 'net_vhost0,iface=%s/vhost-net0,client=1,queues=%d' " % (
-                self.base_dir,
-                enable_queues,
-            )
-            vdev2 = "--vdev 'net_vhost1,iface=%s/vhost-net1,client=1,queues=%d' " % (
-                self.base_dir,
-                enable_queues,
-            )
-        eal_params = self.dut.create_eal_parameters(
-            cores=self.cores_list, prefix="vhost", no_pci=no_pci
-        )
-        if rxq_txq is None:
-            params = " -- -i --nb-cores=%d --txd=1024 --rxd=1024" % nb_cores
-        else:
-            params = " -- -i --nb-cores=%d --txd=1024 --rxd=1024 --rxq=%d --txq=%d" % (
-                nb_cores,
-                rxq_txq,
-                rxq_txq,
-            )
-        self.command_line = testcmd + eal_params + vdev1 + vdev2 + params
-        self.pmd_vhost.execute_cmd(self.command_line, timeout=30)
-        self.pmd_vhost.execute_cmd("start", timeout=30)
-
     def tear_down(self):
         """
         Run after each test case.