test suite reviews and discussions
 help / color / mirror / Atom feed
From: Haiyang Zhao <haiyangx.zhao@intel.com>
To: dts@dpdk.org
Cc: Haiyang Zhao <haiyangx.zhao@intel.com>
Subject: [dts] [next][PATCH V2 6/7] tests/tso:replace etgen with pktgen and fix pep8 issue
Date: Mon,  3 Jun 2019 16:31:08 +0000	[thread overview]
Message-ID: <20190603163109.19706-6-haiyangx.zhao@intel.com> (raw)
In-Reply-To: <20190603163109.19706-1-haiyangx.zhao@intel.com>

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


  parent reply	other threads:[~2019-06-03  8:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Haiyang Zhao [this message]
2019-06-03 16:31 ` [dts] [next][PATCH V2 7/7] tests/vmdq:replace " Haiyang Zhao
2019-06-05  1:40 ` [dts] [next][PATCH V2 1/7] tests/l3fwd: replace " 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=20190603163109.19706-6-haiyangx.zhao@intel.com \
    --to=haiyangx.zhao@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).