[dts] [PATCH V1]tests: Add test suite for exception path sample

Lei lei.a.yao at intel.com
Mon Feb 18 10:58:45 CET 2019


From: Lei Yao <lei.a.yao at intel.com>

Add test suite for exception path sample. The first patch will just
include the performance test based on Ixia.

Signed-off-by: Lei Yao <lei.a.yao at intel.com>
---
 tests/TestSuite_exception_path.py | 185 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 185 insertions(+)
 create mode 100644 tests/TestSuite_exception_path.py

diff --git a/tests/TestSuite_exception_path.py b/tests/TestSuite_exception_path.py
new file mode 100644
index 0000000..c1cf5a7
--- /dev/null
+++ b/tests/TestSuite_exception_path.py
@@ -0,0 +1,185 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#   * Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#   * Neither the name of Intel Corporation nor the names of its
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+"""
+DPDK Test suite.
+Test exception path feature.
+"""
+
+import dts
+import time
+import utils
+from test_case import TestCase
+
+
+
+class TestExceptionpath(TestCase):
+
+    def set_up_all(self):
+        """
+        Run at the start of each test suite.
+
+        Exception path prerequisites.
+        """
+
+        out = self.dut.send_expect("which brctl", "# ")
+        self.verify('no brctl' not in out,
+                    "The linux tool brctl is needed to run this test suite")
+        self.verify('error' not in out, "Which brctl: %s" % out)
+
+        self.dut_ports = self.dut.get_ports_performance(self.nic, force_same_socket=False, force_different_nic=False)
+        self.verify(len(self.dut_ports) >= 2, "Not enough ports available")
+        self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
+
+        out = self.dut.build_dpdk_apps('examples/helloworld')
+        self.steps = []  
+        self.steps.append({'cores': '1S/2C/1T', 'ports': 1, 'pps': '', 'bps': ''})
+
+        # If have enough core available
+        if(len(self.dut.get_core_list('1S/4C/1T')) == 4):
+            self.steps.append(
+                {'cores': '1S/4C/1T', 'ports': 2, 'pps': '', 'bps': ''})
+
+    def set_up(self):
+        """
+        Run before each test case.
+        """
+        pass
+
+    def test_perf_exceptionpath_performance(self):
+        """
+        Test the exception path performance.
+        """
+
+        # We create the pcap files to be sent to the DUT from the traffic
+        # generator (the second one is only needed in the last two steps)
+        txPort1 = self.tester.get_local_port(self.dut_ports[0])
+        txPort2 = self.tester.get_local_port(self.dut_ports[1])
+
+        mac1 = self.tester.get_mac(txPort1)
+        mac2 = self.tester.get_mac(txPort2)
+
+        self.tester.scapy_append('dstmac="ff:ff:ff:ff:ff:ff"')
+        self.tester.scapy_append('srcmac="%s"' % mac1)
+        self.tester.scapy_append(
+            'wrpcap("excpath1.pcap", [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=1)/IP(len=46)/UDP()/("X"*14)])')
+        self.tester.scapy_append('dstmac="ff:ff:ff:ff:ff:ff"')
+        self.tester.scapy_append('srcmac="%s"' % mac2)
+        self.tester.scapy_append(
+            'wrpcap("excpath2.pcap", [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=1)/IP(len=46)/UDP()/("X"*14)])')
+        self.tester.scapy_execute()
+        for n in range(len(self.steps)):
+            coreList = self.dut.get_core_list(
+                self.steps[n]['cores'], socket=self.ports_socket)
+            coreMask = utils.create_mask(coreList)
+
+            if(self.steps[n]['ports'] == 1):
+                portMask = utils.create_mask([self.dut_ports[0]])
+                self.dut.send_expect("./examples/exception_path/build/exception_path -n %d -c %s -- -p %s -i %s -o %s &" % (self.dut.get_memory_channels(), coreMask, portMask, utils.create_mask(
+                    [coreList[1]]), utils.create_mask([coreList[0]])), "APP: Lcore [0-9]+ is reading from tap_dpdk_[0-9]+ and writing to port [0-9]+", 120)
+            elif(self.steps[n]['ports'] == 2):
+                portMask = utils.create_mask(
+                    [self.dut_ports[0], self.dut_ports[1]])
+                self.dut.send_expect("./examples/exception_path/build/exception_path -n %d -c %s -- -p %s -i %s -o %s &" % (self.dut.get_memory_channels(), coreMask, portMask, utils.create_mask(
+                    [coreList[1], coreList[3]]), utils.create_mask([coreList[0], coreList[2]])), "APP: Lcore [0-9]+ is reading from tap_dpdk_[0-9]+ and writing to port [0-9]+", 120)
+
+            self.dut.send_expect(
+                "ifconfig tap_dpdk_%02d up" % int(coreList[0]), "# ")
+            self.dut.send_expect(
+                "ifconfig tap_dpdk_%02d up" % int(coreList[1]), "# ")
+            self.dut.send_expect("brctl addbr \"br_dpdk_00\"", "# ")
+            self.dut.send_expect(
+                "brctl addif br_dpdk_00 tap_dpdk_%02d" % int(coreList[0]), "# ")
+            self.dut.send_expect(
+                "brctl addif br_dpdk_00 tap_dpdk_%02d" % int(coreList[1]), "# ")
+            self.dut.send_expect("ifconfig br_dpdk_00 up", "# ")
+
+            tgenInput = []
+            tgenInput.append((txPort1, txPort1, "excpath1.pcap"))
+
+            if(len(coreList) == 4):
+                self.dut.send_expect(
+                    "ifconfig tap_dpdk_%02d up" % int(coreList[2]), "# ")
+                self.dut.send_expect(
+                    "ifconfig tap_dpdk_%02d up" % int(coreList[3]), "# ")
+                self.dut.send_expect("brctl addbr \"br_dpdk_01\"", "# ")
+                self.dut.send_expect(
+                    "brctl addif br_dpdk_01 tap_dpdk_%02d" % int(coreList[2]), "# ")
+                self.dut.send_expect(
+                    "brctl addif br_dpdk_01 tap_dpdk_%02d" % int(coreList[3]), "# ")
+                self.dut.send_expect("ifconfig br_dpdk_01 up", "# ")
+                tgenInput.append((txPort2, txPort2, "excpath2.pcap"))
+
+            time.sleep(5)
+            bps, pps = self.tester.traffic_generator_throughput(tgenInput)
+            self.steps[n]['pps'] = pps / 1E6
+            self.steps[n]['bps'] = bps
+
+            self.dut.send_expect("ifconfig br_dpdk_00 down", "# ")
+            self.dut.send_expect("brctl delbr \"br_dpdk_00\"", "# ")
+
+            if(len(coreList) == 4):
+                self.dut.send_expect("ifconfig br_dpdk_01 down", "# ")
+                self.dut.send_expect("brctl delbr \"br_dpdk_01\"", "# ")
+
+            self.dut.kill_all()
+
+        for n in range(len(self.steps)):
+            self.verify(self.steps[n]['pps'] != 0, "No traffic detected")
+
+        # Print results
+        header = ['Frame Size', 'Ports', 'S/C/T', 'Mpps',
+                  'Mbps', '% linerate']
+        self.result_table_create(header)
+
+        for step in self.steps:
+            self.result_table_add([64, step['ports'], step['cores'],
+                                       step['pps'],
+                                       step['bps'] / 1E6,
+                                       step[
+                                           'pps'] * 100 / float(self.wirespeed(self.nic,
+                                                                               64, 2))]
+                                      )
+
+        self.result_table_print()
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        pass
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        pass
-- 
2.7.4



More information about the dts mailing list