test suite reviews and discussions
 help / color / mirror / Atom feed
From: hanyingya <yingyax.han@intel.com>
To: dts@dpdk.org
Cc: hanyingya <yingyax.han@intel.com>
Subject: [dts] [PATCH V2]tests/vmdq: vmdq script refactoring
Date: Wed, 25 Mar 2020 13:08:22 +0800	[thread overview]
Message-ID: <1585112902-137050-1-git-send-email-yingyax.han@intel.com> (raw)

script refactoring and enable rss.

Signed-off-by: hanyingya <yingyax.han@intel.com>
---
 tests/TestSuite_vmdq.py | 328 +++++++++++++++++-----------------------
 1 file changed, 142 insertions(+), 186 deletions(-)

diff --git a/tests/TestSuite_vmdq.py b/tests/TestSuite_vmdq.py
index 623d728..cb6bdf0 100644
--- a/tests/TestSuite_vmdq.py
+++ b/tests/TestSuite_vmdq.py
@@ -11,44 +11,52 @@ import os
 import re
 from test_case import TestCase
 from time import sleep
+from settings import HEADER_SIZE
 from pktgen import PacketGeneratorHelper
 
+
 class TestVmdq(TestCase):
-    dut_ports = []
-    ip_dot1q_header_size = 22
-    default_framesize = 64
-    default_payload = default_framesize - ip_dot1q_header_size
-    current_frame_size = 0
-    destmac_port0 = "52:54:00:12:00:00"
-    destmac_port1 = "52:54:00:12:01:00"
-    da_repeat = 1
-    vlan_repeat = 1 
-    queues = 8
 
     def set_up_all(self):
         """
         Run at the start of each test suite.
         """
         self.tester.extend_external_packet_generator(TestVmdq, self)
-        
+
+        self.dut_ports = self.dut.get_ports(self.nic)
+        self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
+        self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
+
         self.dut.send_expect("sed -i 's/CONFIG_RTE_MAX_QUEUES_PER_PORT=256/CONFIG_RTE_MAX_QUEUES_PER_PORT=1024/' ./config/common_base", "# ", 5)
-        
         self.dut.build_install_dpdk(self.target)
         # Update the max queue per port for Fortville.
         self.dut.send_expect("sed -i 's/define MAX_QUEUES 128/define MAX_QUEUES 1024/' ./examples/vmdq/main.c", "#", 5)
-        
-        self.dut_ports = self.dut.get_ports(self.nic)
-        self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
+        out = self.dut.send_expect("make -C examples/vmdq", "#", 10)
+        self.verify("Error" not in out, "Compilation error")
 
+        self.frame_size = 64
+        self.header_size = HEADER_SIZE['ip'] + HEADER_SIZE['eth']
+        self.destmac_port = ["52:54:00:12:0%d:00" % i for i in self.dut_ports]
         self.core_configs = []
         self.core_configs.append({'cores': '1S/1C/1T', 'mpps': {}})
         self.core_configs.append({'cores': '1S/2C/1T', 'mpps': {}})
         self.core_configs.append({'cores': '1S/2C/2T', 'mpps': {}})
         self.core_configs.append({'cores': '1S/4C/1T', 'mpps': {}})
 
-        self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
-        out = self.dut.send_expect("make -C examples/vmdq", "#", 10)
-        self.verify("Error" not in out, "Compilation error")
+        # Put different number of pools: in the case of 10G 82599 Nic is 64, in the case
+        # of FVL spirit is 63,in case of FVL eagle is 34.
+        if self.nic in ("niantic", "springfountain"):
+            self.pools = 64
+        elif self.nic in ("fortville_spirit", "fortville_spirit_single"):
+            self.pools = 63
+        elif self.nic in ("fortville_eagle"):
+            self.pools = 34
+        else:
+            self.pools = 8
+
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
         # get dts output path
         if self.logger.log_path.startswith(os.sep):
             self.output_path = self.logger.log_path
@@ -58,208 +66,137 @@ class TestVmdq(TestCase):
             self.output_path = os.sep.join([cur_path, self.logger.log_path])
         # create an instance to set stream field setting
         self.pktgen_helper = PacketGeneratorHelper()
+        self.prios = range(8)
 
-    def validateApproxEqual(self, lines):
+    def set_up(self):
         """
-        Check that all the rx queue stats are within a 30% range.
+        Run before each test case.
         """
-        minimum = 1000000
-        maximun = 0
+        pass
 
-        # Need to use Python re package because utils.regexp only handles 1 group,
-        # we need 4.
-        scanner = re.compile(
-            "^Pool [0-9]+: ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)$")
-        for l in lines:
-            m = scanner.search(l)
-            if m is None:
-                # Line at the end, "Finished handling signal", ignore
-                pass
-            else:
-                for stat in m.groups():
-                    if stat < minimum:
-                        minimum = stat
-                    if stat > maximun:
-                        maximun = stat
-        self.verify(maximun - minimum <= minimum *
-                    0.3, "Too wide variation in queue stats")
-
-    def Npools_128queues(self, npools):
+    def start_application(self, npools, core_config):
         """
-        MAX queues is 128
-        queues/pools = 128/npools
+        Prepare the commandline and start vmdq app
         """
-        self.current_frame_size = self.default_framesize
-
-        self.dut_ports = self.dut.get_ports(self.nic)
-
-        core_list = self.dut.get_core_list("1S/4C/1T", socket=self.ports_socket)
+        core_list = self.dut.get_core_list(core_config, socket=self.ports_socket)
+        self.verify(core_list is not None, "Requested cores failed")
         core_mask = utils.create_mask(core_list)
-
-        port_mask = utils.create_mask([self.dut_ports[0], self.dut_ports[1]])
+        port_mask = utils.create_mask(self.dut_ports)
         # Run the application
-        out = self.dut.send_expect("./examples/vmdq/build/vmdq_app -n 4 -c %s -- -p %s --nb-pools %s&" %
-                                   (core_mask, port_mask, str(npools)), "reading queues", 120)
+        self.dut.send_expect("./examples/vmdq/build/vmdq_app -c %s -n 4 -- -p %s --nb-pools %s --enable-rss" %
+                             (core_mask, port_mask, str(npools)), "reading queues", 120)
 
-        # Transmit traffic
+    def get_tgen_input(self, prios):
+        """
+        create streams for ports.
+        """
         tx_port = self.tester.get_local_port(self.dut_ports[0])
         rx_port = self.tester.get_local_port(self.dut_ports[1])
-        tx_mac = self.tester.get_mac(tx_port)
-
-        self.vlan_repeat = npools
-        self.da_repeat = npools
         tgen_input = []
-        for p in range(8):
-            self.tester.scapy_append('dmac="%s"' % self.destmac_port0)
-            self.tester.scapy_append('smac="%s"' % tx_mac)
-            self.tester.scapy_append(
-                'flows = [Ether(src=smac, dst=dmac)/Dot1Q(vlan=0,prio=%d)]'%p)
+        for prio in prios:
+            pcap = os.sep.join([self.output_path, "%s%d.pcap" % (self.suite_name, prio)])
+            tgen_input.append((tx_port, rx_port, "%s" % pcap))
+        return tgen_input
 
-            pcap = os.sep.join([self.output_path, "test%d.pcap" % p])
-            self.tester.scapy_append('wrpcap("%s", flows)' %pcap)
-
-            self.tester.scapy_execute()
-            tgen_input.append((tx_port, rx_port, "%s" %pcap))
-
-        self.tester.pktgen.clear_streams()
-        vm_config = self.set_fields()
-        # run packet generator
-        streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 10,
-                                                        vm_config, self.tester.pktgen)
-        loss = self.tester.pktgen.measure_loss(stream_ids=streams)
-        self.logger.info("loss is {}!".format(loss))
+    def create_pcaps(self, prios):
+        """
+        create traffic flows to pcap files
+        """
+        payload = self.frame_size - self.header_size
+        for prio in prios:
+            self.tester.scapy_append(
+                'flows = [Ether(dst="%s")/Dot1Q(vlan=0,prio=%d)/IP(src="1.2.3.4", dst="1.1.1.1")/("X"*%d)]'
+                % (self.destmac_port[0], prio, payload))
+            pcap = os.sep.join([self.output_path, "%s%d.pcap" % (self.suite_name, prio)])
+            self.tester.scapy_append('wrpcap("%s", flows)' % pcap)
+        self.tester.scapy_execute()
 
-        # Verify the accurate
-        self.verify(loss[0]/100 < 0.001, "Excessive packet loss")
+    def verify_all_vmdq_stats(self):
+        """
+        Every RX queue should have received approximately (+/-15%) the same number of incoming packets.
+        """
         out = self.get_vmdq_stats()
-        self.validateApproxEqual(out.split("\r\n"))
+        lines_list = out.split("\r\n")
+        nb_packets = []
+        for pool_info in lines_list:
+            if pool_info.startswith('Pool'):
+                nb_packets += pool_info.split()[2:]
+        nb_packets = list(map(int, nb_packets))
+        self.verify(min(nb_packets) > 0, "Some queues don't get any packet!")
+        self.verify(float((max(nb_packets) - min(nb_packets))/max(nb_packets)) <= 0.15,
+                    "Too wide variation in queue stats")
 
     def get_vmdq_stats(self):
-        vmdq_dcb_session = self.dut.new_session()
-        vmdq_dcb_session.send_expect("kill -s SIGHUP  `pgrep -fl vmdq_app | awk '{print $1}'`", "#", 20)
+        vmdq_session = self.dut.new_session()
+        vmdq_session.send_expect("kill -s SIGHUP  `pgrep -fl vmdq_app | awk '{print $1}'`", "#", 20)
         out = self.dut.get_session_output()
         self.logger.info(out)
-        vmdq_dcb_session.close()
+        vmdq_session.close()
         return out
 
-    def set_up(self):
+    def test_perf_vmdq_max_queues(self):
         """
-        Run before each test case.
+        Every RX queue should have received approximately (+/-15%) the same number of
+        incoming packets.
         """
-        self.dut.kill_all()
-
-    def test_perf_vmdq_64pools_queues(self):
-        """
-        This function call "Npools_128queues" with different number
-        of pools. Details see below. If not sure, set it as 8 pools.
-        """
-        if self.nic in ("niantic", "springfountain"):
-            self.Npools_128queues(64)
-        elif self.nic in ("fortville_spirit", "fortville_spirit_single"):
-            self.Npools_128queues(63)
-        elif self.nic in ("fortville_eagle"):
-            self.Npools_128queues(34)
-        else: 
-            self.Npools_128queues(8)
+        # Run the application
+        self.start_application(self.pools, "1S/4C/1T")
+        # Transmit traffic
+        self.create_pcaps(self.prios)
+        tgen_input = self.get_tgen_input(self.prios)
+        vm_config = self.set_fields(self.pools, self.pools)
+        # Start traffic transmission using approx 10% of line rate.
+        ratePercent = 10
+        # run packet generator
+        streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, ratePercent, vm_config, self.tester.pktgen)
+        # set traffic option
+        options = {'duration': 15}
+        loss = self.tester.pktgen.measure_loss(stream_ids=streams, options=options)
+        self.logger.info("loss is [loss rate, SendNumbers, ReceNumbers]{}!".format(loss))
+        # Verify there is no packet loss
+        self.verify(loss[1] == loss[2], "Packet Loss! Send: %d, but only Receive: %d!".format(loss[1], loss[2]))
+        self.verify_all_vmdq_stats()
+
+    def create_throughput_traffic(self, frame_size):
+        payload = frame_size - self.header_size
+        tgen_Input = []
+        for _port in self.dut_ports:
+            if _port % len(self.dut_ports) == 0 or len(self.dut_ports) % _port == 2:
+                txIntf = self.tester.get_local_port(self.dut_ports[_port + 1])
+            else:
+                txIntf = self.tester.get_local_port(self.dut_ports[_port - 1])
+            rxIntf = self.tester.get_local_port(self.dut_ports[_port])
+            self.tester.scapy_append('flows = [Ether(dst="%s")/Dot1Q(vlan=0)/("X"*%d)]'
+                                     % (self.destmac_port[txIntf], payload))
+            pcap = os.sep.join([self.output_path, "%s-%d.pcap" % (self.suite_name, _port)])
+            self.tester.scapy_append('wrpcap("%s", flows)' % pcap)
+            self.tester.scapy_execute()
+            tgen_Input.append((txIntf, rxIntf, pcap))
+        return tgen_Input
 
     def test_perf_vmdq_performance(self):
         """
         Try different configuration and different packet size
         """
-        self.tester.get_interface(
-            self.tester.get_local_port(self.dut_ports[0]))
-
         frame_sizes = [64, 128, 256, 512, 1024, 1280, 1518]
         for config in self.core_configs:
-
             self.logger.info(config["cores"])
             self.dut.kill_all()
-
             core_config = config['cores']
-            core_list = self.dut.get_core_list(core_config,socket=self.ports_socket)
-            core_mask = utils.create_mask(core_list)
-            portmask = utils.create_mask(self.dut.get_ports())
-            if self.nic in ("niantic", "springfountain"):
-                self.queues = 64
-                self.dut.send_expect(
-                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 64&" %
-                    (self.dut.get_memory_channels(), core_mask, portmask), "reading queues", 30)
-            elif self.nic in ("fortville_spirit", "fortville_spirit_single"):
-                self.queues = 63
-                self.dut.send_expect(
-                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 63&" %
-                    (self.dut.get_memory_channels(), core_mask, portmask), "reading queues", 30)
-            elif self.nic in ("fortville_eagle"):
-                self.queues = 34
-                self.dut.send_expect(
-                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 34&" %
-                    (self.dut.get_memory_channels(), core_mask, portmask), "reading queues", 30)
-            else:
-                self.queues = 8
-                self.dut.send_expect(
-                    "examples/vmdq/build/vmdq_app -n %d -c %s -- -p %s --nb-pools 8&" %
-                    (self.dut.get_memory_channels(), core_mask, portmask), "reading queues", 30)
-
-            tx_port = self.tester.get_local_port(self.dut_ports[0])
-            rx_port = self.tester.get_local_port(self.dut_ports[1])
-
+            self.start_application(self.pools, core_config)
             self.logger.info("Waiting for application to initialize")
             sleep(5)
-
             for frame_size in frame_sizes:
-                TestVmdq.current_frame_size = frame_size
                 self.logger.info(str(frame_size))
-
-                self.tester.scapy_append('dstmac="%s"' % self.destmac_port0)
-                tx_mac = self.tester.get_mac(tx_port)
-                self.tester.scapy_append('srcmac="%s"' % tx_mac)
-                self.tester.scapy_append(
-                        'flows = [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=0)/("X"*%d)]' %
-                        (frame_size - TestVmdq.ip_dot1q_header_size))
-
-                pcap = os.sep.join([self.output_path, "test1.pcap"])
-                self.tester.scapy_append('wrpcap("%s", flows)' %pcap)
-
-                self.tester.scapy_execute()
-
-                self.tester.scapy_append('dstmac="%s"' % self.destmac_port1)
-                tx_mac = self.tester.get_mac(rx_port)
-                self.tester.scapy_append('srcmac="%s"' % tx_mac)
-                self.tester.scapy_append(
-                        'flows = [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=0)/("X"*%d)]' %
-                        (frame_size - TestVmdq.ip_dot1q_header_size))
-
-                pcap = os.sep.join([self.output_path, "test2.pcap"])
-                self.tester.scapy_append('wrpcap("%s", flows)' % pcap)
-
-                self.tester.scapy_execute()
-
-                self.vlan_repeat = self.queues
-                self.da_repeat = self.queues
-
-                tgen_input = []
-
-                pcap1 = os.sep.join([self.output_path, "test1.pcap"])
-                pcap2 = os.sep.join([self.output_path, "test2.pcap"])
-
-                tgen_input.append((tx_port, rx_port, pcap1))
-                tgen_input.append((rx_port, tx_port, pcap2))
-
+                tgen_input = self.create_throughput_traffic(frame_size)
                 # clear streams before add new streams
                 self.tester.pktgen.clear_streams()
-                vm_config = self.set_fields()
+                vm_config = self.set_fields(self.pools, self.pools)
                 # run packet generator
-                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
-                                                    vm_config, self.tester.pktgen)
+                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100, vm_config, self.tester.pktgen)
                 _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
-
-                config['mpps'][frame_size] = pps/1000000.0
-
-        for n in range(len(self.core_configs)):
-            for size in frame_sizes:
-                self.verify(
-                    self.core_configs[n]['mpps'][size] is not 0, "No traffic detected")
-
+                self.verify(pps > 0, "No traffic detected")
+                config['mpps'][frame_size] = pps / 1000000.0
         # Print results
         self.result_table_create(
             ['Frame size'] + [n['cores'] for n in self.core_configs])
@@ -271,12 +208,31 @@ class TestVmdq(TestCase):
         self.result_table_print()
 
     # Override etgen.dot1q function
-    def set_fields(self):
-        ''' set ip protocol field behavior '''
+    def set_fields(self, vid_range, dmac_range):
+        """
+        set ip protocol field behavior
+        """
         fields_config = {
-        'vlan':  {
-            0: {'range': self.vlan_repeat, 'action': 'inc'}},
-        'mac':  {
-            'dst': {'range': self.da_repeat, 'action': 'inc'}},}
-
+            'vlan': {
+                0: {'range': vid_range, 'action': 'inc'}},
+            'mac': {
+                'dst': {'range': dmac_range, 'action': 'inc'}},
+            'ip': {'src': {'action': 'random'}},
+        }
         return fields_config
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        self.dut.kill_all()
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        # resume setting
+        self.dut.send_expect(
+            "sed -i 's/CONFIG_RTE_MAX_QUEUES_PER_PORT=1024/CONFIG_RTE_MAX_QUEUES_PER_PORT=256/' ./config/common_base",
+            "# ", 5)
+        self.dut.build_install_dpdk(self.target)
-- 
2.17.1


             reply	other threads:[~2020-03-25  5:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  5:08 hanyingya [this message]
2020-03-31  3:05 ` Tu, Lijuan

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=1585112902-137050-1-git-send-email-yingyax.han@intel.com \
    --to=yingyax.han@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).