test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] tests/virtio_smoke:add new virtio smoke test suite sync with testplan
@ 2020-12-23 16:33 Ling Wei
  0 siblings, 0 replies; only message in thread
From: Ling Wei @ 2020-12-23 16:33 UTC (permalink / raw)
  To: dts; +Cc: Ling Wei

add new virtio smoke test suite sync with testplan

Signed-off-by: Ling Wei <weix.ling@intel.com>
---
 tests/TestSuite_virtio_smoke.py | 205 ++++++++++++++++++++++++++++++++
 1 file changed, 205 insertions(+)
 create mode 100644 tests/TestSuite_virtio_smoke.py

diff --git a/tests/TestSuite_virtio_smoke.py b/tests/TestSuite_virtio_smoke.py
new file mode 100644
index 00000000..a13c5479
--- /dev/null
+++ b/tests/TestSuite_virtio_smoke.py
@@ -0,0 +1,205 @@
+# BSD LICENSE\r
+#\r
+# Copyright(c) <2019> Intel Corporation. All rights reserved.\r
+# All rights reserved.\r
+#\r
+# Redistribution and use in source and binary forms, with or without\r
+# modification, are permitted provided that the following conditions\r
+# are met:\r
+#\r
+#   * Redistributions of source code must retain the above copyright\r
+#     notice, this list of conditions and the following disclaimer.\r
+#   * Redistributions in binary form must reproduce the above copyright\r
+#     notice, this list of conditions and the following disclaimer in\r
+#     the documentation and/or other materials provided with the\r
+#     distribution.\r
+#   * Neither the name of Intel Corporation nor the names of its\r
+#     contributors may be used to endorse or promote products derived\r
+#     from this software without specific prior written permission.\r
+#\r
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+"""\r
+DPDK Test suite.\r
+"""\r
+\r
+import re\r
+from test_case import TestCase\r
+from packet import Packet\r
+from pktgen import PacketGeneratorHelper\r
+from pmd_output import PmdOutput\r
+\r
+\r
+class TestVirtioSmoke(TestCase):\r
+\r
+\r
+    def set_up_all(self):\r
+        """\r
+        Run at the start of each test suite.\r
+        """\r
+        self.vhost_user = self.dut.new_session(suite="vhost-user")\r
+        self.virtio_user1 = self.dut.new_session(suite="virtio-user1")\r
+        self.pmdout_vhost_user = PmdOutput(self.dut, self.vhost_user)\r
+        self.pmdout_virtio_user1 = PmdOutput(self.dut, self.virtio_user1)\r
+        self.frame_sizes_list = [64, 1518]\r
+        self.dst_mac = "00:01:02:03:04:05"\r
+        self.dut_ports = self.dut.get_ports()\r
+        self.socket = self.dut.get_numa_id(self.dut_ports[0])\r
+        self.cores = self.dut.get_core_list("all", socket=self.socket)\r
+        self.vhost_cores = self.cores[0:3]\r
+        self.virtio1_cores = self.cores[3:6]\r
+        # the path of pcap file\r
+        self.out_path = '/tmp'\r
+        out = self.tester.send_expect('ls -d %s' % self.out_path, '# ')\r
+        if 'No such file or directory' in out:\r
+            self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')\r
+        self.pktgen_helper = PacketGeneratorHelper()\r
+        self.base_dir = self.dut.base_dir.replace('~', '/root')\r
+\r
+    def set_up(self):\r
+        """\r
+        Run before each test case.\r
+        """\r
+        self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#")\r
+\r
+    @property\r
+    def check_2M_env(self):\r
+        out = self.dut.send_expect("cat /proc/meminfo |grep Hugepagesize|awk '{print($2)}'", "# ")\r
+        return True if out == '2048' else False\r
+\r
+    def launch_testpmd_as_vhost_user(self, param, cores="Default", udev="", ports=[], no_pci=True):\r
+        self.pmdout_vhost_user.start_testpmd(cores=cores, param=param, vdevs=[udev], ports=ports, prefix="vhost", fixed_prefix=True, no_pci=no_pci)\r
+        self.vhost_user.send_expect('set fwd mac', 'testpmd> ', 30)\r
+\r
+    def launch_testpmd_as_virtio_user1(self, param, cores="Default", udev="", no_pci=True):\r
+        eal_param = ""\r
+        if self.check_2M_env:\r
+            eal_param += " --single-file-segments"\r
+        if 'vectorized' in self.running_case:\r
+            eal_param += " --force-max-simd-bitwidth=512"\r
+        self.pmdout_virtio_user1.start_testpmd(cores=cores, param=param, vdevs=[udev], ports=[], prefix="virtio1", fixed_prefix=True, eal_param=eal_param, no_pci=no_pci)\r
+\r
+    def verify_vhost_queue_rx_tx_pkts(self, queue_list):\r
+        out = self.vhost_user.send_expect('stop', 'testpmd> ', 30)\r
+        for queue_index in queue_list:\r
+            queue = "Queue= %d" % queue_index\r
+            index = out.find(queue)\r
+            rx = re.search("RX-packets:\s*(\d*)", out[index:])\r
+            tx = re.search("TX-packets:\s*(\d*)", out[index:])\r
+            rx_packets = int(rx.group(1))\r
+            tx_packets = int(tx.group(1))\r
+            self.verify(rx_packets > 0 and tx_packets > 0,\r
+                        "The queue %d rx-packets or tx-packets is 0 about " % queue_index + "rx-packets:%d, tx-packets:%d" % (rx_packets, tx_packets))\r
+\r
+    def test_loopback_reconnect_test_with_split_ring_mergeable_path_and_server_mode(self):\r
+        param = " --nb-cores={} --rxq={} --txq={}"\r
+        other_param = " --tx-offloads=0x0 --enable-hw-vlan-strip --rss-ip"\r
+        vhost_dev = f"'eth_vhost0,iface=vhost-net,client=1,queues=8'"\r
+        virtio_dev = f"'net_virtio_user0,mac={self.dst_mac},path=./vhost-net,server=1,queues=8,mrg_rxbuf=1,in_order=1'"\r
+\r
+        self.logger.info("Launch vhost as client mode with 2 queues")\r
+        nb_core = 2\r
+        vhost_rxq_txq = 2\r
+        virtio_rxq_txq = 8\r
+        vhost_param = param.format(nb_core, vhost_rxq_txq, vhost_rxq_txq)\r
+        virtio_param = (other_param + param).format(nb_core, virtio_rxq_txq, virtio_rxq_txq)\r
+        self.launch_testpmd_as_vhost_user(param=vhost_param, cores=self.vhost_cores, udev=vhost_dev, no_pci=True)\r
+        self.vhost_user.send_expect('start', 'testpmd> ', 30)\r
+        self.logger.info("Launch virtio-user as server mode with 8 queues")\r
+        self.launch_testpmd_as_virtio_user1(param=virtio_param, cores=self.virtio1_cores, udev=virtio_dev, no_pci=True)\r
+        self.virtio_user1.send_expect('set fwd mac', 'testpmd> ', 30)\r
+        self.virtio_user1.send_expect('start tx_first 32', 'testpmd> ', 30)\r
+        self.verify_vhost_queue_rx_tx_pkts(queue_list=range(vhost_rxq_txq))\r
+        self.vhost_user.send_expect("quit", "# ", 20)\r
+\r
+        self.logger.info("Relaunch vhost with 8 queues and send packets")\r
+        vhost_rxq_txq = 8\r
+        vhost_param = param.format(nb_core, vhost_rxq_txq, vhost_rxq_txq)\r
+        self.launch_testpmd_as_vhost_user(param=vhost_param, cores=self.cores[0:3], udev=vhost_dev, no_pci=True)\r
+        self.vhost_user.send_expect('start tx_first 32', 'testpmd> ', 30)\r
+        self.vhost_user.send_expect('stop', 'testpmd> ', 30)\r
+        self.vhost_user.send_expect('set burst 1', 'testpmd> ', 30)\r
+        self.vhost_user.send_expect('start tx_first 1', 'testpmd> ', 30)\r
+        self.verify_vhost_queue_rx_tx_pkts(queue_list=range(vhost_rxq_txq))\r
+\r
+        self.virtio_user1.send_expect("quit", "# ", 20)\r
+        self.vhost_user.send_expect("quit", "# ", 20)\r
+\r
+    def config_stream(self, frame_size):\r
+        tgen_input = []\r
+        rx_port = self.tester.get_local_port(self.dut_ports[0])\r
+        tx_port = self.tester.get_local_port(self.dut_ports[0])\r
+        dst_mac = self.dut.get_mac_address(self.dut_ports[0])\r
+        pkt = Packet(pkt_type='UDP', pkt_len=frame_size)\r
+        pkt.config_layer('ether', {'dst': dst_mac})\r
+        pkt.save_pcapfile(self.tester, "%s/virtio_smoke.pcap" % (self.out_path))\r
+        tgen_input.append((rx_port, tx_port, "%s/virtio_smoke.pcap" % (self.out_path)))\r
+        return tgen_input\r
+\r
+    def perf_test(self, frame_size_list, case_info):\r
+        # Create test results table\r
+        table_header = ['Frame Size(Byte)', 'Mode', 'Throughput(Mpps)']\r
+        self.result_table_create(table_header)\r
+        # Begin test perf\r
+        for frame_size in frame_size_list:\r
+            test_result = {}\r
+            self.logger.info("Test running at parameters: " + "framesize: {}".format(frame_size))\r
+            tgenInput = self.config_stream(frame_size)\r
+            # clear streams before add new streams\r
+            self.tester.pktgen.clear_streams()\r
+            # run packet generator\r
+            streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100, None, self.tester.pktgen)\r
+            # set traffic option\r
+            traffic_opt = {'duration': 5}\r
+            _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)\r
+            self.verify(pps > 0, "No traffic detected")\r
+            throughput = pps / 1000000.0\r
+            test_result[frame_size] = throughput\r
+            self.result_table_add([frame_size, case_info, throughput])\r
+        self.result_table_print()\r
+        return test_result\r
+\r
+    def test_perf_pvp_test_with_virtio_packed_ring_vectorized_path(self):\r
+        param = " --nb-cores={} --txd={} --rxd={}"\r
+        vhost_dev = f"'net_vhost0,iface=vhost-net,queues=1'"\r
+        virtio_dev = f"'net_virtio_user0,mac={self.dst_mac},path=./vhost-net,packed_vq=1,mrg_rxbuf=0,in_order=1,vectorized=1,queue_size=1024'"\r
+        self.logger.info("Launch vhost")\r
+        nb_core = 2\r
+        vhost_rxd_txd = 1024\r
+        vhost_param = param.format(nb_core, vhost_rxd_txd, vhost_rxd_txd)\r
+        port = self.dut.ports_info[self.dut_ports[0]]['pci']\r
+        self.launch_testpmd_as_vhost_user(param=vhost_param, cores=self.vhost_cores, udev=vhost_dev, ports=[port], no_pci=False)\r
+        self.vhost_user.send_expect('start', 'testpmd> ', 30)\r
+\r
+        self.logger.info("Launch virtio")\r
+        nb_core = 1\r
+        virtio_param = param.format(nb_core, vhost_rxd_txd, vhost_rxd_txd)\r
+        self.launch_testpmd_as_virtio_user1(param=virtio_param, cores=self.virtio1_cores, udev=virtio_dev, no_pci=True)\r
+        self.virtio_user1.send_expect('set fwd mac', 'testpmd> ', 30)\r
+        self.virtio_user1.send_expect('start', 'testpmd> ', 30)\r
+\r
+        self.logger.info("Start perf test")\r
+        self.perf_test(frame_size_list=self.frame_sizes_list, case_info='virtio packed ring vectorized path')\r
+\r
+    def tear_down(self):\r
+        """\r
+        Run after each test case.\r
+        """\r
+        self.dut.close_session(self.vhost_user)\r
+        self.dut.close_session(self.virtio_user1)\r
+\r
+    def tear_down_all(self):\r
+        """\r
+        Run after each test suite.\r
+        """\r
+        pass\r
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-23  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23 16:33 [dts] [PATCH V1] tests/virtio_smoke:add new virtio smoke test suite sync with testplan Ling Wei

test suite reviews and discussions

This inbox may be cloned and mirrored by anyone:

	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

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


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