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 80C4BA0096 for ; Thu, 14 Mar 2019 09:30:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4AFFA374E; Thu, 14 Mar 2019 09:30:20 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 5AF112C28 for ; Thu, 14 Mar 2019 09:30:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2019 01:30:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,477,1544515200"; d="scan'208";a="282544883" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 14 Mar 2019 01:30:14 -0700 Received: from fmsmsx161.amr.corp.intel.com (10.18.125.9) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Mar 2019 01:30:06 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX161.amr.corp.intel.com (10.18.125.9) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Mar 2019 01:30:06 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.158]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.26]) with mapi id 14.03.0415.000; Thu, 14 Mar 2019 16:30:04 +0800 From: "Tu, Lijuan" To: "Wu, ChangqingX" , "dts@dpdk.org" CC: "Wu, ChangqingX" Thread-Topic: [dts] [PATCH V1] tests:add test suite about loadbalancer Thread-Index: AQHU0vs5bZnounC9+0SaLqGwIQqQBqYK15BA Date: Thu, 14 Mar 2019 08:30:04 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BA42C89@SHSMSX101.ccr.corp.intel.com> References: <1551752793-18508-1-git-send-email-changqingx.wu@intel.com> In-Reply-To: <1551752793-18508-1-git-send-email-changqingx.wu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTBlYmY4NDMtMzZhOC00ZWMzLWI1NDYtNzUzOGQ0OGMxNmY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiR2NUdklaSGtOVkI5ZDFCMFVZczlcL3djSGkrMGZXNEdIelwvandUbTlxeGx2VzdkMTFxdW5NTGlwQzlBVEFKYlJUIn0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests:add test suite about loadbalancer 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" Comments inline > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of changqingxwu > Sent: Tuesday, March 5, 2019 10:27 AM > To: dts@dpdk.org > Cc: Wu, ChangqingX > Subject: [dts] [PATCH V1] tests:add test suite about loadbalancer >=20 > Signed-off-by: changqingxwu > --- > tests/TestSuite_loadbalancer.py | 104 ++++++++++++++++++++++++++++++++ > 1 file changed, 104 insertions(+) > create mode 100644 tests/TestSuite_loadbalancer.py >=20 > diff --git a/tests/TestSuite_loadbalancer.py b/tests/TestSuite_loadbalanc= er.py > new file mode 100644 index 0000000..620dbdc > --- /dev/null > +++ b/tests/TestSuite_loadbalancer.py > @@ -0,0 +1,104 @@ > +# > + > +""" > +DPDK Test suite. > + > +Test Load Balancer. > + > +""" > + > +import dts > +from packet import Packet > +from test_case import TestCase > +import time > + > + > +class TestLoadbalancer(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + > + Load Balancer prerequisites. > + """ > + # Verify that enough ports are available > + global dutPorts > + # Based on h/w type, choose how many ports to use > + dutPorts =3D self.dut.get_ports(self.nic) > + > + # Verify that enough ports are available > + self.verify(len(dutPorts) >=3D 4, "Insufficient ports for > + testing") > + > + global P0, P1, P2, P3, trafficFlow > + P0 =3D self.tester.get_local_port(dutPorts[0]) > + P1 =3D self.tester.get_local_port(dutPorts[1]) > + P2 =3D self.tester.get_local_port(dutPorts[2]) > + P3 =3D self.tester.get_local_port(dutPorts[3]) > + P0, P1, P2, P3 are not easily readable > + trafficFlow =3D { > + "F1": [P0, "1.0.0.1"], > + "F2": [P1, "1.0.1.1"], > + "F3": [P2, "1.0.2.1"], > + "F4": [P3, "1.0.3.1"], > + } > + > + out =3D self.dut.send_expect("make -C examples/load_balancer", "= #") > + self.verify("Error" not in out, "compilation error 1") > + self.verify("No such file" not in out, "compilation error 2") > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass > + > + def test_load_balancer(self): > + """ > + Verify Load Balancer run successfully > + """ > + cmd =3D './examples/load_balancer/build/load_balancer -l 3-7 -n = 4 -- --rx > "(0,0,3),(1,0,3),(2,0,3),(3,0,3)" ' \ > + '--tx "(0,3),(1,3),(2,3),(3,3)" --w "4,5,6,7" ' \ > + '--lpm "1.0.0.0/24=3D>0;1.0.1.0/24=3D>1;1.0.2.0/24=3D>2;1.= 0.3.0/24=3D>3;' \ > + '" --bsz "(10, 10), (10, 10), (10, 10)" --pos-lb 29' [Lijuan] It's better to make you code suite for generic platform , so sugge= st you get cores form API. > + > + self.dut.send_expect(cmd, 'main loop.') > + > + for flow in trafficFlow.keys(): > + rx_port =3D trafficFlow[flow][0] > + > + for i in range(len(dutPorts)): > + dstport =3D self.tester.get_local_port(dutPorts[i]) > + pkt_count =3D 10 > + inst =3D > + self.tester.tcpdump_sniff_packets(intf=3Dself.tester.get_interface(rx_p= o > + rt), timeout=3D10, count=3Dpkt_count) > + > + pkt =3D Packet() > + dst_mac =3D self.dut.get_mac_address(dutPorts[rx_port-5]= ) > + pkt.config_layer('ether', {'dst': dst_mac}) > + pkt.config_layer('ipv4', {'src': "0.0.0.0", 'dst': traff= icFlow[flow][1]}) > + pkt.send_pkt(tx_port=3Dself.tester.get_interface(dstport= ), count=3D10) > + time.sleep(5) # Wait for the sniffer to finish. > + > + pkts =3D self.tester.load_tcpdump_sniff_packets(inst) > + len_pkts =3D len(pkts) > + > + if len_pkts =3D=3D pkt_count: > + result =3D str([pkts[i].pktgen.pkt.show for i in ran= ge(len_pkts)]) > + self.verify("Ether" in result, "No packet received") > + self.verify("src=3D0.0.0.0" + " dst=3D" + trafficFlo= w[flow][1] in result, > "Wrong IP address") > + self.verify("dst=3D%s" % dst_mac in result, "Recive = wrong packet") [Lijuan] typo: Recive -> Received. > + else: > + self.verify("dst=3D01:00" not in dst_mac, "Packet > + arrived on an unexpected port") [Lijuan] Maybe packet missed > + > + self.dut.send_expect("^C", "#") [Lijuan] if exception happened, how to reach here. The application may be a= live while test suite finished. > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + pass > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + pass > -- > 2.17.2