test suite reviews and discussions
 help / color / mirror / Atom feed
From: Wei Ling <weix.ling@intel.com>
To: dts@dpdk.org
Cc: Wei Ling <weix.ling@intel.com>
Subject: [dts][PATCH V1 1/2] tests/pvp_virtio_user_4k_pages: add expected value to verify
Date: Mon, 24 Apr 2023 18:18:19 +0800	[thread overview]
Message-ID: <20230424101820.2598235-2-weix.ling@intel.com> (raw)
In-Reply-To: <20230424101820.2598235-1-weix.ling@intel.com>

Optimize the verify the expected value from the hard code to read from
conf/pvp_virtio_user_4k_pages.cfg to adapt different platform.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_pvp_virtio_user_4k_pages.py | 131 +++++++++++++-------
 1 file changed, 86 insertions(+), 45 deletions(-)

diff --git a/tests/TestSuite_pvp_virtio_user_4k_pages.py b/tests/TestSuite_pvp_virtio_user_4k_pages.py
index 3e3e09b4..aa41cd50 100644
--- a/tests/TestSuite_pvp_virtio_user_4k_pages.py
+++ b/tests/TestSuite_pvp_virtio_user_4k_pages.py
@@ -2,16 +2,11 @@
 # Copyright(c) 2019 Intel Corporation
 #
 
-"""
-DPDK Test suite.
-vhost/virtio-user pvp with 4K pages.
-"""
+from copy import deepcopy
 
-import time
-
-import framework.utils as utils
 from framework.packet import Packet
 from framework.pktgen import PacketGeneratorHelper
+from framework.settings import UPDATE_EXPECTED, load_global_setting
 from framework.test_case import TestCase
 
 
@@ -41,6 +36,8 @@ class TestPvpVirtioUser4kPages(TestCase):
         self.core_list_virtio_user = self.core_list[0:2]
         self.core_list_vhost_user = self.core_list[2:4]
         self.pci_info = self.dut.ports_info[0]["pci"]
+        self.nb_ports = 1
+        self.gap = self.get_suite_cfg()["accepted_tolerance"]
         self.dst_mac = self.dut.get_mac_address(self.dut_ports[0])
         self.frame_sizes = [64, 128, 256, 512, 1024, 1518]
         self.logger.info(
@@ -68,35 +65,19 @@ class TestPvpVirtioUser4kPages(TestCase):
         self.dut.send_expect("killall -s INT %s" % self.testpmd_name, "# ")
         self.vhost_user = self.dut.new_session(suite="vhost-user")
         self.virtio_user = self.dut.new_session(suite="virtio-user")
+        self.throughput = dict()
+        self.test_result = dict()
         # Prepare the result table
         self.table_header = ["Frame"]
-        self.table_header.append("Mode")
         self.table_header.append("Mpps")
-        self.table_header.append("Queue Num")
         self.table_header.append("% linerate")
-        self.result_table_create(self.table_header)
 
-    @property
-    def check_value(self):
-        check_dict = dict.fromkeys(self.frame_sizes)
-        linerate = {
-            64: 0.08,
-            128: 0.10,
-            256: 0.18,
-            512: 0.20,
-            1024: 0.40,
-            1280: 0.45,
-            1518: 0.50,
-        }
-        for size in self.frame_sizes:
-            speed = self.wirespeed(self.nic, size, self.number_of_ports)
-            check_dict[size] = round(speed * linerate[size], 2)
-        return check_dict
-
-    def send_and_verify(self):
-        """
-        Send packet with packet generator and verify
+    def perf_test(self):
+        """
+        Send packet with packet generator
         """
+        self.result_table_create(self.table_header)
+        self.throughput = {}
         for frame_size in self.frame_sizes:
             tgen_input = []
             rx_port = self.tester.get_local_port(self.dut_ports[0])
@@ -110,21 +91,71 @@ class TestPvpVirtioUser4kPages(TestCase):
             streams = self.pktgen_helper.prepare_stream_from_tginput(
                 tgen_input, 100, None, self.tester.pktgen
             )
-            _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
-            Mpps = pps / 1000000.0
-            self.verify(
-                Mpps > self.check_value[frame_size],
-                "%s of frame size %d speed verify failed, expect %s, result %s"
-                % (self.running_case, frame_size, self.check_value[frame_size], Mpps),
+            # set traffic option
+            traffic_opt = {
+                "delay": 5,
+                "duration": self.get_suite_cfg()["test_duration"],
+            }
+            _, pps = self.tester.pktgen.measure_throughput(
+                stream_ids=streams, options=traffic_opt
             )
-            throughput = Mpps * 100 / float(self.wirespeed(self.nic, 64, 1))
-
+            Mpps = pps / 1000000.0
+            line_rate = Mpps * 100 / float(self.wirespeed(self.nic, 64, 1))
+            self.throughput[frame_size] = Mpps
             results_row = [frame_size]
-            results_row.append("4K pages")
             results_row.append(Mpps)
-            results_row.append("1")
-            results_row.append(throughput)
+            results_row.append(line_rate)
             self.result_table_add(results_row)
+        self.result_table_print()
+
+    def handle_expected(self):
+        """
+        Update expected numbers to configurate file: $DTS_CFG_FOLDER/$suite_name.cfg
+        """
+        if load_global_setting(UPDATE_EXPECTED) == "yes":
+            for frame_size in self.frame_sizes:
+                self.expected_throughput[frame_size] = round(
+                    self.throughput[frame_size], 3
+                )
+
+    def handle_results(self):
+        """
+        results handled process:
+        1, save to self.test_results
+        2, create test results table
+        """
+        # save test results to self.test_result
+        header = self.table_header
+        header.append("Expected Throughput(Mpps)")
+        header.append("Status")
+        self.result_table_create(self.table_header)
+        for frame_size in self.frame_sizes:
+            wirespeed = self.wirespeed(self.nic, frame_size, self.nb_ports)
+            ret_data = {}
+            ret_data[header[0]] = str(frame_size)
+            _real = float(self.throughput[frame_size])
+            _exp = float(self.expected_throughput[frame_size])
+            ret_data[header[1]] = "{:.3f}".format(_real)
+            ret_data[header[2]] = "{:.3f}%".format(_real * 100 / wirespeed)
+            ret_data[header[3]] = "{:.3f}".format(_exp)
+            gap = _exp * -self.gap * 0.01
+            if _real > _exp + gap:
+                ret_data[header[4]] = "PASS"
+            else:
+                ret_data[header[4]] = "FAIL"
+            self.test_result[frame_size] = deepcopy(ret_data)
+
+        for frame_size in self.test_result.keys():
+            table_row = list()
+            for i in range(len(header)):
+                table_row.append(self.test_result[frame_size][header[i]])
+            self.result_table_add(table_row)
+        # present test results to screen
+        self.result_table_print()
+        self.verify(
+            "FAIL" not in self.test_result,
+            "Excessive gap between test results and expectations",
+        )
 
     def start_testpmd_as_vhost(self):
         """
@@ -187,22 +218,32 @@ class TestPvpVirtioUser4kPages(TestCase):
         """
         Basic test for virtio-user 4K pages
         """
+        self.test_target = self.running_case
+        self.expected_throughput = self.get_suite_cfg()["expected_throughput"][
+            self.test_target
+        ]
         self.start_testpmd_as_vhost()
         self.prepare_tmpfs_for_4k()
         self.start_testpmd_as_virtio()
-        self.send_and_verify()
-        self.result_table_print()
+        self.perf_test()
+        self.handle_expected()
+        self.handle_results()
         self.close_all_apps()
 
     def test_perf_pvp_virtio_user_packed_ring_with_4K_pages(self):
         """
         Basic test for virtio-user 4K pages
         """
+        self.test_target = self.running_case
+        self.expected_throughput = self.get_suite_cfg()["expected_throughput"][
+            self.test_target
+        ]
         self.start_testpmd_as_vhost()
         self.prepare_tmpfs_for_4k()
         self.start_testpmd_as_virtio(packed=True)
-        self.send_and_verify()
-        self.result_table_print()
+        self.perf_test()
+        self.handle_expected()
+        self.handle_results()
         self.close_all_apps()
 
     def tear_down(self):
-- 
2.25.1


  reply	other threads:[~2023-04-24 10:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 10:18 [dts][PATCH V1 0/2] " Wei Ling
2023-04-24 10:18 ` Wei Ling [this message]
2023-04-24 10:18 ` [dts][PATCH V1 2/2] conf/pvp_virtio_user_4k_pages: " Wei Ling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230424101820.2598235-2-weix.ling@intel.com \
    --to=weix.ling@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).