test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen
@ 2019-06-03 16:31 Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 2/7] tests/l3fwd_em: replace etgen with pktgen and fix pep8 issue Haiyang Zhao
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen with pktgen API which support both trex and ixia. 
*.delete old etgen override method ip

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_l3fwd.py | 81 +++++++++++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 26 deletions(-)

diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py
index 78eaee7..7ffdcba 100644
--- a/tests/TestSuite_l3fwd.py
+++ b/tests/TestSuite_l3fwd.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -37,12 +37,13 @@ Layer-3 forwarding test script.
 import utils
 import string
 import re
+import os
 from test_case import TestCase
 from exception import VerifyFailure
 from settings import HEADER_SIZE
-from etgen import IxiaPacketGenerator
+from pktgen import PacketGeneratorHelper
 
-class TestL3fwd(TestCase,IxiaPacketGenerator):
+class TestL3fwd(TestCase):
 
     path = "./examples/l3fwd/build/"
 
@@ -185,7 +186,7 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
         out = self.dut.send_expect("make clean -C examples/l3fwd", "# ")
 
         # Compile l3fwd with hash/exact lookup.
-	self.dut.send_expect(r"sed -i -e '/ipv4_l3fwd_em_route_array\[\].*{/,/^\}\;/c\\%s' examples/l3fwd/l3fwd_em.c" % exactStr, "# ")
+        self.dut.send_expect(r"sed -i -e '/ipv4_l3fwd_em_route_array\[\].*{/,/^\}\;/c\\%s' examples/l3fwd/l3fwd_em.c" % exactStr, "# ")
         out = self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS=-DAPP_LOOKUP_METHOD=0")
 
         self.verify("Error" not in out, "compilation error 1")
@@ -197,6 +198,16 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
         self.l3fwd_test_results = {'header': [],
                                    'data': []}
 
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
+
     def flows(self):
         """
         Return a list of packets that implements the flows described in the
@@ -249,11 +260,26 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
             payload_size = frame_size -  \
                 HEADER_SIZE['ip'] - HEADER_SIZE['eth'] - HEADER_SIZE['tcp']
 
+            pcaps = {}
+            flows = []
             for _port in range(ports_num):
-                dmac = self.dut.get_mac_address(valports[_port])
-                flows = ['Ether(dst="%s")/%s/TCP()/("X"*%d)' % (dmac, flow, payload_size) for flow in self.flows()[_port *2:(_port +1)*2]]
-                self.tester.scapy_append('wrpcap("dst%d.pcap", [%s])' %(valports[_port],string.join(flows,',')))
-            self.tester.scapy_execute()
+                index = valports[_port]
+                dmac = self.dut.get_mac_address(index)
+                cnt = 0
+                for layer in self.flows()[_port *2:(_port +1)*2]:
+                    flow = 'Ether(dst="%s")/%s/TCP()/("X"*%d)' % (
+                                                    dmac, layer, payload_size)
+                    flows.append(flow)
+                    pcap = os.sep.join([
+                                self.output_path,
+                                "dst{0}_{1}.pcap".format(index, cnt)])
+                    self.tester.scapy_append('wrpcap("%s", [%s])' % (
+                                                pcap, flow))
+                    self.tester.scapy_execute()
+                    if index not in pcaps:
+                        pcaps[index] = []
+                    pcaps[index].append(pcap)
+                    cnt += 1
 
             self.rst_report("Flows for %d ports, %d frame size.\n" % (ports_num, frame_size),
                        annex=True)
@@ -330,12 +356,23 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
                                 txIntf = self.tester.get_local_port(valports[rxPort - 1])
 
                             rxIntf = self.tester.get_local_port(valports[rxPort])
-                            if rxPort % 2 == 0:
-                                tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort+1]))
-                            else:
-                                tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort-1]))
+                            port_id = valports[rxPort+1] if rxPort % 2 == 0 else \
+                                      valports[rxPort-1]
+                            for pcap in pcaps[port_id]:
+                                tgenInput.append((txIntf, rxIntf, pcap))
+
+                        # Run traffic generator
+
+                        vm_config = self.set_fields()
+                        # clear streams before add new streams
+                        self.tester.pktgen.clear_streams()
+                        # run packet generator
+                        streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput,
+                                            100, vm_config, self.tester.pktgen)
+                        # set traffic option
+                        traffic_opt = {'duration': 60}
+                        zero_loss_rate, tx_pkts, rx_pkts = self.tester.pktgen.measure_rfc2544(stream_ids=streams, options=traffic_opt)
 
-                        zero_loss_rate, tx_pkts, rx_pkts = self.tester.run_rfc2544(tgenInput, delay=60)
                         loss_pkts = tx_pkts - rx_pkts
                         self.dut.send_expect("^C", "#")
                         linerate = self.wirespeed(self.nic, frame_size, ports_num)
@@ -357,19 +394,11 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
 
         self.result_table_print()
 
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd("ip config -sourceIpAddrMode ipRandom")
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd("ip config -destIpAddrMode ipIdle")
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255")
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {'src': {'action': 'random'},},}
+        return fields_config
 
     def tear_down(self):
         """
-- 
2.17.1


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

* [dts] [next][PATCH V2 2/7] tests/l3fwd_em: replace etgen with pktgen and fix pep8 issue
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
@ 2019-06-03 16:31 ` Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 3/7] tests/link_flowctrl: replace etgen with pktgen Haiyang Zhao
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen with pktgen API which support both trex and ixia.
*.delete old etgen override method ip

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_l3fwd_em.py | 83 +++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 41 deletions(-)

diff --git a/tests/TestSuite_l3fwd_em.py b/tests/TestSuite_l3fwd_em.py
index c8f0b18..ee50fcc 100644
--- a/tests/TestSuite_l3fwd_em.py
+++ b/tests/TestSuite_l3fwd_em.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -34,16 +34,18 @@ DPDK Test suite.
 Layer-3 forwarding exact-match test script.
 """
 
+import os
 import utils
 import string
 import re
 from test_case import TestCase
 from exception import VerifyFailure
 from settings import HEADER_SIZE
-from etgen import IxiaPacketGenerator
 from utils import *
+from pktgen import PacketGeneratorHelper
 
-class TestL3fwdEM(TestCase,IxiaPacketGenerator):
+
+class TestL3fwdEM(TestCase):
 
     path = "./examples/l3fwd/build/"
 
@@ -52,8 +54,7 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
                           "1S/4C/1T": "%s -c %s -n %d -- -p %s -E --config '(P0,0,C{1.1.0}), (P1,0,C{1.2.0}),(P0,1,C{1.3.0}), (P1,1,C{1.4.0})' --hash-entry-num 0x400000"
                           }
 
-
-    frame_sizes = [64, 65, 128, 256, 512, 1518]  # 65, 128
+    frame_sizes = [64, 65, 128, 256, 512, 1518]
     methods = ['exact']
 
     #
@@ -99,7 +100,6 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
         
         self.port_socket = netdev.socket
         
-
         # Verify that enough threads are available
         cores = self.dut.get_core_list("1S/8C/2T")
         self.verify(cores is not None, "Insufficient cores for speed testing")
@@ -116,16 +116,21 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
         self.dut.send_expect("sed -i -e 's/CONFIG_RTE_PCI_EXTENDED_TAG=.*$/CONFIG_RTE_PCI_EXTENDED_TAG=\"on\"/' ./config/common_linuxapp", "#", 20)
         self.dut.build_install_dpdk(self.target)
 
-
-        
         out = self.dut.build_dpdk_apps("./examples/l3fwd")
         self.verify("Error" not in out, "compilation error 1")
         self.verify("No such file" not in out, "compilation error 2")
 
-
         self.l3fwd_test_results = {'header': [],
                                    'data': []}
-
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
 
     def repl(self, match):
         pid = match.group(1)
@@ -142,14 +147,12 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
 
         return '%s,%s,%s' % (str(valports[int(pid)]), qid, lcid)
 
-
     def set_up(self):
         """
         Run before each test case.
         """
         pass
 
-
     def test_perf_l3fwd_2ports(self):
         """
         L3fwd main 2 ports.
@@ -169,15 +172,20 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
             # Traffic for port0
             dmac_port0 = self.dut.get_mac_address(valports[0])
             flow1 = '[Ether(dst="%s")/IP(src="200.20.0.1",dst="201.0.0.0")/TCP(sport=12,dport=102)/("X"*%d)]' %(dmac_port0,payload_size)
-            self.tester.scapy_append('wrpcap("dst0.pcap",%s)' %flow1)
+
+            pcaps = {}
+            pcap = os.sep.join([self.output_path, "dst0.pcap"])
+            pcaps[0] = pcap
+            self.tester.scapy_append('wrpcap("{0}",{1})'.format(pcap, flow1))
 
             # Traffic for port1
             dmac_port1 = self.dut.get_mac_address(valports[1])
             flow2 = '[Ether(dst="%s")/IP(src="100.10.0.1",dst="101.0.0.0")/TCP(sport=11,dport=101)/("X"*%d)]' %(dmac_port1,payload_size)
-            self.tester.scapy_append('wrpcap("dst1.pcap",%s)' %flow2)
-            self.tester.scapy_execute()
-
 
+            pcap = os.sep.join([self.output_path, "dst1.pcap"])
+            pcaps[1] = pcap
+            self.tester.scapy_append('wrpcap("{0}",{1})'.format(pcap, flow2))
+            self.tester.scapy_execute()
 
             # Prepare the command line
             global corelist
@@ -192,7 +200,7 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
                 corelist = []
                 while pat.search(rtCmdLines[key]):
                     # Change the socket to the NIC's socket
-                    if key.find('1S')>=0:
+                    if key.find('1S') >= 0:
                         rtCmdLines[key] = pat2.sub(repl1, rtCmdLines[key])
                     rtCmdLines[key] = pat.sub(self.repl, rtCmdLines[key])
 
@@ -220,11 +228,7 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
                     self.rst_report(cmdline + "\n", frame=True, annex=True)
 
                     out = self.dut.send_expect(cmdline, "L3FWD: entering main loop", 120)
-            
-                    
-                    print self.dut.get_session_output(timeout=3)           
                     
-
                     # Measure test
                     tgenInput = []
                     for rxPort in range(2):
@@ -235,18 +239,22 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
                             txIntf = self.tester.get_local_port(valports[rxPort - 1])
 
                         rxIntf = self.tester.get_local_port(valports[rxPort])
-                        if rxPort % 2 == 0: 
-                            tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort+1]))
-                        else: 
-                            tgenInput.append((txIntf, rxIntf, "dst%d.pcap" %valports[rxPort-1]))
+                        port_index = valports[rxPort+1] if rxPort % 2 == 0 else valports[rxPort-1]
+                        tgenInput.append((txIntf, rxIntf, pcaps[port_index]))
                     
-                    _, pps = self.tester.traffic_generator_throughput(tgenInput,delay=20)
+                    vm_config = self.set_fields()
+                    # clear streams before add new streams
+                    self.tester.pktgen.clear_streams()
+                    # run packet generator
+                    streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100,
+                                            vm_config, self.tester.pktgen)
+                    traffic_opt = {'duration': 20, }
+                    _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)
                     
                     self.verify(pps > 0, "No traffic detected")
                     pps /= 1000000.0
                     linerate = self.wirespeed(self.nic, frame_size, 2)
                     pct = pps * 100 / linerate
-
                     index += 1
 
                     # Stop l3fwd
@@ -257,21 +265,14 @@ class TestL3fwdEM(TestCase,IxiaPacketGenerator):
 
         self.result_table_print()
 
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {
+            'dst': {'range': 64, 'mask': '255.240.0.0', 'action': 'inc'}
+        },}
 
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolTcp")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd("ip config -sourceIpAddrMode ipIdle")
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd("ip config -destIpAddrMode ipContIncrHost")
-        self.add_tcl_cmd("ip config -destIpMask '255.240.0.0'")
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
+        return fields_config
 
     def tear_down(self):
         """
-- 
2.17.1


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

* [dts] [next][PATCH V2 3/7] tests/link_flowctrl: replace etgen with pktgen
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 2/7] tests/l3fwd_em: replace etgen with pktgen and fix pep8 issue Haiyang Zhao
@ 2019-06-03 16:31 ` Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 4/7] tests/multiprocess:replace " Haiyang Zhao
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen with pktgen API which support both trex and ixia. 
*.replace print to logger.info to record the necessary debug information.

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_link_flowctrl.py | 52 +++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 17 deletions(-)

diff --git a/tests/TestSuite_link_flowctrl.py b/tests/TestSuite_link_flowctrl.py
index 0057b46..0192498 100644
--- a/tests/TestSuite_link_flowctrl.py
+++ b/tests/TestSuite_link_flowctrl.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -36,11 +36,13 @@ Test for Ethernet Link Flow Control Features by Poll Mode Drivers
 
 import utils
 import re
+import os
 
 from time import sleep
 from test_case import TestCase
 from pmd_output import PmdOutput
 from settings import HEADER_SIZE
+from pktgen import PacketGeneratorHelper
 
 
 class TestLinkFlowctrl(TestCase):
@@ -77,6 +79,15 @@ class TestLinkFlowctrl(TestCase):
 
         self.pmdout = PmdOutput(self.dut)
         self.pmdout.start_testpmd("all", "--portmask=%s" % self.portMask)
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
 
     def pause_frame_loss_test(self, rx_flow_control='off',
                               tx_flow_control='off',
@@ -86,7 +97,9 @@ class TestLinkFlowctrl(TestCase):
         tester_rx_port = self.tester.get_local_port(self.tx_port)
 
         tgenInput = []
-        tgenInput.append((tester_tx_port, tester_rx_port, "test.pcap"))
+        pcap = os.sep.join([self.output_path, "test.pcap"])
+
+        tgenInput.append((tester_tx_port, tester_rx_port, pcap))
 
         self.dut.send_expect("set flow_ctrl rx %s tx %s 300 50 10 1 mac_ctrl_frame_fwd %s autoneg on %d " % (
                              rx_flow_control,
@@ -96,18 +109,23 @@ class TestLinkFlowctrl(TestCase):
                              "testpmd> ")
 
         self.dut.send_expect("set fwd csum", "testpmd> ")
-        self.dut.send_expect("start", "testpmd> ")
-
-        self.tester.scapy_append('wrpcap("test.pcap",[Ether()/IP()/UDP()/("X"*%d)])' %
-                                 TestLinkFlowctrl.payload_size)
+        self.dut.send_expect("start", "testpmd> ", 60)
+        pcap = os.sep.join([self.output_path, "test.pcap"])
+        self.tester.scapy_append('wrpcap("%s",[Ether()/IP()/UDP()/("X"*%d)])' %
+                                 (pcap,TestLinkFlowctrl.payload_size))
 
         self.tester.scapy_execute()
 
-        # Run traffic generator
-        result = self.tester.traffic_generator_loss(tgenInput, 100)
+        # clear streams before add new streams
+        self.tester.pktgen.clear_streams()
+        # run packet generator
+        streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100,
+                                            None, self.tester.pktgen)
+        result = self.tester.pktgen.measure_loss(stream_ids=streams)
+
         self.dut.send_expect("stop", "testpmd> ")
 
-        return result
+        return result[0]/100
 
     def get_testpmd_port_stats(self, ports):
         """
@@ -184,9 +202,9 @@ class TestLinkFlowctrl(TestCase):
             Verifies the test results (use pause_frame_test before) against
             the expected behavior.
         """
-        print "Result (port, rx, tx) %s,  expected rx %s, expected fwd %s" % (result,
+        self.logger.info("Result (port, rx, tx) %s,  expected rx %s, expected fwd %s" % (result,
                                                                               expected_rx,
-                                                                              expected_fwd)
+                                                                              expected_fwd))
 
         if expected_rx:
             self.verify(result[self.rx_port][0] == TestLinkFlowctrl.frames_to_sent,
@@ -339,7 +357,7 @@ class TestLinkFlowctrl(TestCase):
                                             tx_flow_control='on',
                                             pause_frame_fwd='on')
 
-        print "Packet loss: %.3f%%" % result
+        self.logger.info("Packet loss: %.3f%%" % result)
 
         self.verify(result <= 0.01,
                     "Link flow control fail, the loss percent is more than 1%")
@@ -353,7 +371,7 @@ class TestLinkFlowctrl(TestCase):
                                             tx_flow_control='on',
                                             pause_frame_fwd='off')
 
-        print "Packet loss: %.3f%%" % result
+        self.logger.info("Packet loss: %.3f%%" % result)
 
         self.verify(result <= 0.01,
                     "Link flow control fail, the loss percent is more than 1%")
@@ -367,7 +385,7 @@ class TestLinkFlowctrl(TestCase):
                                             tx_flow_control='on',
                                             pause_frame_fwd='off')
 
-        print "Packet loss: %.3f%%" % result
+        self.logger.info("Packet loss: %.3f%%" % result)
 
         self.verify(result <= 0.01,
                     "Link flow control fail, the loss percent is more than 1%")
@@ -381,7 +399,7 @@ class TestLinkFlowctrl(TestCase):
                                             tx_flow_control='off',
                                             pause_frame_fwd='on')
 
-        print "Packet loss: %.3f%%" % result
+        self.logger.info("Packet loss: %.3f%%" % result)
 
         self.verify(result >= 0.5,
                     "Link flow control fail, the loss percent is less than 50%")
@@ -395,7 +413,7 @@ class TestLinkFlowctrl(TestCase):
                                             tx_flow_control='off',
                                             pause_frame_fwd='off')
 
-        print "Packet loss: %.3f%%" % result
+        self.logger.info("Packet loss: %.3f%%" % result)
 
         self.verify(result >= 0.5,
                     "Link flow control fail, the loss percent is less than 50%")
@@ -409,7 +427,7 @@ class TestLinkFlowctrl(TestCase):
                                             tx_flow_control='on',
                                             pause_frame_fwd='off')
 
-        print "Packet loss: %.3f%%" % result
+        self.logger.info("Packet loss: %.3f%%" % result)
 
         self.verify(result <= 0.01,
                     "Link flow control fail, the loss percent is more than 1%")
-- 
2.17.1


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

* [dts] [next][PATCH V2 4/7] tests/multiprocess:replace etgen with pktgen
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 2/7] tests/l3fwd_em: replace etgen with pktgen and fix pep8 issue Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 3/7] tests/link_flowctrl: replace etgen with pktgen Haiyang Zhao
@ 2019-06-03 16:31 ` Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 5/7] tests/pmd:replace " Haiyang Zhao
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen with pktgen API which support both trex and ixia. 
*.delete old etgen override method ip. 
*.add function set_fields. 
*.delete judgement of want_perf_tests.

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_multiprocess.py | 62 +++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py
index 1bac35c..a22266a 100644
--- a/tests/TestSuite_multiprocess.py
+++ b/tests/TestSuite_multiprocess.py
@@ -36,12 +36,13 @@ Multi-process Test.
 
 import utils
 import time
-from etgen import IxiaPacketGenerator
+import os
 executions = []
 from test_case import TestCase
+from pktgen import PacketGeneratorHelper
 
 
-class TestMultiprocess(TestCase, IxiaPacketGenerator):
+class TestMultiprocess(TestCase):
 
     def set_up_all(self):
         """
@@ -53,7 +54,7 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
             DUT core number >= 4
             multi_process build pass
         """
-        #self.verify('bsdapp' not in self.target, "Multiprocess not support freebsd")
+        # self.verify('bsdapp' not in self.target, "Multiprocess not support freebsd")
 
         self.verify(len(self.dut.get_all_cores()) >= 4, "Not enough Cores")
         self.tester.extend_external_packet_generator(TestMultiprocess, self)
@@ -69,8 +70,17 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
         executions.append({'nprocs': 8, 'cores': '1S/4C/2T', 'pps': 0})
         self.dut.alt_session.send_expect("cd dpdk","# ",5)
 
-       # start new session to run secondary
+        # start new session to run secondary
         self.session_secondary = self.dut.new_session()
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
 
     def set_up(self):
         """
@@ -201,11 +211,10 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
 
         self.tester.scapy_append('dmac="%s"' % self.dut.get_mac_address(dutPorts[0]))
         self.tester.scapy_append('smac="%s"' % mac)
-        if not self.dut.want_perf_tests:
-            self.tester.scapy_append('flows = [Ether(src=smac, dst=dmac)/IP(src="192.168.1.%s" % src, dst="192.168.1.%s" % dst)/("X"*26) for src in range(64) for dst in range(64)]')
-        else:
-            self.tester.scapy_append('flows = [Ether(src=smac, dst=dmac)/IP(src="192.168.1.1", dst="192.168.1.1")/("X"*26)]')
-        self.tester.scapy_append('wrpcap("test.pcap", flows)')
+        self.tester.scapy_append('flows = [Ether(src=smac, dst=dmac)/IP(src="192.168.1.1", dst="192.168.1.1")/("X"*26)]')
+
+        pcap = os.sep.join([self.output_path, "test.pcap"])
+        self.tester.scapy_append('wrpcap("%s", flows)' % pcap)
         self.tester.scapy_execute()
 
         validExecutions = []
@@ -230,8 +239,15 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
                 self.dut.send_expect("bg", "# ")
 
             tgenInput = []
-            tgenInput.append([txPort, rxPort, "test.pcap"])
-            _, pps = self.tester.traffic_generator_throughput(tgenInput)
+            tgenInput.append([txPort, rxPort, pcap])
+
+            # clear streams before add new streams
+            self.tester.pktgen.clear_streams()
+            # run packet generator
+            streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100,
+                                                None, self.tester.pktgen)
+            _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
+
             execution['pps'] = pps
             self.dut.kill_all()
             time.sleep(5)
@@ -246,21 +262,15 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
 
         self.result_table_print()
 
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd('ip config -sourceIpAddrMode ipIncrHost')
-        self.add_tcl_cmd('ip config -sourceIpAddrRepeatCount %d' % 64)
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd('ip config -destIpAddrMode ipIncrHost')
-        self.add_tcl_cmd('ip config -destIpAddrRepeatCount %d' % 64)
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -ipProtocol %d" % proto)
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {
+            'src': {'range': 64, 'action': 'inc'},
+            'dst': {'range': 64, 'action': 'inc'},
+        },}
+
+        return fields_config
 
     def tear_down(self):
         """
-- 
2.17.1


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

* [dts] [next][PATCH V2 5/7] tests/pmd:replace etgen with pktgen
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
                   ` (2 preceding siblings ...)
  2019-06-03 16:31 ` [dts] [next][PATCH V2 4/7] tests/multiprocess:replace " Haiyang Zhao
@ 2019-06-03 16:31 ` Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 6/7] tests/tso:replace etgen with pktgen and fix pep8 issue Haiyang Zhao
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen to pktgen API which support both trex and ixia. 
*.delete old etgen override method ip. 
*.add function set_fields.

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_pmd.py | 82 ++++++++++++++++++++++++------------------
 1 file changed, 48 insertions(+), 34 deletions(-)

diff --git a/tests/TestSuite_pmd.py b/tests/TestSuite_pmd.py
index f5df8d5..5ff4d29 100644
--- a/tests/TestSuite_pmd.py
+++ b/tests/TestSuite_pmd.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -43,15 +43,14 @@ from test_case import TestCase
 from time import sleep
 from settings import HEADER_SIZE
 from pmd_output import PmdOutput
-from etgen import IxiaPacketGenerator
 
 from settings import FOLDERS
 from system_info import SystemInfo
 import perf_report
 from datetime import datetime
+from pktgen import PacketGeneratorHelper
 
-
-class TestPmd(TestCase,IxiaPacketGenerator):
+class TestPmd(TestCase):
 
     def set_up_all(self):
         """
@@ -104,6 +103,16 @@ class TestPmd(TestCase,IxiaPacketGenerator):
 
         self.pmdout = PmdOutput(self.dut)
 
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
+
     def set_up(self):
         """
         Run before each test case.
@@ -151,22 +160,21 @@ class TestPmd(TestCase,IxiaPacketGenerator):
         PMD Performance Benchmarking with 4 ports.
         """
         all_cores_mask = utils.create_mask(self.dut.get_core_list("all"))
-
         # prepare traffic generator input
         tgen_input = []
-
+        pcap = os.sep.join([self.output_path, "test.pcap"])
         tgen_input.append((self.tester.get_local_port(self.dut_ports[0]),
                            self.tester.get_local_port(self.dut_ports[1]),
-                           "test.pcap"))
+                           pcap))
         tgen_input.append((self.tester.get_local_port(self.dut_ports[2]),
                            self.tester.get_local_port(self.dut_ports[3]),
-                           "test.pcap"))
+                           pcap))
         tgen_input.append((self.tester.get_local_port(self.dut_ports[1]),
                            self.tester.get_local_port(self.dut_ports[0]),
-                           "test.pcap"))
+                           pcap))
         tgen_input.append((self.tester.get_local_port(self.dut_ports[3]),
                            self.tester.get_local_port(self.dut_ports[2]),
-                           "test.pcap"))
+                           pcap))
 
         # run testpmd for each core config
         for test_cycle in self.test_cycles:
@@ -184,7 +192,7 @@ class TestPmd(TestCase,IxiaPacketGenerator):
             port_mask = utils.create_mask(self.dut.get_ports())
 
             self.pmdout.start_testpmd(core_config, " --rxq=%d --txq=%d --portmask=%s --rss-ip --txrst=32 --txfreet=32 --txd=128 --tx-offloads=0" % (queues, queues, port_mask), socket=self.ports_socket)
-	    command_line = self.pmdout.get_pmd_cmd()
+            command_line = self.pmdout.get_pmd_cmd()
 
             info = "Executing PMD using %s\n" % test_cycle['cores']
             self.rst_report(info, annex=True)
@@ -200,11 +208,17 @@ class TestPmd(TestCase,IxiaPacketGenerator):
                 self.logger.info("Running with frame size %d " % frame_size)
                 payload_size = frame_size - self.headers_size
                 self.tester.scapy_append(
-                    'wrpcap("test.pcap", [Ether(src="52:00:00:00:00:00")/IP(src="1.2.3.4",dst="1.1.1.1")/TCP()/("X"*%d)])' % payload_size)
+                    'wrpcap("%s", [Ether(src="52:00:00:00:00:00")/IP(src="1.2.3.4",dst="1.1.1.1")/TCP()/("X"*%d)])' % (pcap, payload_size))
                 self.tester.scapy_execute()
 
-                # run traffic generator
-                _, pps = self.tester.traffic_generator_throughput(tgen_input, rate_percent=100, delay=60)
+                vm_config = self.set_fields()
+                # clear streams before add new streams
+                self.tester.pktgen.clear_streams()
+                # run packet generator
+                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                        vm_config, self.tester.pktgen)
+                traffic_opt = {'duration': 60, }
+                _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)
 
                 pps /= 1000000.0
                 pct = pps * 100 / wirespeed
@@ -244,12 +258,13 @@ class TestPmd(TestCase,IxiaPacketGenerator):
 
         # prepare traffic generator input
         tgen_input = []
+        pcap = os.sep.join([self.output_path, "test.pcap"])
         tgen_input.append((self.tester.get_local_port(self.dut_ports[0]),
                            self.tester.get_local_port(self.dut_ports[1]),
-                           "test.pcap"))
+                           pcap))
         tgen_input.append((self.tester.get_local_port(self.dut_ports[1]),
                            self.tester.get_local_port(self.dut_ports[0]),
-                           "test.pcap"))
+                           pcap))
 
         # run testpmd for each core config
         for test_cycle in self.test_cycles:
@@ -284,11 +299,19 @@ class TestPmd(TestCase,IxiaPacketGenerator):
                 self.logger.info("Running with frame size %d " % frame_size)
                 payload_size = frame_size - self.headers_size
                 self.tester.scapy_append(
-                    'wrpcap("test.pcap", [Ether(src="52:00:00:00:00:00")/IP(src="1.2.3.4",dst="1.1.1.1")/TCP()/("X"*%d)])' % payload_size)
+                    'wrpcap("%s", [Ether(src="52:00:00:00:00:00")/IP(src="1.2.3.4",dst="1.1.1.1")/TCP()/("X"*%d)])' % (pcap, payload_size))
                 self.tester.scapy_execute()
 
                 # run traffic generator
-                _, pps = self.tester.traffic_generator_throughput(tgen_input, rate_percent=100, delay=60)
+
+                vm_config = self.set_fields()
+                # clear streams before add new streams
+                self.tester.pktgen.clear_streams()
+                # run packet generator
+                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                        vm_config, self.tester.pktgen)
+                traffic_opt = {'duration': 60, }
+                _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)
 
                 pps /= 1000000.0
                 pct = pps * 100 / wirespeed
@@ -436,22 +459,13 @@ class TestPmd(TestCase,IxiaPacketGenerator):
                     "packet pass assert error, expected %d TX bytes, actual %d" % (frame_size - 4, p0tx_bytes))
 
         return out
-    
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version, flags, ihl, ttl, id):
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd("ip config -sourceIpAddrMode ipRandom")
-        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
-        self.add_tcl_cmd("ip config -destIpAddrMode ipIdle")
-        self.add_tcl_cmd("ip config -ttl %d" % ttl)
-        self.add_tcl_cmd("ip config -totalLength %d" % len)
-        self.add_tcl_cmd("ip config -fragment %d" % frag)
-        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255")
-        self.add_tcl_cmd("ip config -identifier %d" % id)
-        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
-        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'], port['port']))
-
-    
+
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'ip':  {'src': {'action': 'random'},},}
+        return fields_config
+
     def tear_down(self):
         """
         Run after each test case.
-- 
2.17.1


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

* [dts] [next][PATCH V2 6/7] tests/tso:replace etgen with pktgen and fix pep8 issue
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
                   ` (3 preceding siblings ...)
  2019-06-03 16:31 ` [dts] [next][PATCH V2 5/7] tests/pmd:replace " Haiyang Zhao
@ 2019-06-03 16:31 ` Haiyang Zhao
  2019-06-03 16:31 ` [dts] [next][PATCH V2 7/7] tests/vmdq:replace etgen with pktgen Haiyang Zhao
  2019-06-05  1:40 ` [dts] [next][PATCH V2 1/7] tests/l3fwd: replace " Tu, Lijuan
  6 siblings, 0 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen with pktgen API which support both trex and ixia. 
*.delete unnecessary print. 
*.revise C style to pythonic.

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_tso.py | 48 ++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py
index 8dc84c2..ba0b45c 100644
--- a/tests/TestSuite_tso.py
+++ b/tests/TestSuite_tso.py
@@ -40,8 +40,10 @@ Tests for TSO.
 import utils
 import time
 import re
+import os
 from test_case import TestCase
 from settings import HEADER_SIZE
+from pktgen import PacketGeneratorHelper
 
 
 class TestTSO(TestCase):
@@ -91,6 +93,15 @@ class TestTSO(TestCase):
 
         self.headers_size = HEADER_SIZE['eth'] + HEADER_SIZE[
             'ip'] + HEADER_SIZE['tcp']
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
 
     def set_up(self):
         """
@@ -126,7 +137,6 @@ class TestTSO(TestCase):
         """
 
         result = self.tester.send_expect(command, '#')
-        print result
         return int(result.strip())
 
     def number_of_packets(self, iface):
@@ -187,10 +197,9 @@ class TestTSO(TestCase):
         self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, padding, tx_interface))
         out = self.tester.scapy_execute()
         out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
         self.tcpdump_stop_sniff()
         rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
+        if rx_stats == 2:
             self.verify(1, "Pass")
 
         # IPv6 tcp test
@@ -199,10 +208,9 @@ class TestTSO(TestCase):
         self.tester.scapy_append('sendp([Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, padding, tx_interface))
         out = self.tester.scapy_execute()
         out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
         self.tcpdump_stop_sniff()
         rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
+        if rx_stats == 2:
             self.verify(1, "Pass")
 
     def test_tso_tunneling(self):
@@ -252,10 +260,9 @@ class TestTSO(TestCase):
         self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/UDP(sport="1021",dport="4789")/VXLAN()/Ether(dst=%s,src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport="1021",dport="1021")/("X"*%s)], iface="%s")' % (mac, mac, padding, tx_interface))
         out = self.tester.scapy_execute()
         out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
         self.tcpdump_stop_sniff()
         rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
+        if rx_stats == 2:
             self.verify(1, "Pass")
 
         # Nvgre test
@@ -263,10 +270,9 @@ class TestTSO(TestCase):
         self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2",proto=47)/NVGRE()/Ether(dst=%s,src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport="1021",dport="1021")/("X"*%s)], iface="%s")' % (mac, mac, padding, tx_interface))
         out = self.tester.scapy_execute()
         out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
         self.tcpdump_stop_sniff()
         rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
+        if rx_stats == 2:
             self.verify(1, "Pass")
 
     def test_perf_TSO_2ports(self):
@@ -287,8 +293,8 @@ class TestTSO(TestCase):
             else:
                 queues = 1
 
-            command_line = "./%s/app/testpmd -c %s -n %d %s -- -i --coremask=%s --rxd=512 --txd=512 --burst=32 --rxfreet=64 --mbcache=128 --portmask=%s --txpt=36 --txht=0 --txwt=0 --txfreet=32 --txrst=32 " % (self.target, self.all_cores_mask, self.dut.get_memory_channels(), self.blacklist, self.coreMask, self.portMask)
-
+            #command_line = "./%s/app/testpmd -c %s -n %d %s -- -i --coremask=%s --rxd=512 --txd=512 --burst=32 --rxfreet=64 --mbcache=128 --portmask=%s --txpt=36 --txht=0 --txwt=0 --txfreet=32 --txrst=32 " % (self.target, self.all_cores_mask, self.dut.get_memory_channels(), self.blacklist, self.coreMask, self.portMask)
+            command_line = "./%s/app/testpmd -c %s -n %d %s -- -i --rxd=512 --txd=512 --burst=32 --rxfreet=64 --mbcache=128 --portmask=%s --txpt=36 --txht=0 --txwt=0 --txfreet=32 --txrst=32 " % (self.target, self.coreMask, self.dut.get_memory_channels(), self.blacklist, self.portMask)
             info = "Executing PMD using %s\n" % test_cycle['cores']
             self.logger.info(info)
             self.rst_report(info, annex=True)
@@ -316,15 +322,21 @@ class TestTSO(TestCase):
                 # create pcap file
                 self.logger.info("Running with frame size %d " % frame_size)
                 payload_size = frame_size - self.headers_size
-		for _port in range(2):
-			mac = self.dut.get_mac_address(self.dut_ports[_port])
-                	self.tester.scapy_append('wrpcap("dst%d.pcap", [Ether(dst="%s",src="52:00:00:00:00:01")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%d)])' % (_port, mac, payload_size))
-        		tgen_input.append((self.tester.get_local_port(self.dut_ports[_port]),
-                           self.tester.get_local_port(self.dut_ports[1-_port]), "dst%d.pcap") % _port)
+                for _port in range(2):
+                    mac = self.dut.get_mac_address(self.dut_ports[_port])
+
+                    pcap = os.sep.join([self.output_path, "dts{0}.pcap".format(_port)])
+                    self.tester.scapy_append('wrpcap("%s", [Ether(dst="%s",src="52:00:00:00:00:01")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%d)])' % (pcap, mac, payload_size))
+                    tgen_input.append((self.tester.get_local_port(self.dut_ports[_port]),
+                    self.tester.get_local_port(self.dut_ports[1-_port]), "%s" % pcap))
                 self.tester.scapy_execute()
 
-                # run traffic generator
-                _, pps = self.tester.traffic_generator_throughput(tgen_input)
+                # clear streams before add new streams
+                self.tester.pktgen.clear_streams()
+                # run packet generator
+                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                                    None, self.tester.pktgen)
+                _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams)
 
                 pps /= 1000000.0
                 test_cycle['Mpps'][frame_size] = pps
-- 
2.17.1


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

* [dts] [next][PATCH V2 7/7] tests/vmdq:replace etgen with pktgen
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
                   ` (4 preceding siblings ...)
  2019-06-03 16:31 ` [dts] [next][PATCH V2 6/7] tests/tso:replace etgen with pktgen and fix pep8 issue Haiyang Zhao
@ 2019-06-03 16:31 ` Haiyang Zhao
  2019-06-05  1:40 ` [dts] [next][PATCH V2 1/7] tests/l3fwd: replace " Tu, Lijuan
  6 siblings, 0 replies; 8+ messages in thread
From: Haiyang Zhao @ 2019-06-03 16:31 UTC (permalink / raw)
  To: dts; +Cc: Haiyang Zhao

*.replace etgen with pktgen API which support both trex and ixia. 
*.delete old etgen override method dot1q, ether. 
*.add function set_fields. 
*.replace print to logger.info to record the necessary debug information 
*.delete unnecessary print.

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 tests/TestSuite_vmdq.py | 102 +++++++++++++++++++++++-----------------
 1 file changed, 60 insertions(+), 42 deletions(-)

diff --git a/tests/TestSuite_vmdq.py b/tests/TestSuite_vmdq.py
index 796a214..bb5aaf4 100644
--- a/tests/TestSuite_vmdq.py
+++ b/tests/TestSuite_vmdq.py
@@ -7,13 +7,13 @@ Tests for vmdq.
 
 """
 import utils
+import os
 import re
-from etgen import IxiaPacketGenerator
 from test_case import TestCase
 from time import sleep
+from pktgen import PacketGeneratorHelper
 
-
-class TestVmdq(TestCase, IxiaPacketGenerator):
+class TestVmdq(TestCase):
     dut_ports = []
     ip_dot1q_header_size = 22
     default_framesize = 64
@@ -38,7 +38,6 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
         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)
-        print self.dut_ports
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
 
         self.core_configs = []
@@ -50,6 +49,15 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
         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")
+        # get dts output path
+        if self.logger.log_path.startswith(os.sep):
+            self.output_path = self.logger.log_path
+        else:
+            cur_path = os.path.dirname(
+                                os.path.dirname(os.path.realpath(__file__)))
+            self.output_path = os.sep.join([cur_path, self.logger.log_path])
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
 
     def validateApproxEqual(self, lines):
         """
@@ -97,7 +105,7 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
         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 = []
@@ -106,15 +114,22 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
             self.tester.scapy_append('smac="%s"' % tx_mac)
             self.tester.scapy_append(
                 'flows = [Ether(src=smac, dst=dmac)/Dot1Q(vlan=0,prio=%d)]'%p)
-            self.tester.scapy_append('wrpcap("test%d.pcap", flows)' %p)
+
+            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, "test%d.pcap" %p))
+            tgen_input.append((tx_port, rx_port, "%s" %pcap))
 
-        loss, _, _ = self.tester.traffic_generator_loss(tgen_input, 10)
-        print "loss is %s !" % loss
+        self.tester.pktgen.clear_streams()
+        # run packet generator
+        streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                                        None, self.tester.pktgen)
+        loss = self.tester.pktgen.measure_loss(stream_ids=streams)
+        self.logger.info("loss is {}!".format(loss))
 
         # Verify the accurate
-        self.verify(loss < 0.001, "Excessive packet loss")
+        self.verify(loss[0]/100 < 0.001, "Excessive packet loss")
         self.validateApproxEqual(out.split("\r\n"))
 
     def set_up(self):
@@ -147,7 +162,7 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
         frame_sizes = [64, 128, 256, 512, 1024, 1280, 1518]
         for config in self.core_configs:
 
-            print utils.BLUE(config["cores"])
+            self.logger.info(config["cores"])
             self.dut.kill_all()
 
             core_config = config['cores']
@@ -178,14 +193,12 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
             tx_port = self.tester.get_local_port(self.dut_ports[0])
             rx_port = self.tester.get_local_port(self.dut_ports[1])
 
-            print utils.GREEN("Waiting for application to initialize")
+            self.logger.info("Waiting for application to initialize")
             sleep(5)
 
             for frame_size in frame_sizes:
-
                 TestVmdq.current_frame_size = frame_size
-
-                print utils.BLUE(str(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)
@@ -193,7 +206,10 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
                 self.tester.scapy_append(
                         'flows = [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=0)/("X"*%d)]' %
                         (frame_size - TestVmdq.ip_dot1q_header_size))
-                self.tester.scapy_append('wrpcap("test1.pcap", flows)')
+
+                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)
@@ -202,16 +218,30 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
                 self.tester.scapy_append(
                         'flows = [Ether(src=srcmac,dst=dstmac)/Dot1Q(vlan=0)/("X"*%d)]' %
                         (frame_size - TestVmdq.ip_dot1q_header_size))
-                self.tester.scapy_append('wrpcap("test2.pcap", flows)')
+
+                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 = []
-                tgen_input.append((tx_port, rx_port, "test1.pcap"))
-                tgen_input.append((rx_port, tx_port, "test2.pcap"))
-                _, pps = self.tester.traffic_generator_throughput(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))
+
+                # clear streams before add new streams
+                self.tester.pktgen.clear_streams()
+                # run packet generator
+                streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                                    None, 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)):
@@ -230,24 +260,12 @@ class TestVmdq(TestCase, IxiaPacketGenerator):
         self.result_table_print()
 
     # Override etgen.dot1q function
-    def dot1q(self, port, prio, id, vlan, type):
-        """
-        Change Ixia configuration
-        """
-        self.add_tcl_cmd("vlan config -mode vIncrement")
-        self.add_tcl_cmd("vlan config -step 1")
-        self.add_tcl_cmd("vlan config -repeat %d" % self.vlan_repeat)
-        self.add_tcl_cmd("stream config -framesize %d" %
-                         TestVmdq.current_frame_size)
-        super(TestVmdq, self).dot1q(port, prio, id, vlan, type)
-
-    def ether(self, port, src, dst, type):
-        """
-        Configure Ether protocol.
-        """
-        self.add_tcl_cmd("protocol config -ethernetType ethernetII")
-        self.add_tcl_cmd('stream config -sa "%s"' % self.macToTclFormat(src))
-        self.add_tcl_cmd('stream config -da "%s"' % self.macToTclFormat(dst))
-        self.add_tcl_cmd('stream config -daRepeatCounter increment')
-        self.add_tcl_cmd('stream config -daStep 1')
-        self.add_tcl_cmd('stream config -numDA %d' % self.da_repeat)
+    def set_fields(self):
+        ''' set ip protocol field behavior '''
+        fields_config = {
+        'vlan':  {
+            0: {'range': self.vlan_repeat, 'action': 'inc'}},
+        'mac':  {
+            'dst': {'range': self.da_repeat, 'action': 'inc'}},}
+
+        return fields_config
-- 
2.17.1


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

* Re: [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen
  2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
                   ` (5 preceding siblings ...)
  2019-06-03 16:31 ` [dts] [next][PATCH V2 7/7] tests/vmdq:replace etgen with pktgen Haiyang Zhao
@ 2019-06-05  1:40 ` Tu, Lijuan
  6 siblings, 0 replies; 8+ messages in thread
From: Tu, Lijuan @ 2019-06-05  1:40 UTC (permalink / raw)
  To: Zhao, HaiyangX, dts; +Cc: Zhao, HaiyangX

Applied the series into next branch, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Haiyang Zhao
> Sent: Tuesday, June 4, 2019 12:31 AM
> To: dts@dpdk.org
> Cc: Zhao, HaiyangX <haiyangx.zhao@intel.com>
> Subject: [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen
> 
> *.replace etgen with pktgen API which support both trex and ixia.
> *.delete old etgen override method ip
> 
> Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
> ---
>  tests/TestSuite_l3fwd.py | 81 +++++++++++++++++++++++++++-------------
>  1 file changed, 55 insertions(+), 26 deletions(-)
> 
> diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py index
> 78eaee7..7ffdcba 100644
> --- a/tests/TestSuite_l3fwd.py
> +++ b/tests/TestSuite_l3fwd.py
> @@ -1,6 +1,6 @@
>  # BSD LICENSE
>  #
> -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
> +# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
>  # All rights reserved.
>  #
>  # Redistribution and use in source and binary forms, with or without @@ -
> 37,12 +37,13 @@ Layer-3 forwarding test script.
>  import utils
>  import string
>  import re
> +import os
>  from test_case import TestCase
>  from exception import VerifyFailure
>  from settings import HEADER_SIZE
> -from etgen import IxiaPacketGenerator
> +from pktgen import PacketGeneratorHelper
> 
> -class TestL3fwd(TestCase,IxiaPacketGenerator):
> +class TestL3fwd(TestCase):
> 
>      path = "./examples/l3fwd/build/"
> 
> @@ -185,7 +186,7 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
>          out = self.dut.send_expect("make clean -C examples/l3fwd", "# ")
> 
>          # Compile l3fwd with hash/exact lookup.
> -	self.dut.send_expect(r"sed -i -e
> '/ipv4_l3fwd_em_route_array\[\].*{/,/^\}\;/c\\%s'
> examples/l3fwd/l3fwd_em.c" % exactStr, "# ")
> +        self.dut.send_expect(r"sed -i -e
> + '/ipv4_l3fwd_em_route_array\[\].*{/,/^\}\;/c\\%s'
> + examples/l3fwd/l3fwd_em.c" % exactStr, "# ")
>          out = self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS=-
> DAPP_LOOKUP_METHOD=0")
> 
>          self.verify("Error" not in out, "compilation error 1") @@ -197,6 +198,16
> @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
>          self.l3fwd_test_results = {'header': [],
>                                     'data': []}
> 
> +        # get dts output path
> +        if self.logger.log_path.startswith(os.sep):
> +            self.output_path = self.logger.log_path
> +        else:
> +            cur_path = os.path.dirname(
> +                                os.path.dirname(os.path.realpath(__file__)))
> +            self.output_path = os.sep.join([cur_path, self.logger.log_path])
> +        # create an instance to set stream field setting
> +        self.pktgen_helper = PacketGeneratorHelper()
> +
>      def flows(self):
>          """
>          Return a list of packets that implements the flows described in the @@
> -249,11 +260,26 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
>              payload_size = frame_size -  \
>                  HEADER_SIZE['ip'] - HEADER_SIZE['eth'] - HEADER_SIZE['tcp']
> 
> +            pcaps = {}
> +            flows = []
>              for _port in range(ports_num):
> -                dmac = self.dut.get_mac_address(valports[_port])
> -                flows = ['Ether(dst="%s")/%s/TCP()/("X"*%d)' % (dmac, flow,
> payload_size) for flow in self.flows()[_port *2:(_port +1)*2]]
> -                self.tester.scapy_append('wrpcap("dst%d.pcap",
> [%s])' %(valports[_port],string.join(flows,',')))
> -            self.tester.scapy_execute()
> +                index = valports[_port]
> +                dmac = self.dut.get_mac_address(index)
> +                cnt = 0
> +                for layer in self.flows()[_port *2:(_port +1)*2]:
> +                    flow = 'Ether(dst="%s")/%s/TCP()/("X"*%d)' % (
> +                                                    dmac, layer, payload_size)
> +                    flows.append(flow)
> +                    pcap = os.sep.join([
> +                                self.output_path,
> +                                "dst{0}_{1}.pcap".format(index, cnt)])
> +                    self.tester.scapy_append('wrpcap("%s", [%s])' % (
> +                                                pcap, flow))
> +                    self.tester.scapy_execute()
> +                    if index not in pcaps:
> +                        pcaps[index] = []
> +                    pcaps[index].append(pcap)
> +                    cnt += 1
> 
>              self.rst_report("Flows for %d ports, %d frame size.\n" % (ports_num,
> frame_size),
>                         annex=True)
> @@ -330,12 +356,23 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
>                                  txIntf = self.tester.get_local_port(valports[rxPort - 1])
> 
>                              rxIntf = self.tester.get_local_port(valports[rxPort])
> -                            if rxPort % 2 == 0:
> -                                tgenInput.append((txIntf, rxIntf,
> "dst%d.pcap" %valports[rxPort+1]))
> -                            else:
> -                                tgenInput.append((txIntf, rxIntf,
> "dst%d.pcap" %valports[rxPort-1]))
> +                            port_id = valports[rxPort+1] if rxPort % 2 == 0 else \
> +                                      valports[rxPort-1]
> +                            for pcap in pcaps[port_id]:
> +                                tgenInput.append((txIntf, rxIntf,
> + pcap))
> +
> +                        # Run traffic generator
> +
> +                        vm_config = self.set_fields()
> +                        # clear streams before add new streams
> +                        self.tester.pktgen.clear_streams()
> +                        # run packet generator
> +                        streams =
> self.pktgen_helper.prepare_stream_from_tginput(tgenInput,
> +                                            100, vm_config, self.tester.pktgen)
> +                        # set traffic option
> +                        traffic_opt = {'duration': 60}
> +                        zero_loss_rate, tx_pkts, rx_pkts =
> + self.tester.pktgen.measure_rfc2544(stream_ids=streams,
> + options=traffic_opt)
> 
> -                        zero_loss_rate, tx_pkts, rx_pkts =
> self.tester.run_rfc2544(tgenInput, delay=60)
>                          loss_pkts = tx_pkts - rx_pkts
>                          self.dut.send_expect("^C", "#")
>                          linerate = self.wirespeed(self.nic, frame_size, ports_num) @@
> -357,19 +394,11 @@ class TestL3fwd(TestCase,IxiaPacketGenerator):
> 
>          self.result_table_print()
> 
> -    def ip(self, port, frag, src, proto, tos, dst, chksum, len, options, version,
> flags, ihl, ttl, id):
> -        self.add_tcl_cmd("protocol config -name ip")
> -        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
> -        self.add_tcl_cmd("ip config -sourceIpAddrMode ipRandom")
> -        self.add_tcl_cmd('ip config -destIpAddr "%s"' % dst)
> -        self.add_tcl_cmd("ip config -destIpAddrMode ipIdle")
> -        self.add_tcl_cmd("ip config -ttl %d" % ttl)
> -        self.add_tcl_cmd("ip config -totalLength %d" % len)
> -        self.add_tcl_cmd("ip config -fragment %d" % frag)
> -        self.add_tcl_cmd("ip config -ipProtocol ipV4ProtocolReserved255")
> -        self.add_tcl_cmd("ip config -identifier %d" % id)
> -        self.add_tcl_cmd("stream config -framesize %d" % (len + 18))
> -        self.add_tcl_cmd("ip set %d %d %d" % (self.chasId, port['card'],
> port['port']))
> +    def set_fields(self):
> +        ''' set ip protocol field behavior '''
> +        fields_config = {
> +        'ip':  {'src': {'action': 'random'},},}
> +        return fields_config
> 
>      def tear_down(self):
>          """
> --
> 2.17.1


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

end of thread, other threads:[~2019-06-05  1:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03 16:31 [dts] [next][PATCH V2 1/7] tests/l3fwd: replace etgen with pktgen Haiyang Zhao
2019-06-03 16:31 ` [dts] [next][PATCH V2 2/7] tests/l3fwd_em: replace etgen with pktgen and fix pep8 issue Haiyang Zhao
2019-06-03 16:31 ` [dts] [next][PATCH V2 3/7] tests/link_flowctrl: replace etgen with pktgen Haiyang Zhao
2019-06-03 16:31 ` [dts] [next][PATCH V2 4/7] tests/multiprocess:replace " Haiyang Zhao
2019-06-03 16:31 ` [dts] [next][PATCH V2 5/7] tests/pmd:replace " Haiyang Zhao
2019-06-03 16:31 ` [dts] [next][PATCH V2 6/7] tests/tso:replace etgen with pktgen and fix pep8 issue Haiyang Zhao
2019-06-03 16:31 ` [dts] [next][PATCH V2 7/7] tests/vmdq:replace etgen with pktgen Haiyang Zhao
2019-06-05  1:40 ` [dts] [next][PATCH V2 1/7] tests/l3fwd: replace " Tu, Lijuan

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