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 75BC5A0096 for ; Thu, 11 Apr 2019 20:06:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1924A4CAB; Thu, 11 Apr 2019 20:06:48 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 8A1A0A3 for ; Thu, 11 Apr 2019 20:06:46 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2019 11:06:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,338,1549958400"; d="scan'208";a="133465256" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 11 Apr 2019 11:06:44 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 11 Apr 2019 11:06:43 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.164]) by shsmsx102.ccr.corp.intel.com ([169.254.2.206]) with mapi id 14.03.0415.000; Fri, 12 Apr 2019 02:06:41 +0800 From: "Tu, Lijuan" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Ma, LihongX" Thread-Topic: [dts] [PATCH V1] Add testsuite of loopback virtio server mode Thread-Index: AQHU6oUBbPca8WBDEUSGnXRpXsuloqY3TPtQ Date: Thu, 11 Apr 2019 18:06:42 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BA6059E@SHSMSX101.ccr.corp.intel.com> References: <1554314614-20290-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1554314614-20290-1-git-send-email-lihongx.ma@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.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWVhMDhmZDAtZjdkMy00YmIzLWExNzAtNGE1NWVhMjYyMzE0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOENkbThrdUk2NEpuU1JDNFFtMmFrcGpHRTIwem1peUhqTEJ3SkRTVnAwK3MzVldLQndwaW1abFwvTzk1elpqd2gifQ== 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] Add testsuite of loopback virtio server mode 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" > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong > Sent: Wednesday, April 3, 2019 11:04 AM > To: dts@dpdk.org > Cc: Ma, LihongX > Subject: [dts] [PATCH V1] Add testsuite of loopback virtio server mode >=20 > Signed-off-by: lihong > --- > .../TestSuite_loopback_virtio_user_server_mode.py | 353 > +++++++++++++++++++++ > 1 file changed, 353 insertions(+) > create mode 100644 tests/TestSuite_loopback_virtio_user_server_mode.py >=20 > diff --git a/tests/TestSuite_loopback_virtio_user_server_mode.py > b/tests/TestSuite_loopback_virtio_user_server_mode.py > new file mode 100644 > index 0000000..abb171d > --- /dev/null > +++ b/tests/TestSuite_loopback_virtio_user_server_mode.py > @@ -0,0 +1,353 @@ > +# > +# BSD LICENSE > +# > +# Copyright(c) 2010-2019 Intel Corporation. All rights reserved. > +# All rights reserved. > +# > +# Redistribution and use in source and binary forms, with or without # > +modification, are permitted provided that the following conditions # > +are met: > +# > +# * Redistributions of source code must retain the above copyright > +# notice, this list of conditions and the following disclaimer. > +# * Redistributions in binary form must reproduce the above copyright > +# notice, this list of conditions and the following disclaimer in > +# the documentation and/or other materials provided with the > +# distribution. > +# * Neither the name of Intel Corporation nor the names of its > +# contributors may be used to endorse or promote products derived > +# from this software without specific prior written permission. > +# > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS # > +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS > FOR # > +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT # > +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, # > +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > # > +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > USE, # > +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > ON ANY # > +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # > +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE > USE # > +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + > + > +""" > +DPDK Test suite. > +Test loopback virtio-user server mode > +""" > +import utils > +import time > +import re > +from test_case import TestCase > + > + > +class TestLoopbackVirtioUserServerMode(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.core_config =3D "1S/6C/1T" > + self.queue_number =3D 1 > + self.nb_cores =3D 1 > + self.dut_ports =3D self.dut.get_ports() > + self.ports_socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + self.core_list =3D self.dut.get_core_list( > + self.core_config, socket=3Dself.ports_socket) [Lijuan] Could you please examine if there is enough cores for your tests, = some platform may don't have 6 cores. > + self.core_list_user =3D self.core_list[0:3] > + self.core_list_host =3D self.core_list[3:6] > + self.core_mask_user =3D utils.create_mask(self.core_list_user) > + self.core_mask_host =3D utils.create_mask(self.core_list_host) > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + # Clean the execution ENV > + self.dut.send_expect("rm -rf ./vhost-net*", "#") > + self.dut.send_expect("killall -s INT testpmd", "#") > + # Prepare the result table > + self.table_header =3D ["Mode", "Throughput(Mpps)", "Cycle"] > + self.result_table_create(self.table_header) > + > + self.vhost =3D self.dut.new_session(suite=3D"vhost") > + self.virtio_user =3D self.dut.new_session(suite=3D"virtio-user") > + > + def lanuch_vhost_testpmd(self, queue_number=3D1, nb_cores=3D1, > extern_params=3D""): > + """ > + start testpmd on vhost > + """ > + command_client =3D self.dut.target + "/app/testpmd " + \ > + " -n %d -c %s --socket-mem 1024,1024 " + \ > + " --legacy-mem --no-pci --file-prefix=3Dvhost "= + \ > + " --vdev 'net_vhost0,iface=3Dvhost-net,client= =3D1,queues=3D%d' " + > \ > + " -- -i --rxq=3D%d --txq=3D%d --nb-cores=3D%d %= s" > + command_line_client =3D command_client % > (self.dut.get_memory_channels(), > + self.core_mask_host, queue_number, queue_n= umber, > + queue_number, nb_cores, extern_params) > + self.vhost.send_expect(command_line_client, "testpmd> ", 120) > + self.vhost.send_expect("set fwd mac", "testpmd> ", 120) > + > + def lanuch_virtio_user_testpmd(self): > + """ > + start testpmd of vhost user > + """ > + command_line_user =3D self.dut.target + "/app/testpmd -n %d -c %= s -- > socket-mem 1024,1024 " + \ > + "--legacy-mem --no-pci --file-prefix=3Dvirti= o " + \ > + "-- > vdev=3Dnet_virtio_user0,mac=3D00:01:02:03:04:05,path=3Dvhost- > net,server=3D1,queues=3D1 " + \ > + " -- -i --rxq=3D1 --txq=3D1 --no-numa" > + command_line_user =3D command_line_user % > (self.dut.get_memory_channels(), > + self.core_mask_user) > + self.virtio_user.send_expect(command_line_user, "testpmd> ", 120= ) > + self.virtio_user.send_expect("set fwd mac", "testpmd> ", 120) > + > + def lanuch_vhost_testpmd_with_multi_queue(self, extern_params=3D""): > + """ > + start testpmd with multi qeueue > + """ > + self.lanuch_vhost_testpmd(self.queue_number, self.nb_cores, > + extern_params=3Dextern_params) > + > + def lanuch_virtio_user_testpmd_with_multi_queue(self, mode, > extern_params=3D""): > + """ > + start testpmd of vhost user > + """ > + command_line_user =3D self.dut.target + "/app/testpmd -n %d -c %= s -- > socket-mem 1024,1024 " + \ > + "--legacy-mem --no-pci --file-prefix=3Dvirti= o " + \ > + "-- > vdev=3Dnet_virtio_user0,mac=3D00:01:02:03:04:05,path=3Dvhost- > net,server=3D1,queues=3D%d,%s " + \ > + " -- -i --tx-offloads=3D0x0 --enable-hw-vlan= -strip --rss-ip --nb- > cores=3D%d --rxq=3D%d --txq=3D%d %s" > + command_line_user =3D command_line_user % > (self.dut.get_memory_channels(), > + self.core_mask_user, self.queue_number, mode= , > self.nb_cores, > + self.queue_number, self.queue_number, extern= _params) > + self.virtio_user.send_expect(command_line_user, "testpmd> ", 120= ) > + self.virtio_user.send_expect("set fwd mac", "testpmd> ", 120) > + > + def start_to_send_packets(self, session_rx, session_tx): > + """ > + start the testpmd of vhost-user and virtio-user > + start to send packets > + """ > + session_rx.send_expect("start", "testpmd> ", 30) > + session_tx.send_expect("start tx_first 32", "testpmd> ", 30) > + > + def check_port_throughput_after_port_stop(self): > + """ > + check the throughput after port stop > + """ > + loop =3D 1 > + while(loop <=3D 5): > + out =3D self.vhost.send_expect("show port stats 0", "testpmd= >", 60) > + lines =3D re.search("Rx-pps:\s*(\d*)", out) > + result =3D lines.group(1) > + if result =3D=3D "0": > + break > + time.sleep(3) > + loop =3D loop + 1 > + self.verify(result =3D=3D "0", "port stop failed, it alse can > + recevie data after stop.") > + > + def check_port_link_status_after_port_restart(self): > + """ > + check the link status after port restart > + """ > + loop =3D 1 > + while(loop <=3D 5): > + out =3D self.vhost.send_expect("show port info all", "testpm= d> ", 120) > + port_status =3D re.findall("Link\s*status:\s*([a-z]*)", out) > + if("down" not in port_status): > + break > + time.sleep(3) > + loop =3D loop + 1 > + > + self.verify("down" not in port_status, "port can not up after > + restart") > + > + def check_link_status(self, side, status): > + out =3D side.send_expect("show port info 0", "testpmd> ", 120) > + res =3D re.search("Link\s*status:\s*(\S*)", out) > + self.verify(res.group(1) =3D=3D status, > + "The status not right on virtio side after vhost quit, statu= s: %s" % > + res.group(1)) > + > + def port_restart(self): > + self.vhost.send_expect("stop", "testpmd> ", 120) > + self.vhost.send_expect("port stop 0", "testpmd> ", 120) > + self.check_port_throughput_after_port_stop() > + self.vhost.send_expect("clear port stats all", "testpmd> ", 120) > + self.vhost.send_expect("port start 0", "testpmd> ", 120) > + self.check_port_link_status_after_port_restart() > + self.vhost.send_expect("start tx_first 32", "testpmd> ", 120) > + > + def relanuch_vhost_testpmd_with_multi_queue(self): > + self.vhost.send_expect("quit", "#", 60) > + self.check_link_status(self.virtio_user, "down") > + self.lanuch_vhost_testpmd_with_multi_queue() > + > + def relanuch_virtio_testpmd_with_multi_queue(self, mode, > extern_params=3D""): > + self.virtio_user.send_expect("quit", "#", 60) > + self.check_link_status(self.vhost, "down") > + self.lanuch_virtio_user_testpmd_with_multi_queue(mode, > + extern_params) > + > + def calculate_avg_throughput(self, case_info, cycle): > + """ > + calculate the average throughput > + """ > + results =3D 0.0 > + results_row =3D [] > + for i in range(10): > + out =3D self.vhost.send_expect("show port stats all", "testp= md>", 60) > + time.sleep(5) > + lines =3D re.search("Rx-pps:\s*(\d*)", out) > + result =3D lines.group(1) > + results +=3D float(result) > + Mpps =3D results / (1000000 * 10) > + self.verify(Mpps > 0, "port can not receive packets") > + > + results_row.append(case_info) > + results_row.append(Mpps) > + results_row.append(cycle) > + self.result_table_add(results_row) > + > + def check_packets_of_each_queue(self): > + """ > + check all the queue has receive packets > + """ > + out =3D self.vhost.send_expect("stop", "testpmd> ", 60) > + for queue_index in range(0, self.queue_number): > + queue =3D "Queue=3D %d" % queue_index > + index =3D out.find(queue) > + rx =3D re.search("RX-packets:\s*(\d*)", out[index:]) > + tx =3D re.search("TX-packets:\s*(\d*)", out[index:]) > + rx_packets =3D int(rx.group(1)) > + tx_packets =3D int(tx.group(1)) > + self.verify(rx_packets > 0 and tx_packets > 0, > + "The queue %d rx-packets or tx-packets is 0, rx-packe= ts:%s, tx- > packets:%s" % > + (queue_index, rx_packets, tx_packets)) > + > + def close_all_testpmd(self): > + """ > + close testpmd about vhost-user and virtio-user > + """ > + self.vhost.send_expect("quit", "#", 60) > + self.virtio_user.send_expect("quit", "#", 60) > + > + def close_all_session(self): > + """ > + close session of vhost-user and virtio-user > + """ > + self.dut.close_session(self.vhost) > + self.dut.close_session(self.virtio_user) > + > + def test_server_mode_launch_vhost_first(self): > + """ > + basic test for virtio-user server mode, launch vhost first > + """ > + self.lanuch_vhost_testpmd() > + self.lanuch_virtio_user_testpmd() > + self.start_to_send_packets(self.vhost, self.virtio_user) > + self.calculate_avg_throughput("lanuch vhost first", "") > + self.result_table_print() > + self.close_all_testpmd() > + > + def test_server_mode_launch_virtio_first(self): > + """ > + basic test for virtio-user server mode, launch virtio-user first > + """ > + self.lanuch_virtio_user_testpmd() > + self.lanuch_vhost_testpmd() > + self.start_to_send_packets(self.virtio_user, self.vhost) > + self.calculate_avg_throughput("lanuch virtio first", "") > + self.result_table_print() > + self.close_all_testpmd() > + > + def > test_server_mode_multi_queue_reconnect_from_vhost_side_with_virtio11(s > elf): > + """ > + reconnect virtio-user from the vhost side with multi_queues > + """ > + self.queue_number =3D 2 > + self.nb_cores =3D 2 > + mode =3D "packed_vq=3D1,in_order=3D0,mrg_rxbuf=3D1" > + self.lanuch_vhost_testpmd_with_multi_queue() > + self.lanuch_virtio_user_testpmd_with_multi_queue(mode=3Dmode) > + self.start_to_send_packets(self.vhost, self.virtio_user) > + self.calculate_avg_throughput("reconnet from vhost with virtio1.= 1", > + "before reconnet") > + > + self.relanuch_vhost_testpmd_with_multi_queue() > + self.start_to_send_packets(self.virtio_user, self.vhost) > + self.calculate_avg_throughput("reconnet from vhost with virtio1.= 1", > + "after reconnet") > + self.result_table_print() > + self.check_packets_of_each_queue() > + self.close_all_testpmd() > + > + def > test_server_mode_multi_queue_reconnect_from_vhost_side_with_virtio10(s > elf): > + """ > + reconnect virtio-user from the vhost side with multi_queues > + """ > + self.queue_number =3D 2 > + self.nb_cores =3D 2 > + mode =3D "packed_vq=3D0,in_order=3D1,mrg_rxbuf=3D1" > + self.lanuch_vhost_testpmd_with_multi_queue() > + self.lanuch_virtio_user_testpmd_with_multi_queue(mode=3Dmode) > + self.start_to_send_packets(self.vhost, self.virtio_user) > + self.calculate_avg_throughput("reconnet from vhost with virtio1.= 0", > + "before reconnet") > + > + self.relanuch_vhost_testpmd_with_multi_queue() > + self.start_to_send_packets(self.virtio_user, self.vhost) > + self.calculate_avg_throughput("reconnet from vhost with virtio1.= 0", > + "after reconnet") > + self.result_table_print() > + self.check_packets_of_each_queue() > + self.close_all_testpmd() > + > + def > test_server_mode_multi_queue_reconnect_from_virito_side_with_virtio10(s > elf): > + """ > + reconnect vhost-user from the virtio side with vhost/virtio1.0 l= oopback > multi_queues > + """ > + self.queue_number =3D 2 > + self.nb_cores =3D 2 > + mode =3D "packed_vq=3D0,in_order=3D1,mrg_rxbuf=3D1" > + self.lanuch_vhost_testpmd_with_multi_queue() > + self.lanuch_virtio_user_testpmd_with_multi_queue(mode=3Dmode) > + self.start_to_send_packets(self.vhost, self.virtio_user) > + self.calculate_avg_throughput("reconnet from virito with virtio1= .0", > + "before reconnet") > + > + self.relanuch_virtio_testpmd_with_multi_queue(mode=3Dmode) > + self.start_to_send_packets(self.vhost, self.virtio_user) > + self.calculate_avg_throughput("reconnet from virito with virtio1= .0", > + "after reconnet") > + self.result_table_print() > + self.close_all_testpmd() > + > + def test_server_mode_port_start_stop_at_vhost(self): > + """ > + port start/stop at vhost side with server mode multi queues > + """ > + self.queue_number =3D 2 > + self.nb_cores =3D 2 > + mode =3D "packed_vq=3D1,in_order=3D0,mrg_rxbuf=3D1" > + extern_params =3D "--txd=3D1024 --rxd=3D1024" > + > self.lanuch_vhost_testpmd_with_multi_queue(extern_params=3Dextern_para > ms) > + self.lanuch_virtio_user_testpmd_with_multi_queue(mode=3Dmode, > extern_params=3Dextern_params) > + self.start_to_send_packets(self.vhost, self.virtio_user) > + self.calculate_avg_throughput("vhost port restart", "before > + restart") > + > + self.port_restart() > + self.calculate_avg_throughput("vhost port restart", "after resta= rt") > + self.result_table_print() > + > + self.check_packets_of_each_queue() > + self.close_all_testpmd() > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.send_expect("killall -s INT testpmd", "#") > + self.close_all_session() > + time.sleep(2) > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > -- > 2.7.4