From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 13324A0096 for ; Mon, 3 Jun 2019 10:31:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 07C721B94F; Mon, 3 Jun 2019 10:31:28 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id E76121B94F for ; Mon, 3 Jun 2019 10:31:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 01:31:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,546,1549958400"; d="scan'208";a="181081874" Received: from zhaohy_tester.sh.intel.com ([10.240.179.16]) by fmsmga002.fm.intel.com with ESMTP; 03 Jun 2019 01:31:23 -0700 From: Haiyang Zhao To: dts@dpdk.org Cc: Haiyang Zhao Date: Mon, 3 Jun 2019 16:31:04 +0000 Message-Id: <20190603163109.19706-2-haiyangx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603163109.19706-1-haiyangx.zhao@intel.com> References: <20190603163109.19706-1-haiyangx.zhao@intel.com> Subject: [dts] [next][PATCH V2 2/7] tests/l3fwd_em: replace etgen with pktgen and fix pep8 issue X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" *.replace etgen with pktgen API which support both trex and ixia. *.delete old etgen override method ip Signed-off-by: Haiyang Zhao --- 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