test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
@ 2022-04-22  8:17 Wei Ling
  2022-04-22  8:31 ` He, Xingguang
  0 siblings, 1 reply; 8+ messages in thread
From: Wei Ling @ 2022-04-22  8:17 UTC (permalink / raw)
  To: dts; +Cc: Wei Ling

1.Change testcase1 testpmd fwd mode for better case coverage.
2.Add automation testcase2 sync with testplan and optimize code.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_vdev_primary_secondary.py | 148 ++++++++++++++--------
 1 file changed, 95 insertions(+), 53 deletions(-)

diff --git a/tests/TestSuite_vdev_primary_secondary.py b/tests/TestSuite_vdev_primary_secondary.py
index 7f054cda..4c9dba8e 100644
--- a/tests/TestSuite_vdev_primary_secondary.py
+++ b/tests/TestSuite_vdev_primary_secondary.py
@@ -47,6 +47,7 @@ import time
 import framework.utils as utils
 from framework.test_case import TestCase
 from framework.virt_common import VM
+from framework.pmd_output import PmdOutput
 
 
 class TestVdevPrimarySecondary(TestCase):
@@ -59,14 +60,16 @@ class TestVdevPrimarySecondary(TestCase):
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
-        cores = self.dut.get_core_list("1S/12C/1T", socket=self.ports_socket)
-        self.coremask = utils.create_mask(cores)
-        self.verify(len(self.coremask) >= 6, "The machine has too few cores.")
+        self.cores = self.dut.get_core_list("all", socket=self.ports_socket)
+        self.vhost_cores = self.cores[0:6]
+        self.verify(len(self.vhost_cores) >= 6, "The machine has too few cores.")
         self.base_dir = self.dut.base_dir.replace("~", "/root")
-        self.pci_info = self.dut.ports_info[0]["pci"]
         self.app_testpmd_path = self.dut.apps_name["test-pmd"]
         self.app_symmetric_mp_path = self.dut.apps_name["symmetric_mp"]
+        self.app_hotplug_mp_path = self.dut.apps_name["hotplug_mp"]
         self.testpmd_name = self.app_testpmd_path.split("/")[-1]
+        self.vhost_user = self.dut.create_session("vhost-user")
+        self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user)
 
     def set_up(self):
         """
@@ -89,7 +92,7 @@ class TestVdevPrimarySecondary(TestCase):
             vm_params["opt_mac"] = "%s%d" % (self.virtio_mac, i + 2)
             vm_params["opt_queue"] = self.queues
             vm_params["opt_server"] = "server"
-            vm_params["opt_settings"] = "mrg_rxbuf=on,mq=on,vectors=%d" % (
+            vm_params["opt_settings"] = "mrg_rxbuf=on,csum=on,mq=on,vectors=%d" % (
                 2 * self.queues + 2
             )
             self.vm.set_vm_device(**vm_params)
@@ -103,33 +106,14 @@ class TestVdevPrimarySecondary(TestCase):
 
         return True
 
-    def launch_testpmd(self):
+    def launch_testpmd(self, param, eal_param):
         """
         launch testpmd
         """
-        testcmd = self.app_testpmd_path + " "
-        vdev1 = " --vdev 'net_vhost0,iface=%s/vhost-net0,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        vdev2 = " --vdev 'net_vhost1,iface=%s/vhost-net1,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        eal_params = self.dut.create_eal_parameters(
-            cores="1S/12C/1T", prefix="vhost", ports=[self.pci_info]
-        )
-        para = " -- -i --nb-cores=4 --rxq=%d --txq=%d --txd=1024 --rxd=1024" % (
-            self.queues,
-            self.queues,
-        )
-        start_cmd = testcmd + eal_params + vdev1 + vdev2 + para
-        self.dut.send_expect(start_cmd, "testpmd> ", 120)
-        self.dut.send_expect("set fwd txonly", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ", 120)
+        self.vhost_user_pmd.start_testpmd(cores=self.vhost_cores, param=param, eal_param=eal_param, prefix='vhost', fixed_prefix=True, no_pci=True)
 
-    def launch_examples(self):
-        example_cmd_auto = (
+    def launch_symmetric_mp(self):
+        example_cmd_primary = (
             self.app_symmetric_mp_path
             + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
         )
@@ -137,53 +121,111 @@ class TestVdevPrimarySecondary(TestCase):
             self.app_symmetric_mp_path
             + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
         )
-        final_cmd_first = example_cmd_auto % (self.mem_channels, self.queues)
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
+        final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
+        self.vm_primary.send_expect(final_cmd_primary, "Lcore", 120)
+        time.sleep(3)
+        self.vm_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+
+    def launch_hotplug_mp(self):
+        example_cmd_primary = (
+            self.app_hotplug_mp_path
+            + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
+        )
+        example_cmd_secondary = (
+            self.app_hotplug_mp_path
+            + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
+        )
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
         final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
-        self.vhost_first.send_expect(final_cmd_first, "Lcore", 120)
+        self.vm_primary.send_expect(final_cmd_primary, "example>", 120)
         time.sleep(3)
-        self.vhost_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+        self.vm_secondary.send_expect(final_cmd_secondary, "example>", 120)
+
+    def check_etherdev(self, dev_list):
+        primary_out = self.vm_primary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in primary_out, "dev {} not in the list")
+        secondary_out = self.vm_secondary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in secondary_out, "dev {} not in the list")
+
+    def detach_etherdev_from_primary(self, dev_pci):
+        self.vm_primary.send_expect("detach {}".format(dev_pci), "example", 120)
+
+    def attach_etherdev_from_secondary(self, dev_pci):
+        self.vm_secondary.send_expect("attach {}".format(dev_pci), "example", 120)
 
     def prepare_symmetric_mp(self):
         out = self.vm_dut.build_dpdk_apps("./examples/multi_process/symmetric_mp")
         self.verify("Error" not in out, "compilation symmetric_mp error")
 
-    def close_session(self):
-        self.vm_dut.close_session(self.vhost_first)
-        self.vm_dut.close_session(self.vhost_secondary)
+    def prepare_hotplug_mp(self):
+        out = self.vm_dut.build_dpdk_apps("./examples/multi_process/hotplug_mp")
+        self.verify("Error" not in out, "compilation hotplug_mp error")
 
-    def test_Virtio_primary_and_secondary_process(self):
-        # start testpmd
-        self.launch_testpmd()
+    def close_session(self):
+        self.vm_dut.close_session(self.vm_primary)
+        self.vm_dut.close_session(self.vm_secondary)
+        self.dut.close_session(self.vhost_user)
+
+    def test_virtio_primary_and_secondary_process(self):
+        vhost_eal_param = "--vdev 'net_vhost,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
         self.setup_vm_env()
-        # Modify code
         self.prepare_symmetric_mp()
-        # create 2 new session
-        self.vhost_first = self.vm_dut.new_session(suite="vhost_first")
-        self.vhost_secondary = self.vm_dut.new_session(suite="vhsot_secondary")
-        # start symmetric_mp
-        self.launch_examples()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_symmetric_mp()
+        self.vhost_user_pmd.execute_cmd("set fwd mac")
+        self.vhost_user_pmd.execute_cmd("start tx_first")
         time.sleep(3)
-        vhost_first_out = self.vhost_first.send_expect("^c", "#", 15)
-        print(vhost_first_out)
+        vm_primary_out = self.vm_primary.send_expect("^c", "#", 15)
+        print(vm_primary_out)
         time.sleep(3)
-        vhost_secondary_out = self.vhost_secondary.send_expect("^c", "#", 15)
-        print(vhost_secondary_out)
-        result_first = re.findall(r"Port \d: RX - (\w+)", vhost_first_out)
-        result_secondary = re.findall(r"Port \d: RX - (\w+)", vhost_secondary_out)
+        vm_secondary_out = self.vm_secondary.send_expect("^c", "#", 15)
+        print(vm_secondary_out)
+        result_primary = re.findall(r"Port \d: RX - (\w+)", vm_primary_out)
+        result_secondary = re.findall(r"Port \d: RX - (\w+)", vm_secondary_out)
         self.verify(
-            len(result_first[0]) != 0
-            and len(result_first[1]) != 0
+            len(result_primary[0]) != 0
+            and len(result_primary[1]) != 0
             and len(result_secondary[0]) != 0
             and len(result_secondary[1]) != 0,
             "RX no data",
         )
         self.dut.send_expect("quit", "#", 15)
 
+    def test_virtio_primay_and_secondary_process_hotplug(self):
+        vhost_eal_param = "--vdev 'net_vhost0,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
+        self.vhost_user_pmd.execute_cmd("set fwd txonly")
+        self.vhost_user_pmd.execute_cmd("start")
+        self.setup_vm_env()
+        self.prepare_hotplug_mp()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_hotplug_mp()
+        vm_ports = []
+        for pci_info in self.vm_dut.ports_info:
+            vm_ports.append(pci_info['pci'])
+        self.check_etherdev(dev_list=vm_ports)
+        detach_pci = vm_ports[0]
+        for _ in range(2):
+            self.detach_etherdev_from_primary(dev_pci=detach_pci)
+            vm_ports.remove(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+            self.attach_etherdev_from_secondary(dev_pci=detach_pci)
+            vm_ports.append(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+        self.dut.send_expect("quit", "#", 15)
+
     def tear_down(self):
         """
         Run after each test case.
         """
-        self.close_session()
         self.vm_dut.kill_all()
         self.dut.kill_all()
         self.vm.stop()
@@ -195,4 +237,4 @@ class TestVdevPrimarySecondary(TestCase):
         """
         Run after each test suite.
         """
-        pass
+        self.close_session()
-- 
2.25.1


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

* RE: [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
  2022-04-22  8:17 [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan Wei Ling
@ 2022-04-22  8:31 ` He, Xingguang
  0 siblings, 0 replies; 8+ messages in thread
From: He, Xingguang @ 2022-04-22  8:31 UTC (permalink / raw)
  To: dts; +Cc: Ling, WeiX

> -----Original Message-----
> From: Wei Ling <weix.ling@intel.com>
> Sent: Friday, April 22, 2022 4:18 PM
> To: dts@dpdk.org
> Cc: Ling, WeiX <weix.ling@intel.com>
> Subject: [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation
> testcase2 sync with testplan
> 
> 1.Change testcase1 testpmd fwd mode for better case coverage.
> 2.Add automation testcase2 sync with testplan and optimize code.
> 
> Signed-off-by: Wei Ling <weix.ling@intel.com>
> ---

Acked-by: Xingguang He<xingguang.he@intel.com>

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

* [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
@ 2022-04-25  1:57 Wei Ling
  0 siblings, 0 replies; 8+ messages in thread
From: Wei Ling @ 2022-04-25  1:57 UTC (permalink / raw)
  To: dts; +Cc: Wei Ling

1. Change testcase1 testpmd fwd mode from `set fwd txonly` and `start`
   to `set fwd mac` and `start tx_first` take VM and testpmd can loop the traffic.
2. Add automation testcase2 sync with testplan and optimize code.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_vdev_primary_secondary.py | 148 ++++++++++++++--------
 1 file changed, 95 insertions(+), 53 deletions(-)

diff --git a/tests/TestSuite_vdev_primary_secondary.py b/tests/TestSuite_vdev_primary_secondary.py
index 7f054cda..4c9dba8e 100644
--- a/tests/TestSuite_vdev_primary_secondary.py
+++ b/tests/TestSuite_vdev_primary_secondary.py
@@ -47,6 +47,7 @@ import time
 import framework.utils as utils
 from framework.test_case import TestCase
 from framework.virt_common import VM
+from framework.pmd_output import PmdOutput
 
 
 class TestVdevPrimarySecondary(TestCase):
@@ -59,14 +60,16 @@ class TestVdevPrimarySecondary(TestCase):
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
-        cores = self.dut.get_core_list("1S/12C/1T", socket=self.ports_socket)
-        self.coremask = utils.create_mask(cores)
-        self.verify(len(self.coremask) >= 6, "The machine has too few cores.")
+        self.cores = self.dut.get_core_list("all", socket=self.ports_socket)
+        self.vhost_cores = self.cores[0:6]
+        self.verify(len(self.vhost_cores) >= 6, "The machine has too few cores.")
         self.base_dir = self.dut.base_dir.replace("~", "/root")
-        self.pci_info = self.dut.ports_info[0]["pci"]
         self.app_testpmd_path = self.dut.apps_name["test-pmd"]
         self.app_symmetric_mp_path = self.dut.apps_name["symmetric_mp"]
+        self.app_hotplug_mp_path = self.dut.apps_name["hotplug_mp"]
         self.testpmd_name = self.app_testpmd_path.split("/")[-1]
+        self.vhost_user = self.dut.create_session("vhost-user")
+        self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user)
 
     def set_up(self):
         """
@@ -89,7 +92,7 @@ class TestVdevPrimarySecondary(TestCase):
             vm_params["opt_mac"] = "%s%d" % (self.virtio_mac, i + 2)
             vm_params["opt_queue"] = self.queues
             vm_params["opt_server"] = "server"
-            vm_params["opt_settings"] = "mrg_rxbuf=on,mq=on,vectors=%d" % (
+            vm_params["opt_settings"] = "mrg_rxbuf=on,csum=on,mq=on,vectors=%d" % (
                 2 * self.queues + 2
             )
             self.vm.set_vm_device(**vm_params)
@@ -103,33 +106,14 @@ class TestVdevPrimarySecondary(TestCase):
 
         return True
 
-    def launch_testpmd(self):
+    def launch_testpmd(self, param, eal_param):
         """
         launch testpmd
         """
-        testcmd = self.app_testpmd_path + " "
-        vdev1 = " --vdev 'net_vhost0,iface=%s/vhost-net0,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        vdev2 = " --vdev 'net_vhost1,iface=%s/vhost-net1,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        eal_params = self.dut.create_eal_parameters(
-            cores="1S/12C/1T", prefix="vhost", ports=[self.pci_info]
-        )
-        para = " -- -i --nb-cores=4 --rxq=%d --txq=%d --txd=1024 --rxd=1024" % (
-            self.queues,
-            self.queues,
-        )
-        start_cmd = testcmd + eal_params + vdev1 + vdev2 + para
-        self.dut.send_expect(start_cmd, "testpmd> ", 120)
-        self.dut.send_expect("set fwd txonly", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ", 120)
+        self.vhost_user_pmd.start_testpmd(cores=self.vhost_cores, param=param, eal_param=eal_param, prefix='vhost', fixed_prefix=True, no_pci=True)
 
-    def launch_examples(self):
-        example_cmd_auto = (
+    def launch_symmetric_mp(self):
+        example_cmd_primary = (
             self.app_symmetric_mp_path
             + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
         )
@@ -137,53 +121,111 @@ class TestVdevPrimarySecondary(TestCase):
             self.app_symmetric_mp_path
             + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
         )
-        final_cmd_first = example_cmd_auto % (self.mem_channels, self.queues)
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
+        final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
+        self.vm_primary.send_expect(final_cmd_primary, "Lcore", 120)
+        time.sleep(3)
+        self.vm_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+
+    def launch_hotplug_mp(self):
+        example_cmd_primary = (
+            self.app_hotplug_mp_path
+            + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
+        )
+        example_cmd_secondary = (
+            self.app_hotplug_mp_path
+            + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
+        )
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
         final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
-        self.vhost_first.send_expect(final_cmd_first, "Lcore", 120)
+        self.vm_primary.send_expect(final_cmd_primary, "example>", 120)
         time.sleep(3)
-        self.vhost_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+        self.vm_secondary.send_expect(final_cmd_secondary, "example>", 120)
+
+    def check_etherdev(self, dev_list):
+        primary_out = self.vm_primary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in primary_out, "dev {} not in the list")
+        secondary_out = self.vm_secondary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in secondary_out, "dev {} not in the list")
+
+    def detach_etherdev_from_primary(self, dev_pci):
+        self.vm_primary.send_expect("detach {}".format(dev_pci), "example", 120)
+
+    def attach_etherdev_from_secondary(self, dev_pci):
+        self.vm_secondary.send_expect("attach {}".format(dev_pci), "example", 120)
 
     def prepare_symmetric_mp(self):
         out = self.vm_dut.build_dpdk_apps("./examples/multi_process/symmetric_mp")
         self.verify("Error" not in out, "compilation symmetric_mp error")
 
-    def close_session(self):
-        self.vm_dut.close_session(self.vhost_first)
-        self.vm_dut.close_session(self.vhost_secondary)
+    def prepare_hotplug_mp(self):
+        out = self.vm_dut.build_dpdk_apps("./examples/multi_process/hotplug_mp")
+        self.verify("Error" not in out, "compilation hotplug_mp error")
 
-    def test_Virtio_primary_and_secondary_process(self):
-        # start testpmd
-        self.launch_testpmd()
+    def close_session(self):
+        self.vm_dut.close_session(self.vm_primary)
+        self.vm_dut.close_session(self.vm_secondary)
+        self.dut.close_session(self.vhost_user)
+
+    def test_virtio_primary_and_secondary_process(self):
+        vhost_eal_param = "--vdev 'net_vhost,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
         self.setup_vm_env()
-        # Modify code
         self.prepare_symmetric_mp()
-        # create 2 new session
-        self.vhost_first = self.vm_dut.new_session(suite="vhost_first")
-        self.vhost_secondary = self.vm_dut.new_session(suite="vhsot_secondary")
-        # start symmetric_mp
-        self.launch_examples()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_symmetric_mp()
+        self.vhost_user_pmd.execute_cmd("set fwd mac")
+        self.vhost_user_pmd.execute_cmd("start tx_first")
         time.sleep(3)
-        vhost_first_out = self.vhost_first.send_expect("^c", "#", 15)
-        print(vhost_first_out)
+        vm_primary_out = self.vm_primary.send_expect("^c", "#", 15)
+        print(vm_primary_out)
         time.sleep(3)
-        vhost_secondary_out = self.vhost_secondary.send_expect("^c", "#", 15)
-        print(vhost_secondary_out)
-        result_first = re.findall(r"Port \d: RX - (\w+)", vhost_first_out)
-        result_secondary = re.findall(r"Port \d: RX - (\w+)", vhost_secondary_out)
+        vm_secondary_out = self.vm_secondary.send_expect("^c", "#", 15)
+        print(vm_secondary_out)
+        result_primary = re.findall(r"Port \d: RX - (\w+)", vm_primary_out)
+        result_secondary = re.findall(r"Port \d: RX - (\w+)", vm_secondary_out)
         self.verify(
-            len(result_first[0]) != 0
-            and len(result_first[1]) != 0
+            len(result_primary[0]) != 0
+            and len(result_primary[1]) != 0
             and len(result_secondary[0]) != 0
             and len(result_secondary[1]) != 0,
             "RX no data",
         )
         self.dut.send_expect("quit", "#", 15)
 
+    def test_virtio_primay_and_secondary_process_hotplug(self):
+        vhost_eal_param = "--vdev 'net_vhost0,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
+        self.vhost_user_pmd.execute_cmd("set fwd txonly")
+        self.vhost_user_pmd.execute_cmd("start")
+        self.setup_vm_env()
+        self.prepare_hotplug_mp()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_hotplug_mp()
+        vm_ports = []
+        for pci_info in self.vm_dut.ports_info:
+            vm_ports.append(pci_info['pci'])
+        self.check_etherdev(dev_list=vm_ports)
+        detach_pci = vm_ports[0]
+        for _ in range(2):
+            self.detach_etherdev_from_primary(dev_pci=detach_pci)
+            vm_ports.remove(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+            self.attach_etherdev_from_secondary(dev_pci=detach_pci)
+            vm_ports.append(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+        self.dut.send_expect("quit", "#", 15)
+
     def tear_down(self):
         """
         Run after each test case.
         """
-        self.close_session()
         self.vm_dut.kill_all()
         self.dut.kill_all()
         self.vm.stop()
@@ -195,4 +237,4 @@ class TestVdevPrimarySecondary(TestCase):
         """
         Run after each test suite.
         """
-        pass
+        self.close_session()
-- 
2.25.1


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

* RE: [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
  2022-04-22  9:20 Wei Ling
@ 2022-04-22  9:27 ` He, Xingguang
  0 siblings, 0 replies; 8+ messages in thread
From: He, Xingguang @ 2022-04-22  9:27 UTC (permalink / raw)
  To: dts; +Cc: Ling, WeiX

> -----Original Message-----
> From: Wei Ling <weix.ling@intel.com>
> Sent: Friday, April 22, 2022 5:21 PM
> To: dts@dpdk.org
> Cc: Ling, WeiX <weix.ling@intel.com>
> Subject: [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation
> testcase2 sync with testplan
> 
> 1. Change testcase1 testpmd fwd mode from `set fwd txonly` and `start`
>    to `set fwd mac` and `start tx_first` take VM and testpmd can loop the
> traffic.
> 2. Add automation testcase2 sync with testplan and optimize code.
> 
> Signed-off-by: Wei Ling <weix.ling@intel.com>
> ---

Acked-by: Xingguang He<xingguang.he@intel.com>

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

* [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
@ 2022-04-22  9:20 Wei Ling
  2022-04-22  9:27 ` He, Xingguang
  0 siblings, 1 reply; 8+ messages in thread
From: Wei Ling @ 2022-04-22  9:20 UTC (permalink / raw)
  To: dts; +Cc: Wei Ling

1. Change testcase1 testpmd fwd mode from `set fwd txonly` and `start`
   to `set fwd mac` and `start tx_first` take VM and testpmd can loop the traffic.
2. Add automation testcase2 sync with testplan and optimize code.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_vdev_primary_secondary.py | 148 ++++++++++++++--------
 1 file changed, 95 insertions(+), 53 deletions(-)

diff --git a/tests/TestSuite_vdev_primary_secondary.py b/tests/TestSuite_vdev_primary_secondary.py
index 7f054cda..4c9dba8e 100644
--- a/tests/TestSuite_vdev_primary_secondary.py
+++ b/tests/TestSuite_vdev_primary_secondary.py
@@ -47,6 +47,7 @@ import time
 import framework.utils as utils
 from framework.test_case import TestCase
 from framework.virt_common import VM
+from framework.pmd_output import PmdOutput
 
 
 class TestVdevPrimarySecondary(TestCase):
@@ -59,14 +60,16 @@ class TestVdevPrimarySecondary(TestCase):
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
-        cores = self.dut.get_core_list("1S/12C/1T", socket=self.ports_socket)
-        self.coremask = utils.create_mask(cores)
-        self.verify(len(self.coremask) >= 6, "The machine has too few cores.")
+        self.cores = self.dut.get_core_list("all", socket=self.ports_socket)
+        self.vhost_cores = self.cores[0:6]
+        self.verify(len(self.vhost_cores) >= 6, "The machine has too few cores.")
         self.base_dir = self.dut.base_dir.replace("~", "/root")
-        self.pci_info = self.dut.ports_info[0]["pci"]
         self.app_testpmd_path = self.dut.apps_name["test-pmd"]
         self.app_symmetric_mp_path = self.dut.apps_name["symmetric_mp"]
+        self.app_hotplug_mp_path = self.dut.apps_name["hotplug_mp"]
         self.testpmd_name = self.app_testpmd_path.split("/")[-1]
+        self.vhost_user = self.dut.create_session("vhost-user")
+        self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user)
 
     def set_up(self):
         """
@@ -89,7 +92,7 @@ class TestVdevPrimarySecondary(TestCase):
             vm_params["opt_mac"] = "%s%d" % (self.virtio_mac, i + 2)
             vm_params["opt_queue"] = self.queues
             vm_params["opt_server"] = "server"
-            vm_params["opt_settings"] = "mrg_rxbuf=on,mq=on,vectors=%d" % (
+            vm_params["opt_settings"] = "mrg_rxbuf=on,csum=on,mq=on,vectors=%d" % (
                 2 * self.queues + 2
             )
             self.vm.set_vm_device(**vm_params)
@@ -103,33 +106,14 @@ class TestVdevPrimarySecondary(TestCase):
 
         return True
 
-    def launch_testpmd(self):
+    def launch_testpmd(self, param, eal_param):
         """
         launch testpmd
         """
-        testcmd = self.app_testpmd_path + " "
-        vdev1 = " --vdev 'net_vhost0,iface=%s/vhost-net0,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        vdev2 = " --vdev 'net_vhost1,iface=%s/vhost-net1,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        eal_params = self.dut.create_eal_parameters(
-            cores="1S/12C/1T", prefix="vhost", ports=[self.pci_info]
-        )
-        para = " -- -i --nb-cores=4 --rxq=%d --txq=%d --txd=1024 --rxd=1024" % (
-            self.queues,
-            self.queues,
-        )
-        start_cmd = testcmd + eal_params + vdev1 + vdev2 + para
-        self.dut.send_expect(start_cmd, "testpmd> ", 120)
-        self.dut.send_expect("set fwd txonly", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ", 120)
+        self.vhost_user_pmd.start_testpmd(cores=self.vhost_cores, param=param, eal_param=eal_param, prefix='vhost', fixed_prefix=True, no_pci=True)
 
-    def launch_examples(self):
-        example_cmd_auto = (
+    def launch_symmetric_mp(self):
+        example_cmd_primary = (
             self.app_symmetric_mp_path
             + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
         )
@@ -137,53 +121,111 @@ class TestVdevPrimarySecondary(TestCase):
             self.app_symmetric_mp_path
             + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
         )
-        final_cmd_first = example_cmd_auto % (self.mem_channels, self.queues)
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
+        final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
+        self.vm_primary.send_expect(final_cmd_primary, "Lcore", 120)
+        time.sleep(3)
+        self.vm_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+
+    def launch_hotplug_mp(self):
+        example_cmd_primary = (
+            self.app_hotplug_mp_path
+            + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
+        )
+        example_cmd_secondary = (
+            self.app_hotplug_mp_path
+            + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
+        )
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
         final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
-        self.vhost_first.send_expect(final_cmd_first, "Lcore", 120)
+        self.vm_primary.send_expect(final_cmd_primary, "example>", 120)
         time.sleep(3)
-        self.vhost_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+        self.vm_secondary.send_expect(final_cmd_secondary, "example>", 120)
+
+    def check_etherdev(self, dev_list):
+        primary_out = self.vm_primary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in primary_out, "dev {} not in the list")
+        secondary_out = self.vm_secondary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in secondary_out, "dev {} not in the list")
+
+    def detach_etherdev_from_primary(self, dev_pci):
+        self.vm_primary.send_expect("detach {}".format(dev_pci), "example", 120)
+
+    def attach_etherdev_from_secondary(self, dev_pci):
+        self.vm_secondary.send_expect("attach {}".format(dev_pci), "example", 120)
 
     def prepare_symmetric_mp(self):
         out = self.vm_dut.build_dpdk_apps("./examples/multi_process/symmetric_mp")
         self.verify("Error" not in out, "compilation symmetric_mp error")
 
-    def close_session(self):
-        self.vm_dut.close_session(self.vhost_first)
-        self.vm_dut.close_session(self.vhost_secondary)
+    def prepare_hotplug_mp(self):
+        out = self.vm_dut.build_dpdk_apps("./examples/multi_process/hotplug_mp")
+        self.verify("Error" not in out, "compilation hotplug_mp error")
 
-    def test_Virtio_primary_and_secondary_process(self):
-        # start testpmd
-        self.launch_testpmd()
+    def close_session(self):
+        self.vm_dut.close_session(self.vm_primary)
+        self.vm_dut.close_session(self.vm_secondary)
+        self.dut.close_session(self.vhost_user)
+
+    def test_virtio_primary_and_secondary_process(self):
+        vhost_eal_param = "--vdev 'net_vhost,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
         self.setup_vm_env()
-        # Modify code
         self.prepare_symmetric_mp()
-        # create 2 new session
-        self.vhost_first = self.vm_dut.new_session(suite="vhost_first")
-        self.vhost_secondary = self.vm_dut.new_session(suite="vhsot_secondary")
-        # start symmetric_mp
-        self.launch_examples()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_symmetric_mp()
+        self.vhost_user_pmd.execute_cmd("set fwd mac")
+        self.vhost_user_pmd.execute_cmd("start tx_first")
         time.sleep(3)
-        vhost_first_out = self.vhost_first.send_expect("^c", "#", 15)
-        print(vhost_first_out)
+        vm_primary_out = self.vm_primary.send_expect("^c", "#", 15)
+        print(vm_primary_out)
         time.sleep(3)
-        vhost_secondary_out = self.vhost_secondary.send_expect("^c", "#", 15)
-        print(vhost_secondary_out)
-        result_first = re.findall(r"Port \d: RX - (\w+)", vhost_first_out)
-        result_secondary = re.findall(r"Port \d: RX - (\w+)", vhost_secondary_out)
+        vm_secondary_out = self.vm_secondary.send_expect("^c", "#", 15)
+        print(vm_secondary_out)
+        result_primary = re.findall(r"Port \d: RX - (\w+)", vm_primary_out)
+        result_secondary = re.findall(r"Port \d: RX - (\w+)", vm_secondary_out)
         self.verify(
-            len(result_first[0]) != 0
-            and len(result_first[1]) != 0
+            len(result_primary[0]) != 0
+            and len(result_primary[1]) != 0
             and len(result_secondary[0]) != 0
             and len(result_secondary[1]) != 0,
             "RX no data",
         )
         self.dut.send_expect("quit", "#", 15)
 
+    def test_virtio_primay_and_secondary_process_hotplug(self):
+        vhost_eal_param = "--vdev 'net_vhost0,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
+        self.vhost_user_pmd.execute_cmd("set fwd txonly")
+        self.vhost_user_pmd.execute_cmd("start")
+        self.setup_vm_env()
+        self.prepare_hotplug_mp()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_hotplug_mp()
+        vm_ports = []
+        for pci_info in self.vm_dut.ports_info:
+            vm_ports.append(pci_info['pci'])
+        self.check_etherdev(dev_list=vm_ports)
+        detach_pci = vm_ports[0]
+        for _ in range(2):
+            self.detach_etherdev_from_primary(dev_pci=detach_pci)
+            vm_ports.remove(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+            self.attach_etherdev_from_secondary(dev_pci=detach_pci)
+            vm_ports.append(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+        self.dut.send_expect("quit", "#", 15)
+
     def tear_down(self):
         """
         Run after each test case.
         """
-        self.close_session()
         self.vm_dut.kill_all()
         self.dut.kill_all()
         self.vm.stop()
@@ -195,4 +237,4 @@ class TestVdevPrimarySecondary(TestCase):
         """
         Run after each test suite.
         """
-        pass
+        self.close_session()
-- 
2.25.1


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

* RE: [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
  2022-04-22  9:11 Wei Ling
@ 2022-04-22  9:20 ` He, Xingguang
  0 siblings, 0 replies; 8+ messages in thread
From: He, Xingguang @ 2022-04-22  9:20 UTC (permalink / raw)
  To: dts; +Cc: Ling, WeiX

> -----Original Message-----
> From: Wei Ling <weix.ling@intel.com>
> Sent: Friday, April 22, 2022 5:12 PM
> To: dts@dpdk.org
> Cc: Ling, WeiX <weix.ling@intel.com>
> Subject: [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation
> testcase2 sync with testplan
> 
> 1.Change testcase1 testpmd fwd mode take VM and testpmd can loop the
>   traffic.
> 2.Add automation testcase2 sync with testplan and optimize code.
> 
> Signed-off-by: Wei Ling <weix.ling@intel.com>
> ---

Acked-by: Xingguang He<xingguang.he@intel.com>

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

* [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
@ 2022-04-22  9:11 Wei Ling
  2022-04-22  9:20 ` He, Xingguang
  0 siblings, 1 reply; 8+ messages in thread
From: Wei Ling @ 2022-04-22  9:11 UTC (permalink / raw)
  To: dts; +Cc: Wei Ling

1.Change testcase1 testpmd fwd mode take VM and testpmd can loop the
  traffic.
2.Add automation testcase2 sync with testplan and optimize code.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_vdev_primary_secondary.py | 148 ++++++++++++++--------
 1 file changed, 95 insertions(+), 53 deletions(-)

diff --git a/tests/TestSuite_vdev_primary_secondary.py b/tests/TestSuite_vdev_primary_secondary.py
index 7f054cda..4c9dba8e 100644
--- a/tests/TestSuite_vdev_primary_secondary.py
+++ b/tests/TestSuite_vdev_primary_secondary.py
@@ -47,6 +47,7 @@ import time
 import framework.utils as utils
 from framework.test_case import TestCase
 from framework.virt_common import VM
+from framework.pmd_output import PmdOutput
 
 
 class TestVdevPrimarySecondary(TestCase):
@@ -59,14 +60,16 @@ class TestVdevPrimarySecondary(TestCase):
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
-        cores = self.dut.get_core_list("1S/12C/1T", socket=self.ports_socket)
-        self.coremask = utils.create_mask(cores)
-        self.verify(len(self.coremask) >= 6, "The machine has too few cores.")
+        self.cores = self.dut.get_core_list("all", socket=self.ports_socket)
+        self.vhost_cores = self.cores[0:6]
+        self.verify(len(self.vhost_cores) >= 6, "The machine has too few cores.")
         self.base_dir = self.dut.base_dir.replace("~", "/root")
-        self.pci_info = self.dut.ports_info[0]["pci"]
         self.app_testpmd_path = self.dut.apps_name["test-pmd"]
         self.app_symmetric_mp_path = self.dut.apps_name["symmetric_mp"]
+        self.app_hotplug_mp_path = self.dut.apps_name["hotplug_mp"]
         self.testpmd_name = self.app_testpmd_path.split("/")[-1]
+        self.vhost_user = self.dut.create_session("vhost-user")
+        self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user)
 
     def set_up(self):
         """
@@ -89,7 +92,7 @@ class TestVdevPrimarySecondary(TestCase):
             vm_params["opt_mac"] = "%s%d" % (self.virtio_mac, i + 2)
             vm_params["opt_queue"] = self.queues
             vm_params["opt_server"] = "server"
-            vm_params["opt_settings"] = "mrg_rxbuf=on,mq=on,vectors=%d" % (
+            vm_params["opt_settings"] = "mrg_rxbuf=on,csum=on,mq=on,vectors=%d" % (
                 2 * self.queues + 2
             )
             self.vm.set_vm_device(**vm_params)
@@ -103,33 +106,14 @@ class TestVdevPrimarySecondary(TestCase):
 
         return True
 
-    def launch_testpmd(self):
+    def launch_testpmd(self, param, eal_param):
         """
         launch testpmd
         """
-        testcmd = self.app_testpmd_path + " "
-        vdev1 = " --vdev 'net_vhost0,iface=%s/vhost-net0,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        vdev2 = " --vdev 'net_vhost1,iface=%s/vhost-net1,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        eal_params = self.dut.create_eal_parameters(
-            cores="1S/12C/1T", prefix="vhost", ports=[self.pci_info]
-        )
-        para = " -- -i --nb-cores=4 --rxq=%d --txq=%d --txd=1024 --rxd=1024" % (
-            self.queues,
-            self.queues,
-        )
-        start_cmd = testcmd + eal_params + vdev1 + vdev2 + para
-        self.dut.send_expect(start_cmd, "testpmd> ", 120)
-        self.dut.send_expect("set fwd txonly", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ", 120)
+        self.vhost_user_pmd.start_testpmd(cores=self.vhost_cores, param=param, eal_param=eal_param, prefix='vhost', fixed_prefix=True, no_pci=True)
 
-    def launch_examples(self):
-        example_cmd_auto = (
+    def launch_symmetric_mp(self):
+        example_cmd_primary = (
             self.app_symmetric_mp_path
             + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
         )
@@ -137,53 +121,111 @@ class TestVdevPrimarySecondary(TestCase):
             self.app_symmetric_mp_path
             + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
         )
-        final_cmd_first = example_cmd_auto % (self.mem_channels, self.queues)
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
+        final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
+        self.vm_primary.send_expect(final_cmd_primary, "Lcore", 120)
+        time.sleep(3)
+        self.vm_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+
+    def launch_hotplug_mp(self):
+        example_cmd_primary = (
+            self.app_hotplug_mp_path
+            + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
+        )
+        example_cmd_secondary = (
+            self.app_hotplug_mp_path
+            + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
+        )
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
         final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
-        self.vhost_first.send_expect(final_cmd_first, "Lcore", 120)
+        self.vm_primary.send_expect(final_cmd_primary, "example>", 120)
         time.sleep(3)
-        self.vhost_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+        self.vm_secondary.send_expect(final_cmd_secondary, "example>", 120)
+
+    def check_etherdev(self, dev_list):
+        primary_out = self.vm_primary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in primary_out, "dev {} not in the list")
+        secondary_out = self.vm_secondary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in secondary_out, "dev {} not in the list")
+
+    def detach_etherdev_from_primary(self, dev_pci):
+        self.vm_primary.send_expect("detach {}".format(dev_pci), "example", 120)
+
+    def attach_etherdev_from_secondary(self, dev_pci):
+        self.vm_secondary.send_expect("attach {}".format(dev_pci), "example", 120)
 
     def prepare_symmetric_mp(self):
         out = self.vm_dut.build_dpdk_apps("./examples/multi_process/symmetric_mp")
         self.verify("Error" not in out, "compilation symmetric_mp error")
 
-    def close_session(self):
-        self.vm_dut.close_session(self.vhost_first)
-        self.vm_dut.close_session(self.vhost_secondary)
+    def prepare_hotplug_mp(self):
+        out = self.vm_dut.build_dpdk_apps("./examples/multi_process/hotplug_mp")
+        self.verify("Error" not in out, "compilation hotplug_mp error")
 
-    def test_Virtio_primary_and_secondary_process(self):
-        # start testpmd
-        self.launch_testpmd()
+    def close_session(self):
+        self.vm_dut.close_session(self.vm_primary)
+        self.vm_dut.close_session(self.vm_secondary)
+        self.dut.close_session(self.vhost_user)
+
+    def test_virtio_primary_and_secondary_process(self):
+        vhost_eal_param = "--vdev 'net_vhost,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
         self.setup_vm_env()
-        # Modify code
         self.prepare_symmetric_mp()
-        # create 2 new session
-        self.vhost_first = self.vm_dut.new_session(suite="vhost_first")
-        self.vhost_secondary = self.vm_dut.new_session(suite="vhsot_secondary")
-        # start symmetric_mp
-        self.launch_examples()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_symmetric_mp()
+        self.vhost_user_pmd.execute_cmd("set fwd mac")
+        self.vhost_user_pmd.execute_cmd("start tx_first")
         time.sleep(3)
-        vhost_first_out = self.vhost_first.send_expect("^c", "#", 15)
-        print(vhost_first_out)
+        vm_primary_out = self.vm_primary.send_expect("^c", "#", 15)
+        print(vm_primary_out)
         time.sleep(3)
-        vhost_secondary_out = self.vhost_secondary.send_expect("^c", "#", 15)
-        print(vhost_secondary_out)
-        result_first = re.findall(r"Port \d: RX - (\w+)", vhost_first_out)
-        result_secondary = re.findall(r"Port \d: RX - (\w+)", vhost_secondary_out)
+        vm_secondary_out = self.vm_secondary.send_expect("^c", "#", 15)
+        print(vm_secondary_out)
+        result_primary = re.findall(r"Port \d: RX - (\w+)", vm_primary_out)
+        result_secondary = re.findall(r"Port \d: RX - (\w+)", vm_secondary_out)
         self.verify(
-            len(result_first[0]) != 0
-            and len(result_first[1]) != 0
+            len(result_primary[0]) != 0
+            and len(result_primary[1]) != 0
             and len(result_secondary[0]) != 0
             and len(result_secondary[1]) != 0,
             "RX no data",
         )
         self.dut.send_expect("quit", "#", 15)
 
+    def test_virtio_primay_and_secondary_process_hotplug(self):
+        vhost_eal_param = "--vdev 'net_vhost0,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
+        self.vhost_user_pmd.execute_cmd("set fwd txonly")
+        self.vhost_user_pmd.execute_cmd("start")
+        self.setup_vm_env()
+        self.prepare_hotplug_mp()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_hotplug_mp()
+        vm_ports = []
+        for pci_info in self.vm_dut.ports_info:
+            vm_ports.append(pci_info['pci'])
+        self.check_etherdev(dev_list=vm_ports)
+        detach_pci = vm_ports[0]
+        for _ in range(2):
+            self.detach_etherdev_from_primary(dev_pci=detach_pci)
+            vm_ports.remove(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+            self.attach_etherdev_from_secondary(dev_pci=detach_pci)
+            vm_ports.append(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+        self.dut.send_expect("quit", "#", 15)
+
     def tear_down(self):
         """
         Run after each test case.
         """
-        self.close_session()
         self.vm_dut.kill_all()
         self.dut.kill_all()
         self.vm.stop()
@@ -195,4 +237,4 @@ class TestVdevPrimarySecondary(TestCase):
         """
         Run after each test suite.
         """
-        pass
+        self.close_session()
-- 
2.25.1


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

* [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan
@ 2022-04-22  7:59 Wei Ling
  0 siblings, 0 replies; 8+ messages in thread
From: Wei Ling @ 2022-04-22  7:59 UTC (permalink / raw)
  To: dts; +Cc: Wei Ling

Add automation testcase2 sync with testplan and optimize code.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_vdev_primary_secondary.py | 148 ++++++++++++++--------
 1 file changed, 95 insertions(+), 53 deletions(-)

diff --git a/tests/TestSuite_vdev_primary_secondary.py b/tests/TestSuite_vdev_primary_secondary.py
index 7f054cda..4c9dba8e 100644
--- a/tests/TestSuite_vdev_primary_secondary.py
+++ b/tests/TestSuite_vdev_primary_secondary.py
@@ -47,6 +47,7 @@ import time
 import framework.utils as utils
 from framework.test_case import TestCase
 from framework.virt_common import VM
+from framework.pmd_output import PmdOutput
 
 
 class TestVdevPrimarySecondary(TestCase):
@@ -59,14 +60,16 @@ class TestVdevPrimarySecondary(TestCase):
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
-        cores = self.dut.get_core_list("1S/12C/1T", socket=self.ports_socket)
-        self.coremask = utils.create_mask(cores)
-        self.verify(len(self.coremask) >= 6, "The machine has too few cores.")
+        self.cores = self.dut.get_core_list("all", socket=self.ports_socket)
+        self.vhost_cores = self.cores[0:6]
+        self.verify(len(self.vhost_cores) >= 6, "The machine has too few cores.")
         self.base_dir = self.dut.base_dir.replace("~", "/root")
-        self.pci_info = self.dut.ports_info[0]["pci"]
         self.app_testpmd_path = self.dut.apps_name["test-pmd"]
         self.app_symmetric_mp_path = self.dut.apps_name["symmetric_mp"]
+        self.app_hotplug_mp_path = self.dut.apps_name["hotplug_mp"]
         self.testpmd_name = self.app_testpmd_path.split("/")[-1]
+        self.vhost_user = self.dut.create_session("vhost-user")
+        self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user)
 
     def set_up(self):
         """
@@ -89,7 +92,7 @@ class TestVdevPrimarySecondary(TestCase):
             vm_params["opt_mac"] = "%s%d" % (self.virtio_mac, i + 2)
             vm_params["opt_queue"] = self.queues
             vm_params["opt_server"] = "server"
-            vm_params["opt_settings"] = "mrg_rxbuf=on,mq=on,vectors=%d" % (
+            vm_params["opt_settings"] = "mrg_rxbuf=on,csum=on,mq=on,vectors=%d" % (
                 2 * self.queues + 2
             )
             self.vm.set_vm_device(**vm_params)
@@ -103,33 +106,14 @@ class TestVdevPrimarySecondary(TestCase):
 
         return True
 
-    def launch_testpmd(self):
+    def launch_testpmd(self, param, eal_param):
         """
         launch testpmd
         """
-        testcmd = self.app_testpmd_path + " "
-        vdev1 = " --vdev 'net_vhost0,iface=%s/vhost-net0,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        vdev2 = " --vdev 'net_vhost1,iface=%s/vhost-net1,queues=%d,client=1'" % (
-            self.base_dir,
-            self.queues,
-        )
-        eal_params = self.dut.create_eal_parameters(
-            cores="1S/12C/1T", prefix="vhost", ports=[self.pci_info]
-        )
-        para = " -- -i --nb-cores=4 --rxq=%d --txq=%d --txd=1024 --rxd=1024" % (
-            self.queues,
-            self.queues,
-        )
-        start_cmd = testcmd + eal_params + vdev1 + vdev2 + para
-        self.dut.send_expect(start_cmd, "testpmd> ", 120)
-        self.dut.send_expect("set fwd txonly", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ", 120)
+        self.vhost_user_pmd.start_testpmd(cores=self.vhost_cores, param=param, eal_param=eal_param, prefix='vhost', fixed_prefix=True, no_pci=True)
 
-    def launch_examples(self):
-        example_cmd_auto = (
+    def launch_symmetric_mp(self):
+        example_cmd_primary = (
             self.app_symmetric_mp_path
             + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
         )
@@ -137,53 +121,111 @@ class TestVdevPrimarySecondary(TestCase):
             self.app_symmetric_mp_path
             + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
         )
-        final_cmd_first = example_cmd_auto % (self.mem_channels, self.queues)
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
+        final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
+        self.vm_primary.send_expect(final_cmd_primary, "Lcore", 120)
+        time.sleep(3)
+        self.vm_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+
+    def launch_hotplug_mp(self):
+        example_cmd_primary = (
+            self.app_hotplug_mp_path
+            + " -l 0 -n %d --proc-type=auto -- -p 3 --num-procs=%d --proc-id=0"
+        )
+        example_cmd_secondary = (
+            self.app_hotplug_mp_path
+            + " -l 1 -n %d --proc-type=secondary -- -p 3 --num-procs=%d --proc-id=1"
+        )
+        final_cmd_primary = example_cmd_primary % (self.mem_channels, self.queues)
         final_cmd_secondary = example_cmd_secondary % (self.mem_channels, self.queues)
-        self.vhost_first.send_expect(final_cmd_first, "Lcore", 120)
+        self.vm_primary.send_expect(final_cmd_primary, "example>", 120)
         time.sleep(3)
-        self.vhost_secondary.send_expect(final_cmd_secondary, "Lcore", 120)
+        self.vm_secondary.send_expect(final_cmd_secondary, "example>", 120)
+
+    def check_etherdev(self, dev_list):
+        primary_out = self.vm_primary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in primary_out, "dev {} not in the list")
+        secondary_out = self.vm_secondary.send_expect("list", "example", 120)
+        for dev in dev_list:
+            self.verify(dev in secondary_out, "dev {} not in the list")
+
+    def detach_etherdev_from_primary(self, dev_pci):
+        self.vm_primary.send_expect("detach {}".format(dev_pci), "example", 120)
+
+    def attach_etherdev_from_secondary(self, dev_pci):
+        self.vm_secondary.send_expect("attach {}".format(dev_pci), "example", 120)
 
     def prepare_symmetric_mp(self):
         out = self.vm_dut.build_dpdk_apps("./examples/multi_process/symmetric_mp")
         self.verify("Error" not in out, "compilation symmetric_mp error")
 
-    def close_session(self):
-        self.vm_dut.close_session(self.vhost_first)
-        self.vm_dut.close_session(self.vhost_secondary)
+    def prepare_hotplug_mp(self):
+        out = self.vm_dut.build_dpdk_apps("./examples/multi_process/hotplug_mp")
+        self.verify("Error" not in out, "compilation hotplug_mp error")
 
-    def test_Virtio_primary_and_secondary_process(self):
-        # start testpmd
-        self.launch_testpmd()
+    def close_session(self):
+        self.vm_dut.close_session(self.vm_primary)
+        self.vm_dut.close_session(self.vm_secondary)
+        self.dut.close_session(self.vhost_user)
+
+    def test_virtio_primary_and_secondary_process(self):
+        vhost_eal_param = "--vdev 'net_vhost,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
         self.setup_vm_env()
-        # Modify code
         self.prepare_symmetric_mp()
-        # create 2 new session
-        self.vhost_first = self.vm_dut.new_session(suite="vhost_first")
-        self.vhost_secondary = self.vm_dut.new_session(suite="vhsot_secondary")
-        # start symmetric_mp
-        self.launch_examples()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_symmetric_mp()
+        self.vhost_user_pmd.execute_cmd("set fwd mac")
+        self.vhost_user_pmd.execute_cmd("start tx_first")
         time.sleep(3)
-        vhost_first_out = self.vhost_first.send_expect("^c", "#", 15)
-        print(vhost_first_out)
+        vm_primary_out = self.vm_primary.send_expect("^c", "#", 15)
+        print(vm_primary_out)
         time.sleep(3)
-        vhost_secondary_out = self.vhost_secondary.send_expect("^c", "#", 15)
-        print(vhost_secondary_out)
-        result_first = re.findall(r"Port \d: RX - (\w+)", vhost_first_out)
-        result_secondary = re.findall(r"Port \d: RX - (\w+)", vhost_secondary_out)
+        vm_secondary_out = self.vm_secondary.send_expect("^c", "#", 15)
+        print(vm_secondary_out)
+        result_primary = re.findall(r"Port \d: RX - (\w+)", vm_primary_out)
+        result_secondary = re.findall(r"Port \d: RX - (\w+)", vm_secondary_out)
         self.verify(
-            len(result_first[0]) != 0
-            and len(result_first[1]) != 0
+            len(result_primary[0]) != 0
+            and len(result_primary[1]) != 0
             and len(result_secondary[0]) != 0
             and len(result_secondary[1]) != 0,
             "RX no data",
         )
         self.dut.send_expect("quit", "#", 15)
 
+    def test_virtio_primay_and_secondary_process_hotplug(self):
+        vhost_eal_param = "--vdev 'net_vhost0,iface=vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=vhost-net1,queues=2,client=1'"
+        vhost_param = "--nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024"
+        self.launch_testpmd(param=vhost_param, eal_param=vhost_eal_param)
+        self.vhost_user_pmd.execute_cmd("set fwd txonly")
+        self.vhost_user_pmd.execute_cmd("start")
+        self.setup_vm_env()
+        self.prepare_hotplug_mp()
+        self.vm_primary = self.vm_dut.new_session(suite="vm_primary")
+        self.vm_secondary = self.vm_dut.new_session(suite="vm_secondary")
+        self.launch_hotplug_mp()
+        vm_ports = []
+        for pci_info in self.vm_dut.ports_info:
+            vm_ports.append(pci_info['pci'])
+        self.check_etherdev(dev_list=vm_ports)
+        detach_pci = vm_ports[0]
+        for _ in range(2):
+            self.detach_etherdev_from_primary(dev_pci=detach_pci)
+            vm_ports.remove(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+            self.attach_etherdev_from_secondary(dev_pci=detach_pci)
+            vm_ports.append(detach_pci)
+            self.check_etherdev(dev_list=vm_ports)
+        self.dut.send_expect("quit", "#", 15)
+
     def tear_down(self):
         """
         Run after each test case.
         """
-        self.close_session()
         self.vm_dut.kill_all()
         self.dut.kill_all()
         self.vm.stop()
@@ -195,4 +237,4 @@ class TestVdevPrimarySecondary(TestCase):
         """
         Run after each test suite.
         """
-        pass
+        self.close_session()
-- 
2.25.1


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

end of thread, other threads:[~2022-04-25  1:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22  8:17 [dts][PATCH V1 2/2] tests/vdev_primary_secondary: add automation testcase2 sync with testplan Wei Ling
2022-04-22  8:31 ` He, Xingguang
  -- strict thread matches above, loose matches on Subject: below --
2022-04-25  1:57 Wei Ling
2022-04-22  9:20 Wei Ling
2022-04-22  9:27 ` He, Xingguang
2022-04-22  9:11 Wei Ling
2022-04-22  9:20 ` He, Xingguang
2022-04-22  7:59 Wei Ling

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