test suite reviews and discussions
 help / color / Atom feed
* [dts] [PATCH V1] tests/vhost_dequeue_zero_copy: optimization code
@ 2019-08-14  1:18 lihong
  0 siblings, 0 replies; only message in thread
From: lihong @ 2019-08-14  1:18 UTC (permalink / raw)
  To: dts; +Cc: lihong

1. modify class name
2. update code to support trex

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 tests/TestSuite_vhost_dequeue_zero_copy.py | 49 ++++++++++++++++--------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/tests/TestSuite_vhost_dequeue_zero_copy.py b/tests/TestSuite_vhost_dequeue_zero_copy.py
index 596a23a..5935536 100644
--- a/tests/TestSuite_vhost_dequeue_zero_copy.py
+++ b/tests/TestSuite_vhost_dequeue_zero_copy.py
@@ -45,16 +45,16 @@ import re
 from settings import HEADER_SIZE
 from virt_common import VM
 from test_case import TestCase
-from etgen import IxiaPacketGenerator
+from pktgen import PacketGeneratorHelper
 
 
-class TestPVPQemuZeroCopy(TestCase, IxiaPacketGenerator):
+class TestVhostDequeueZeroCopy(TestCase):
 
     def set_up_all(self):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestPVPQemuZeroCopy, self)
+        self.tester.extend_external_packet_generator(TestVhostDequeueZeroCopy, self)
         self.frame_sizes = [64, 128, 256, 512, 1024, 1518]
         self.queue_number = 1
         self.nb_cores = 1
@@ -74,6 +74,13 @@ class TestPVPQemuZeroCopy(TestCase, IxiaPacketGenerator):
         if 'packet_sizes' in self.get_suite_cfg():
             self.frame_sizes = self.get_suite_cfg()['packet_sizes']
 
+        self.out_path = '/tmp'
+        out = self.tester.send_expect('ls -d %s' % self.out_path, '# ')
+        if 'No such file or directory' in out:
+            self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
+
     def set_up(self):
         """
         Run before each test case.
@@ -89,23 +96,6 @@ class TestPVPQemuZeroCopy(TestCase, IxiaPacketGenerator):
 
         self.vhost = self.dut.new_session(suite="vhost-user")
 
-    def ip(self, port, frag, src, proto, tos, dst, chksum, len,
-                            options, version, flags, ihl, ttl, id):
-        """
-        Configure IP protocol.
-        """
-        self.add_tcl_cmd("protocol config -name ip")
-        self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src)
-        self.add_tcl_cmd('ip config -destIpAddrMode ipRandom')
-        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 get_core_mask(self):
         """
         check whether the server has enough cores to run case
@@ -209,6 +199,13 @@ class TestPVPQemuZeroCopy(TestCase, IxiaPacketGenerator):
         results_row.append(cycle)
         self.result_table_add(results_row)
 
+    def set_fields(self):
+        """
+        set ip protocol field behavior
+        """
+        fields_config = {'ip':  {'dst': {'action': 'random'}, }, }
+        return fields_config
+
     def calculate_avg_throughput(self, frame_size, loopback):
         """
         start to send packet and get the throughput
@@ -216,13 +213,19 @@ class TestPVPQemuZeroCopy(TestCase, IxiaPacketGenerator):
         payload = frame_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - HEADER_SIZE['udp']
         flow = '[Ether(dst="%s")/IP(src="192.168.4.1",proto=255)/UDP()/("X"*%d)]' % (
             self.dst_mac, payload)
-        self.tester.scapy_append('wrpcap("zero_copy.pcap", %s)' % flow)
+        self.tester.scapy_append('wrpcap("%s/zero_copy.pcap", %s)' % (
+                                self.out_path, flow))
         self.tester.scapy_execute()
 
         tgenInput = []
         port = self.tester.get_local_port(self.dut_ports[0])
-        tgenInput.append((port, port, "zero_copy.pcap"))
-        _, pps = self.tester.traffic_generator_throughput(tgenInput, delay=30)
+        tgenInput.append((port, port, "%s/zero_copy.pcap" % self.out_path))
+        vm_config = self.set_fields()
+        self.tester.pktgen.clear_streams()
+        streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100, vm_config, self.tester.pktgen)
+        # set traffic option
+        traffic_opt = {'delay': 5, 'duration': 20}
+        _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)
         Mpps = pps / 1000000.0
         # when the fwd mode is rxonly, we can not receive data, so should not verify it
         if loopback != "rxonly":
-- 
2.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14  1:18 [dts] [PATCH V1] tests/vhost_dequeue_zero_copy: optimization code lihong

test suite reviews and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ http://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/ public-inbox