From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA0D7A09FF; Wed, 30 Dec 2020 04:28:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 98D422B8C; Wed, 30 Dec 2020 04:28:39 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 40FE02B87 for ; Wed, 30 Dec 2020 04:28:36 +0100 (CET) IronPort-SDR: C7JQ2UxNe2tX5sD5g4Qklf2PX4b/3Bgdw0TKxxlnSJilR6YtTEWZhOAc5nJr//AXoTqJrk/R1w COdpXW3Ui50g== X-IronPort-AV: E=McAfee;i="6000,8403,9849"; a="261316941" X-IronPort-AV: E=Sophos;i="5.78,460,1599548400"; d="scan'208";a="261316941" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2020 19:28:34 -0800 IronPort-SDR: yzV1TYsxCV3N0jW1eMFeT+zy7J1JgPxTAjymcQDIFn51NiMUex8wZudH509Cno6GOglne3yec+ eFk7PnVC80kA== X-IronPort-AV: E=Sophos;i="5.78,460,1599548400"; d="scan'208";a="567916251" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2020 19:28:32 -0800 From: JiangYu To: dts@dpdk.org Cc: JiangYu Date: Wed, 30 Dec 2020 11:22:20 +0000 Message-Id: <20201230112220.876065-1-yux.jiang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [dts] [PATCH V1] tests/vhost_cbdma: Optimize Case1-2 and Add Case3 to check CBDMA threshold value 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" 0, Add expected value json file and related function. 1, Optimize Case1: Add relaunch vhost performance check. 2, Optimize self.send_and_verify function.=20 3, Add New Case3: test_check_threshold_value_with_cbdma. Signed-off-by: JiangYu --- conf/vhost_cbdma.cfg | 7 + tests/TestSuite_vhost_cbdma.py | 323 +++++++++++++++++++++++++++++++++++++= ---- 2 files changed, 299 insertions(+), 31 deletions(-) create mode 100644 conf/vhost_cbdma.cfg diff --git a/conf/vhost_cbdma.cfg b/conf/vhost_cbdma.cfg new file mode 100644 index 0000000..2777d79 --- /dev/null +++ b/conf/vhost_cbdma.cfg @@ -0,0 +1,7 @@ +[suite] +update_expected =3D True +test_parameters =3D {64: [1024], 1518: [1024]} +test_duration =3D 60 +accepted_tolerance =3D 2 +expected_throughput =3D {'test_perf_dynamic_queue_number_cbdma_vhost_enque= ue_operations': {'dynamic_queue2': {64: {1024: 0.00}, 1518: {1024: 0.00}}, = 'virtio_user_dynamic_queue2_change_to_1': {64: {1024: 0.00}, 1518: {1024: 0= .00}}, 'Relaunch_dynamic_queue2': {64: {1024: 0.00}, 1518: {1024: 0.00}}, '= vhost_userRelaunch_dynamic_queue2_change_to_1': {64: {1024: 0.00}, 1518: {1= 024: 0.00}}, 'Relaunch_vhost_2_cbdma': {64: {1024: 0.00}, 1518: {1024: 0.00= }}}, 'test_perf_pvp_spilt_all_path_with_cbdma_vhost_enqueue_operations': {'= inorder_mergeable_path': {64: {1024: 0.00}, 1518: {1024: 0.00}}, 'inorder_m= ergeable_path_RestartVhost': {64: {1024: 0.00}, 1518: {1024: 0.00}}, 'merge= able_path': {64: {1024: 0.00}, 1518: {1024: 0.00}}, 'mergeable_path_Restart= Vhost': {64: {1024: 0.00}, 1518: {1024: 0.00}}, 'inorder_non_mergeable_path= ': {64: {1024: 0.00}, 1518: {1024: 0.00}}, 'inorder_non_mergeable_path_Rest= artVhost': {64: {1024: 0.00}, 1518: {1024: 0.00}}, 'non_mergeable_path': {6= 4: {1024: 0.00}, 1518: {1024: 0.00}}, 'non_mergeable_path_RestartVhost': {6= 4: {1024: 0.00}, 1518: {1024: 0.00}}, 'vector_rx_path': {64: {1024: 0.00}, = 1518: {1024: 0.00}}, 'vector_rx_path_RestartVhost': {64: {1024: 0.00}, 1518= : {1024: 0.00}}},} + diff --git a/tests/TestSuite_vhost_cbdma.py b/tests/TestSuite_vhost_cbdma.py index 869765f..7cf8bd4 100644 --- a/tests/TestSuite_vhost_cbdma.py +++ b/tests/TestSuite_vhost_cbdma.py @@ -42,12 +42,16 @@ Here is an example: $ ./testpmd -c f -n 4 \ --vdev 'net_vhost0,iface=3D/tmp/s0,queues=3D1,dmas=3D[txq0@80:04.0],dma= thr=3D1024' """ +import rst, json import re import time from test_case import TestCase from settings import HEADER_SIZE +from packet import Packet from pktgen import PacketGeneratorHelper from pmd_output import PmdOutput +from settings import UPDATE_EXPECTED, load_global_setting +from copy import deepcopy =20 =20 class TestVirTioVhostCbdma(TestCase): @@ -58,8 +62,10 @@ class TestVirTioVhostCbdma(TestCase): =20 self.vhost_user =3D self.dut.new_session(suite=3D"vhost-user") self.virtio_user =3D self.dut.new_session(suite=3D"virtio-user") + self.virtio_user1 =3D self.dut.new_session(suite=3D"virtio-user1") self.pmdout_vhost_user =3D PmdOutput(self.dut, self.vhost_user) self.pmdout_virtio_user =3D PmdOutput(self.dut, self.virtio_user) + self.pmdout_virtio_user1 =3D PmdOutput(self.dut, self.virtio_user1) self.frame_sizes =3D [64, 1518] self.virtio_mac =3D "00:01:02:03:04:05" self.headers_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] @@ -77,20 +83,40 @@ class TestVirTioVhostCbdma(TestCase): self.tester.send_expect('mkdir -p %s' % self.out_path, '# ') self.pktgen_helper =3D PacketGeneratorHelper() self.base_dir =3D self.dut.base_dir.replace('~', '/root') + self.testpmd_name =3D self.dut.apps_name['test-pmd'].split("/")[-1] + self.save_result_flag =3D True + self.json_obj =3D {} =20 def set_up(self): """ Run before each test case. """ self.table_header =3D ['Frame'] + self.table_header.append("Mode/RXD-TXD") self.used_cbdma =3D [] - self.table_header.append("Mode") self.table_header.append("Mpps") self.table_header.append("% linerate") self.result_table_create(self.table_header) - self.vhost =3D self.dut.new_session(suite=3D"vhost-user") + + # test parameters include: frames size, descriptor numbers + self.test_parameters =3D self.get_suite_cfg()['test_parameters'] + + # traffic duraion in second + self.test_duration =3D self.get_suite_cfg()['test_duration'] + + # initilize throughput attribution + # {'TestCase':{ 'Mode': {'$framesize':{"$nb_desc": 'throughput'}}} + self.throughput =3D {} + + # Accepted tolerance in Mpps + self.gap =3D self.get_suite_cfg()['accepted_tolerance'] + self.test_result =3D {} + self.nb_desc =3D self.test_parameters[64][0] + + self.dut.send_expect("killall -I %s" % self.testpmd_name, '#', 20) self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#") self.dut.send_expect("rm -rf /tmp/s0", "#") + self.mode_list =3D [] =20 def bind_nic_driver(self, ports, driver=3D""): if driver =3D=3D "igb_uio": @@ -143,6 +169,33 @@ class TestVirTioVhostCbdma(TestCase): self.dut.send_expect('./usertools/dpdk-devbind.py --force --bi= nd=3Dioatdma %s' % self.device_str, '# ', 60) =20 + def check_packets_of_each_queue(self, queue_list): + """ + check each queue has receive packets + """ + out =3D self.vhost_user.send_expect("stop", "testpmd> ", 60) + for queue_index in queue_list: + 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 about = " % + queue_index + \ + "rx-packets:%d, tx-packets:%d" % + (rx_packets, tx_packets)) + + self.vhost_user.send_expect("clear port stats all", "testpmd> ", 3= 0) + self.vhost_user.send_expect("start", "testpmd> ", 30) + + def check_port_stats_result(self, session): + out =3D session.send_expect("show port stats all", "testpmd> ", 30) + self.result_first =3D re.findall(r'RX-packets: (\w+)', out) + self.result_secondary =3D re.findall(r'TX-packets: (\w+)', out) + self.verify(int(self.result_first[0]) > 1 and int(self.result_seco= ndary[0]) > 1, "forward packets no correctly") + @property def check_2m_env(self): out =3D self.dut.send_expect("cat /proc/meminfo |grep Hugepagesize= |awk '{print($2)}'", "# ") @@ -156,6 +209,16 @@ class TestVirTioVhostCbdma(TestCase): self.vhost_user.send_expect('set fwd mac', 'testpmd> ', 120) self.vhost_user.send_expect('start', 'testpmd> ', 120) =20 + def launch_testpmd_as_virtio_user1(self, command, cores=3D"Default", d= ev=3D""): + eal_params =3D "" + if self.check_2m_env: + eal_params +=3D " --single-file-segments" + self.pmdout_virtio_user1.start_testpmd(cores, command, vdevs=3D[de= v], ports=3D[], no_pci=3DTrue, + prefix=3D"virtio1", fixed_p= refix=3DTrue, eal_param=3Deal_params) + self.virtio_user1.send_expect('set fwd mac', 'testpmd> ', 30) + self.virtio_user1.send_expect('start', 'testpmd> ', 30) + self.virtio_user1.send_expect('show port info all', 'testpmd> ', 3= 0) + def launch_testpmd_as_virtio_user(self, command, cores=3D"Default", de= v=3D""): eal_params =3D "" if self.check_2m_env: @@ -165,11 +228,11 @@ class TestVirTioVhostCbdma(TestCase): =20 self.virtio_user.send_expect('set fwd mac', 'testpmd> ', 120) self.virtio_user.send_expect('start', 'testpmd> ', 120) + self.virtio_user.send_expect('show port info all', 'testpmd> ', 30) =20 - def diff_param_launch_send_and_verify(self, mode, params, dev, cores, = is_quit=3DTrue): - self.launch_testpmd_as_virtio_user(params, - cores, - dev=3Ddev) + def diff_param_launch_send_and_verify(self, mode, params, dev, cores, = is_quit=3DTrue, launch_virtio=3DTrue): + if launch_virtio: + self.launch_testpmd_as_virtio_user(params, cores, dev=3Ddev) =20 self.send_and_verify(mode) if is_quit: @@ -181,6 +244,9 @@ class TestVirTioVhostCbdma(TestCase): used one cbdma port bonding igb_uio :return: """ + self.test_target =3D self.running_case + self.expected_throughput =3D self.get_suite_cfg()['expected_throug= hput'][self.test_target] + txd_rxd =3D 1024 dmathr =3D 1024 eal_tx_rxd =3D ' --nb-cores=3D%d --txd=3D%d --rxd=3D%d' @@ -207,16 +273,34 @@ class TestVirTioVhostCbdma(TestCase): queue, txd_rxd, txd_rxd) vdevs =3D f"'net_virtio_user0,mac=3D{self.virtio_mac},path=3D/= tmp/s0,{path_mode},queues=3D%d'" % queue self.diff_param_launch_send_and_verify(key, pvp_split_all_path= _virtio_params, vdevs, - self.cores[2:4], + self.cores[2:4], is_qui= t=3DFalse, ) + self.mode_list.append(key) + # step3 restart vhost port, then check throughput again + key +=3D "_RestartVhost" + self.vhost_user.send_expect('show port stats all', 'testpmd> '= , 10) + self.vhost_user.send_expect('stop', 'testpmd> ', 10) + self.vhost_user.send_expect('start', 'testpmd> ', 10) + self.vhost_user.send_expect('show port info all', 'testpmd> ',= 30) + self.vhost_user.send_expect('show port stats all', 'testpmd> '= , 10) + self.diff_param_launch_send_and_verify(key, pvp_split_all_path= _virtio_params, vdevs, + self.cores[2:4], launch= _virtio=3DFalse) + self.mode_list.append(key) + + self.vhost_user.send_expect("quit", "# ") self.result_table_print() + self.handle_expected(mode_list=3Dself.mode_list) + self.handle_results(mode_list=3Dself.mode_list) =20 def test_perf_dynamic_queue_number_cbdma_vhost_enqueue_operations(self= ): """ # used 2 cbdma ports bonding igb_uio :return: """ - used_cbdma_num =3D 2 + self.test_target =3D self.running_case + self.expected_throughput =3D self.get_suite_cfg()['expected_throug= hput'][self.test_target] + + used_cbdma_num =3D 4 queue =3D 2 txd_rxd =3D 1024 dmathr =3D 1024 @@ -237,50 +321,102 @@ class TestVirTioVhostCbdma(TestCase): self.launch_testpmd_as_vhost_user(eal_params, self.cores[0:2], dev=3Dvhost_dev % vhost_dmas) # - # queue 2 start virtio testpmd,virtio queue 2 to 1 + # queue 2 start virtio testpmd, check perforamnce and RX/TX mode =3D "dynamic_queue2" + self.mode_list.append(mode) self.launch_testpmd_as_virtio_user(dynamic_queue_number_cbdma_virt= io_params, self.cores[2:4], dev=3Dvirtio_dev) - self.send_and_verify(mode) + self.send_and_verify(mode, queue_list=3Drange(queue)) + + # On virtio-user side, dynamic change rx/tx queue numbers from 2 q= ueue to 1 queues self.vhost_or_virtio_set_one_queue(self.virtio_user) - self.send_and_verify("virtio_user_" + mode + "_change_to_1", multi= ple_queue=3DFalse) =20 + self.send_and_verify("virtio_user_" + mode + "_change_to_1", queue= _list=3D[0]) + self.mode_list.append("virtio_user_" + mode + "_change_to_1") self.virtio_user.send_expect("stop", "testpmd> ") self.virtio_user.send_expect("quit", "# ") time.sleep(5) self.dut.send_expect(f"rm -rf {virtio_path}", "#") - # queue 2 start virtio testpmd,vhost queue 2 to 1 + + # queue 2 start virtio testpmd, check perforamnce and RX/TX self.launch_testpmd_as_virtio_user(dynamic_queue_number_cbdma_virt= io_params, self.cores[2:4], dev=3Dvirtio_dev) mode =3D "Relaunch_dynamic_queue2" - self.send_and_verify(mode) + self.mode_list.append(mode) + self.send_and_verify(mode, queue_list=3Drange(queue)) + + # On vhost side, dynamic change rx queue numbers from 2 queue to 1= queues self.vhost_or_virtio_set_one_queue(self.vhost_user) self.send_and_verify("vhost_user" + mode + "_change_to_1") + self.mode_list.append("vhost_user" + mode + "_change_to_1") self.vhost_user.send_expect("quit", "# ") time.sleep(2) =20 # Relaunch vhost with another two cbdma channels mode =3D "Relaunch_vhost_2_cbdma" + self.mode_list.append(mode) dmathr =3D 512 - vhost_dmas =3D f"dmas=3D[txq0@{self.used_cbdma[0]}],dmathr=3D{dmat= hr}" + vhost_dmas =3D f"dmas=3D[txq0@{self.used_cbdma[2]};txq1@{self.used= _cbdma[3]}],dmathr=3D{dmathr}" self.launch_testpmd_as_vhost_user(eal_params, self.cores[0:2], dev=3Dvhost_dev % vhost_dmas) - self.send_and_verify(mode) + self.virtio_user.send_expect("clear port stats all", "testpmd> ", = 30) + self.send_and_verify(mode, queue_list=3Drange(queue)) + self.check_port_stats_result(self.virtio_user) self.virtio_user.send_expect("quit", "# ") self.vhost_user.send_expect("quit", "# ") - time.sleep(2) + self.result_table_print() + # result_rows =3D [[], [64, 'dynamic_queue2', 7.4959375, 12.593175= ], [1518, 'dynamic_queue2', 1.91900225, 59.028509209999996]] + result_rows =3D self.result_table_getrows() # + self.handle_expected(mode_list=3Dself.mode_list) + self.handle_results(mode_list=3Dself.mode_list) + + def test_check_threshold_value_with_cbdma(self): + """ + Test Case3: CBDMA threshold value check + """ + used_cbdma_num =3D 4 + params =3D '--nb-cores=3D1 --rxq=3D2 --txq=3D2' + dmathr =3D [512, 4096] + self.get_cbdma_ports_info_and_bind_to_dpdk(used_cbdma_num) + self.dut.restore_interfaces() + # launch vhost, Check the cbdma threshold value for each vhost por= t can be config correct from vhost log + vhost_vdev =3D [f"'eth_vhost0,iface=3Dvhost-net0,queues=3D2,client= =3D1,dmas=3D[txq0@{self.used_cbdma[0]};txq1@{self.used_cbdma[1]}],dmathr=3D= {dmathr[0]}'", \ + f"'eth_vhost1,iface=3Dvhost-net1,queues=3D2,client=3D1,dmas=3D= [txq0@{self.used_cbdma[2]};txq1@{self.used_cbdma[3]}],dmathr=3D{dmathr[1]}'= "] + virtio_dev0 =3D f"net_virtio_user0,mac=3D00:01:02:03:04:05,path=3D= ./vhost-net0,queues=3D2,server=3D1,packed_vq=3D0,mrg_rxbuf=3D1,in_order=3D0= ,queue_size=3D4096" + virtio_dev1 =3D f"net_virtio_user1,mac=3D00:01:02:03:04:05,path=3D= ./vhost-net1,queues=3D2,server=3D1,packed_vq=3D0,mrg_rxbuf=3D1,in_order=3D0= ,queue_size=3D4096" + vdev_params =3D '{} --vdev {}'.format(vhost_vdev[0], vhost_vdev[1]) + self.pmdout_vhost_user.start_testpmd(cores=3Dself.cores[0:2], para= m=3Dparams, vdevs=3D[vdev_params], ports=3D[], prefix=3D"vhost", fixed_pref= ix=3DTrue) + self.vhost_user.send_expect('start', 'testpmd> ', 120) + self.launch_testpmd_as_virtio_user1(params, self.cores[2:4], dev= =3Dvirtio_dev1) + self.launch_testpmd_as_virtio_user(params, self.cores[4:6], dev=3D= virtio_dev0) + # Check the cbdma threshold value for each vhost port can be confi= g correct from vhost log + # dma parameters: vid-1,qid0,dma0,threshold:1024 + out =3D self.vhost_user.get_session_before(timeout=3D2) + self.vhost_user.send_expect("quit", "# ") + self.virtio_user.send_expect("quit", "# ") + self.virtio_user1.send_expect("quit", "# ") + pattern =3D re.compile(r'dma parameters: vid\S+,qid\d+,dma\d+,thre= shold:\d+') + return_param =3D re.findall(pattern, out) + check_param =3D ['dma parameters: vid0,qid0,dma{},threshold:{}'.fo= rmat(self.used_cbdma[0][-1:], dmathr[0]), + 'dma parameters: vid0,qid2,dma{},threshold:{}'.form= at(self.used_cbdma[1][-1:], dmathr[0]), + 'dma parameters: vid1,qid0,dma{},threshold:{}'.form= at(self.used_cbdma[2][-1:], dmathr[1]), + 'dma parameters: vid1,qid2,dma{},threshold:{}'.form= at(self.used_cbdma[3][-1:], dmathr[1])] + for return_item in return_param: + self.verify(return_item in check_param, "CBDMA threshold value= check failed, return value:{}, Not in check_param: {}".format(return_item,= check_param)) =20 @staticmethod def vhost_or_virtio_set_one_queue(session): - session.send_expect('start', 'testpmd> ', 120) session.send_expect('stop', 'testpmd> ', 120) session.send_expect('port stop all', 'testpmd> ', 120) session.send_expect('port config all rxq 1', 'testpmd> ', 120) + session.send_expect('port config all txq 1', 'testpmd> ', 120) session.send_expect('port start all', 'testpmd> ', 120) session.send_expect('start', 'testpmd> ', 120) + session.send_expect('show port info all', 'testpmd> ', 30) + session.send_expect('show port stats all', 'testpmd> ', 120) time.sleep(5) =20 @property @@ -292,47 +428,171 @@ class TestVirTioVhostCbdma(TestCase): check_dict[size] =3D round(speed * linerate[size], 2) return check_dict =20 - def send_and_verify(self, mode, multiple_queue=3DTrue): + def send_and_verify(self, mode, multiple_queue=3DTrue, queue_list=3D[]= ): """ Send packet with packet generator and verify """ + self.throughput[mode] =3D dict() for frame_size in self.frame_sizes: + self.throughput[mode][frame_size] =3D dict() + payload_size =3D frame_size - self.headers_size - tgen_input =3D [] - rx_port =3D self.tester.get_local_port(self.dut_ports[0]) - tx_port =3D self.tester.get_local_port(self.dut_ports[0]) - ip_src =3D 'src=3DRandIP()' + tgenInput =3D [] + port =3D self.tester.get_local_port(self.dut_ports[0]) + + fields_config =3D {'ip': {'src': {'action': 'random'},},} if not multiple_queue: - ip_src =3D "" + fields_config =3D None + + pkt1 =3D Packet() + pkt1.assign_layers(['ether', 'ipv4', 'raw']) + pkt1.config_layers([('ether', {'dst': '%s' % self.virtio_mac})= , ('ipv4', {'src': '1.1.1.1'}), + ('raw', {'payload': ['01'] * int('%d' % pa= yload_size)})]) =20 - pacp =3D 'wrpcap("%s/vhost.pcap", [Ether(dst=3D"%s")/IP(%s)/("= X"*%d)])' \ - % (self.out_path, self.virtio_mac, ip_src, payload_size) - self.tester.scapy_append(pacp) - tgen_input.append((tx_port, rx_port, "%s/vhost.pcap" % self.ou= t_path)) + pkt1.save_pcapfile(self.tester, "%s/multiqueuerandomip_%s.pcap= " % (self.out_path, frame_size)) + tgenInput.append((port, port, "%s/multiqueuerandomip_%s.pcap" = % (self.out_path, frame_size))) =20 - self.tester.scapy_execute() self.tester.pktgen.clear_streams() - streams =3D self.pktgen_helper.prepare_stream_from_tginput(tge= n_input, 100, - None,= self.tester.pktgen) + streams =3D self.pktgen_helper.prepare_stream_from_tginput(tge= nInput, 100, fields_config, self.tester.pktgen) trans_options =3D {'delay': 5, 'duration': 20} _, pps =3D self.tester.pktgen.measure_throughput(stream_ids=3D= streams, options=3Dtrans_options) + Mpps =3D pps / 1000000.0 self.verify(Mpps > 0, "%s can not receive packets of frame size %d" % (s= elf.running_case, frame_size)) throughput =3D Mpps * 100 / \ float(self.wirespeed(self.nic, frame_size, 1)) =20 + self.throughput[mode][frame_size][self.nb_desc] =3D Mpps + results_row =3D [frame_size] results_row.append(mode) results_row.append(Mpps) results_row.append(throughput) self.result_table_add(results_row) =20 + if queue_list: + # check RX/TX can work normally in each queues + self.check_packets_of_each_queue(queue_list=3Dqueue_list) + + def handle_expected(self, mode_list): + """ + Update expected numbers to configurate file: conf/$suite_name.cfg + """ + if load_global_setting(UPDATE_EXPECTED) =3D=3D "yes": + for mode in mode_list: + for frame_size in self.test_parameters.keys(): + for nb_desc in self.test_parameters[frame_size]: + self.expected_throughput[mode][frame_size][nb_desc= ] =3D round( + self.throughput[mode][frame_size][nb_desc], 3) + + def handle_results(self, mode_list): + """ + results handled process: + 1, save to self.test_results + table_header =3D ['Frame', 'Mode/RXD-TXD', 'Mpps', '% linerate= ', 'nb_desc', 'Expected Throughput', 'Throughput Difference'] + ret_datas =3D {1024: {'Frame': 64, 'Mode/RXD-TXD': 'dynamic_qu= eue2', 'Mpps': '7.537 Mpps', '% linerate': '12.662%', + 'nb_desc': 1024, 'Expected Throughput': '7.537 Mpp= s', 'Throughput Difference': '-0.000 Mpps'}} + self.test_result =3D {'dynamic_queue2': {64: {1024: {'Frame': = 64, 'Mode/RXD-TXD': 'dynamic_queue2', 'Mpps': '7.537 Mpps', + '% linerate': '12.662%', 'nb_desc': 1024, 'Expected Throug= hput': '7.537 Mpps', 'Throughput Difference': '-0.000 Mpps'}}}} + 2, create test results table + 3, save to json file for Open Lab + """ + header =3D self.table_header + header.append("nb_desc") + header.append("Expected Throughput") + header.append("Throughput Difference") + + for mode in mode_list: + self.test_result[mode] =3D dict() + for frame_size in self.test_parameters.keys(): + wirespeed =3D self.wirespeed(self.nic, frame_size, self.nu= mber_of_ports) + ret_datas =3D {} + for nb_desc in self.test_parameters[frame_size]: + ret_data =3D {} + ret_data[header[0]] =3D frame_size + ret_data[header[1]] =3D mode + ret_data[header[2]] =3D "{:.3f} Mpps".format( + self.throughput[mode][frame_size][nb_desc]) + ret_data[header[3]] =3D "{:.3f}%".format( + self.throughput[mode][frame_size][nb_desc] * 100 /= wirespeed) + ret_data[header[4]] =3D nb_desc + ret_data[header[5]] =3D "{:.3f} Mpps".format( + self.expected_throughput[mode][frame_size][nb_desc= ]) + ret_data[header[6]] =3D "{:.3f} Mpps".format( + self.throughput[mode][frame_size][nb_desc] - + self.expected_throughput[mode][frame_size][nb_desc= ]) + ret_datas[nb_desc] =3D deepcopy(ret_data) + self.test_result[mode][frame_size] =3D deepcopy(ret_datas) + # Create test results table + self.result_table_create(header) + for mode in mode_list: + for frame_size in self.test_parameters.keys(): + for nb_desc in self.test_parameters[frame_size]: + table_row =3D list() + for i in range(len(header)): + table_row.append( + self.test_result[mode][frame_size][nb_desc][he= ader[i]]) + self.result_table_add(table_row) + + # present test results to screen + self.result_table_print() + # save test results as a file + if self.save_result_flag: + self.save_result(self.test_result, mode_list) + + def save_result(self, data, mode_list): + """ + Saves the test results as a separated file named with + self.nic+_perf_virtio_user_pvp.json in output folder + if self.save_result_flag is True + """ + case_name =3D self.running_case + self.json_obj[case_name] =3D list() + status_result =3D [] + + for mode in mode_list: + for frame_size in self.test_parameters.keys(): + for nb_desc in self.test_parameters[frame_size]: + row_in =3D self.test_result[mode][frame_size][nb_desc] + row_dict0 =3D dict() + row_dict0['performance'] =3D list() + row_dict0['parameters'] =3D list() + row_dict0['parameters'] =3D list() + result_throughput =3D float(row_in['Mpps'].split()[0]) + expected_throughput =3D float(row_in['Expected Through= put'].split()[0]) + # delta value and accepted tolerance in percentage + delta =3D result_throughput - expected_throughput + gap =3D expected_throughput * -self.gap * 0.01 + delta =3D float(delta) + gap =3D float(gap) + self.logger.info("Accept tolerance are (Mpps) %f" % ga= p) + self.logger.info("Throughput Difference are (Mpps) %f"= % delta) + if result_throughput > expected_throughput + gap: + row_dict0['status'] =3D 'PASS' + else: + row_dict0['status'] =3D 'FAIL' + row_dict1 =3D dict(name=3D"Throughput", value=3Dresult= _throughput, unit=3D"Mpps", delta=3Ddelta) + row_dict2 =3D dict(name=3D"Txd/Rxd", value=3Drow_in["M= ode/RXD-TXD"], unit=3D"descriptor") + row_dict3 =3D dict(name=3D"frame_size", value=3Drow_in= ["Frame"], unit=3D"bytes") + row_dict0['performance'].append(row_dict1) + row_dict0['parameters'].append(row_dict2) + row_dict0['parameters'].append(row_dict3) + self.json_obj[case_name].append(row_dict0) + status_result.append(row_dict0['status']) + + with open(os.path.join(rst.path2Result, + '{0:s}_{1}.json'.format( + self.nic, self.suite_name)), 'w') as fp: + json.dump(self.json_obj, fp) + self.verify("FAIL" not in status_result, "Exceeded Gap") + def tear_down(self): """ Run after each test case. Clear qemu and testpmd to avoid blocking the following TCs """ + self.dut.send_expect("killall -I %s" % self.testpmd_name, '#', 20) self.bind_cbdma_device_to_kernel() self.bind_nic_driver(self.dut_ports) =20 @@ -344,4 +604,5 @@ class TestVirTioVhostCbdma(TestCase): self.bind_nic_driver(self.dut_ports, self.drivername) self.dut.close_session(self.vhost_user) self.dut.close_session(self.virtio_user) - + self.dut.close_session(self.virtio_user1) + self.dut.kill_all() --=20 2.7.4