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 278C9A0613 for ; Thu, 26 Sep 2019 09:06:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 091334C9D; Thu, 26 Sep 2019 09:06:34 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 18D8D4C8E for ; Thu, 26 Sep 2019 09:06:30 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2019 00:06:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,551,1559545200"; d="scan'208";a="340664438" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 26 Sep 2019 00:06:29 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 26 Sep 2019 00:06:28 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.92]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0439.000; Thu, 26 Sep 2019 15:06:27 +0800 From: "Ma, LihongX" To: "Zeng, XiaoxiaoX" , "dts@dpdk.org" CC: "Zeng, XiaoxiaoX" Thread-Topic: [dts] [PATCH V1.2] tests/sriov_kvm:complete case and fix bugs Thread-Index: AQHVc2UPVLabqkGRK0+ZlRQF0JmzWac9g4cQ Date: Thu, 26 Sep 2019 07:06:26 +0000 Message-ID: References: <20190925174918.19030-1-xiaoxiaox.zeng@intel.com> In-Reply-To: <20190925174918.19030-1-xiaoxiaox.zeng@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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.2] tests/sriov_kvm:complete case and fix bugs 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" Hi, xiaoxiao About the function setup_two_vm_common_prerequisite, the command 'set fwd = xx' , 'start' have many times, I think you can reduce it. If you have reset the all the rule evn on tear_down, so you can ignore the = reset_port_all_mirror_rule in cases. And the port id in tear_down, I think you can not define the local value of= it, it should a data member of the class to identify the port. And if you can define the self.setup_2vm_prerequisite_flag =3D 0 in the tea= r_down , the judge in the setup_two_vm_common_prerequisite is useless. -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xiaoxiao Zeng Sent: Thursday, September 26, 2019 1:49 AM To: dts@dpdk.org Cc: Zeng, XiaoxiaoX Subject: [dts] [PATCH V1.2] tests/sriov_kvm:complete case and fix bugs *.complete cases according to sriov_kvm_test_plan. *.expand setup_two_vm_common_prerequisite() to suit different fwd mode. *.add try...except to avoid env can't reset when case failed. *.add reset pf mirror rule in tear_down(). Signed-off-by: Xiaoxiao Zeng --- tests/TestSuite_sriov_kvm.py | 368 ++++++++++++++++++++++------------- 1 file changed, 238 insertions(+), 130 deletions(-) diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py in= dex 3518f8f..b7be21c 100644 --- a/tests/TestSuite_sriov_kvm.py +++ b/tests/TestSuite_sriov_kvm.py @@ -11,6 +11,7 @@ Test userland 10Gb PMD. import re import pdb import time +import random =20 from virt_common import VM from test_case import TestCase @@ -622,22 +623,32 @@ class TestSriovKvm(TestCase): for rule_id in self.port_mirror_ref[port][:]: self.reset_port_mirror_rule(port, rule_id) =20 - def setup_two_vm_common_prerequisite(self): - self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') - self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) - self.vm0_testpmd.start_testpmd(VM_CORES_MASK) - self.vm0_testpmd.execute_cmd('set fwd rxonly') - self.vm0_testpmd.execute_cmd('set promisc all off') - self.vm0_testpmd.execute_cmd('start') + def setup_two_vm_common_prerequisite(self, fwd0=3D"rxonly", fwd1=3D"ma= c"): =20 - self.vm1_dut_ports =3D self.vm_dut_1.get_ports('any') - self.vm1_testpmd =3D PmdOutput(self.vm_dut_1) - self.vm1_testpmd.start_testpmd(VM_CORES_MASK) - self.vm1_testpmd.execute_cmd('set fwd mac') - self.vm1_testpmd.execute_cmd('set promisc all off') - self.vm1_testpmd.execute_cmd('start') + if self.setup_2vm_prerequisite_flag =3D=3D 1: + self.vm0_testpmd.execute_cmd('stop') + self.vm0_testpmd.execute_cmd('set fwd %s' % fwd0) + self.vm0_testpmd.execute_cmd('start') =20 - self.setup_2vm_prerequisite_flag =3D 1 + self.vm1_testpmd.execute_cmd('stop') + self.vm1_testpmd.execute_cmd('set fwd %s' % fwd1) + self.vm1_testpmd.execute_cmd('start') + else: + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set fwd %s' % fwd0) + self.vm0_testpmd.execute_cmd('set promisc all off') + self.vm0_testpmd.execute_cmd('start') + + self.vm1_dut_ports =3D self.vm_dut_1.get_ports('any') + self.vm1_testpmd =3D PmdOutput(self.vm_dut_1) + self.vm1_testpmd.start_testpmd(VM_CORES_MASK) + self.vm1_testpmd.execute_cmd('set fwd %s' % fwd1) + self.vm1_testpmd.execute_cmd('set promisc all off') + self.vm1_testpmd.execute_cmd('start') + + self.setup_2vm_prerequisite_flag =3D 1 =20 def destroy_two_vm_common_prerequisite(self): self.vm0_testpmd =3D None @@ -713,78 +724,154 @@ class TestSriovKvm(TestCase): ret_stats[key] =3D end_stats[key] - start_stats[key] return ret_stats =20 - def test_two_vms_pool_mirror(self): + def test_two_vms_pool_up_mirrors(self): + """ + Test Case2: Mirror Traffic between 2VMs with Pool up mirroring + """ port_id_0 =3D 0 packet_num =3D 10 =20 + # set Pool up mirror rule rule_id =3D self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 o= n') + + # get vm1 port stats vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send 10 packets self.send_packet( self.vm_dut_0, self.vm0_dut_ports, port_id_0, count=3Dpacket_n= um) + + # get vm1 port stats vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) =20 - self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and - vm1_ret_stats['TX-packets'] =3D=3D packet_num, - "Pool mirror failed between VM0 and VM1!") + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and = vm1_ret_stats['TX-packets'] =3D=3D packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Pool mirror failed between VM0 and VM1!") =20 - self.reset_port_mirror_rule(port_id_0, rule_id) + def test_two_vms_pool_down_mirrors(self): + """ + Test Case3: Mirror Traffic between 2VMs with Pool down mirroring + """ + port_id_0 =3D 0 + mirror_name =3D "pool-mirror-down" + packet_num =3D 32 + + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0=3D"mac",=20 + fwd1=3D"rxonly") + + # set Pool down mirror rule + rule_id =3D self.set_port_mirror_rule(port_id_0, mirror_name,=20 + '0x1 dst-pool 1 on') + + # get vm port stats + vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets + self.vm0_testpmd.execute_cmd('stop') + self.vm0_testpmd.execute_cmd('start tx_first') + + # get vm port stats + vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # verify vm1 receive packets + vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_st= ats) + vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['= TX-packets'] and vm1_ret_stats['RX-packets'] =3D=3D packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Pool mirror failed between VM0 and VM1!") =20 def test_two_vms_uplink_mirror(self): + """ + Test Case4: Mirror Traffic between 2VMs with Uplink mirroring + """ port_id_0 =3D 0 packet_num =3D 10 =20 + # set uplink mirror rule rule_id =3D self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on'= ) + + # get vm1 port stats vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets self.send_packet( self.vm_dut_0, self.vm0_dut_ports, port_id_0, count=3Dpacket_n= um) + + # get vm1 port stats vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) - - self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and - vm1_ret_stats['TX-packets'] =3D=3D packet_num, - "Uplink mirror failed between VM0 and VM1!") - - self.reset_port_mirror_rule(port_id_0, rule_id) + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and = vm1_ret_stats['TX-packets'] =3D=3D packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Uplink mirror failed between VM0 and VM1!") =20 def test_two_vms_downlink_mirror(self): - self.vm0_testpmd.execute_cmd('stop') - self.vm1_testpmd.execute_cmd('stop') - + """ + Test Case5: Mirror Traffic between 2VMs with Downlink mirroring + """ port_id_0 =3D 0 + packet_num =3D 32 =20 + # set downlink mirror rule rule_id =3D self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 o= n') =20 - self.vm1_testpmd.execute_cmd('set fwd rxonly') - self.vm1_testpmd.execute_cmd('start') - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0=3D"mac",=20 + fwd1=3D"rxonly") + + # get vms port stats vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets + self.vm0_testpmd.execute_cmd('stop') self.vm0_testpmd.execute_cmd('start tx_first') + + # get vms port stats vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_st= ats) vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) - - self.verify(self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-pack= ets'], vm0_ret_stats['TX-packets']), - "Downlink mirror failed between VM0 and VM1!") - - self.reset_port_mirror_rule(port_id_0, rule_id) + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['= TX-packets'] and vm1_ret_stats['RX-packets'] =3D=3D packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Pool mirror failed between VM0 and VM1!") =20 def test_two_vms_vlan_mirror(self): - self.vm1_testpmd.execute_cmd('vlan set strip on 0') + """ + Test Case6: Mirror Traffic between 2VMs with Vlan mirroring + """ port_id_0 =3D 0 - vlan_id =3D 0 + vlan_id =3D random.randint(1, 4095) vf_mask =3D '0x1' packet_num =3D 10 =20 - self.host_testpmd.execute_cmd( - 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)= ) - rule_id =3D self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 on'= ) + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0=3D"mac",=20 + fwd1=3D"rxonly") + + # add rx vlan on VF0 + self.host_testpmd.execute_cmd('rx_vlan add %d port %d vf %s' %=20 + (vlan_id, port_id_0, vf_mask)) =20 + # set vlan mirror rule + rule_id =3D self.set_port_vlan_mirror(port_id_0, '%d dst-pool 1=20 + on' % vlan_id) + + # get vm port stats vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets ether_ip =3D {} ether_ip['vlan'] =3D {'vlan': '%d' % vlan_id} self.send_packet( @@ -793,16 +880,23 @@ class TestSriovKvm(TestCase): port_id_0, count=3Dpacket_num, **ether_ip) + + # get vm port stats vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num * 2,= "failed") + except: + # reset env. + self.host_testpmd.execute_cmd('rx_vlan rm %d port %d vf %s' % = (vlan_id, port_id_0, vf_mask)) + self.reset_port_all_mirror_rule(port_id_0) + self.host_testpmd.execute_cmd('rx_vlan rm %d port %d vf %s' % = (vlan_id, port_id_0, vf_mask)) + raise ("Vlan mirror failed between VM0 and VM1!") =20 - self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and - vm1_ret_stats['TX-packets'] =3D=3D packet_num, - "Vlan mirror failed between VM0 and VM1!") - self.host_testpmd.execute_cmd( - 'rx_vlan rm %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)) - self.reset_port_mirror_rule(port_id_0, rule_id) + # reset env. + self.host_testpmd.execute_cmd('rx_vlan rm %d port %d vf %s' %=20 + (vlan_id, port_id_0, vf_mask)) =20 def test_two_vms_vlan_and_pool_mirror(self): self.vm0_testpmd.execute_cmd('vlan set strip on 0') @@ -852,133 +9= 46,144 @@ class TestSriovKvm(TestCase): self.reset_port_all_mirror_rule(port_id_0) =20 def test_two_vms_uplink_and_downlink_mirror(self): - self.vm0_testpmd.execute_cmd('stop') - self.vm1_testpmd.execute_cmd('stop') - + """ + Test Case7: Mirror Traffic between 2VMs with up link mirroring & d= own link mirroring + """ port_id_0 =3D 0 packet_num =3D 10 =20 + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0=3D"mac",=20 + fwd1=3D"rxonly") + + # set mirror rule self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on') self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') =20 - self.vm1_testpmd.execute_cmd('set fwd rxonly') - self.vm1_testpmd.execute_cmd('start') + # get vm1 port stats vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) - vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) - self.vm0_testpmd.execute_cmd('start tx_first') - vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) - - vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_st= ats) - vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) =20 - self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['TX-p= ackets'], - "Downlink mirror failed between VM0 and VM1 " + - "when set uplink and downlink mirror!") + # send packets + self.send_packet(self.vm_dut_0, self.vm0_dut_ports, port_id_0,=20 + count=3Dpacket_num) =20 - self.vm0_testpmd.execute_cmd('stop') - self.vm0_testpmd.execute_cmd('set fwd mac') - self.vm0_testpmd.execute_cmd('start') - - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) - self.send_packet( - self.vm_dut_0, - self.vm0_dut_ports, - port_id_0, - count=3Dpacket_num) + # get vm1 port stats vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) - - self.verify(vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, - "Uplink and down link mirror failed between VM0 and VM= 1 " + - "when set uplink and downlink mirror!") - - self.reset_port_all_mirror_rule(port_id_0) + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num * 2,= "failed") + except: + self.reset_port_all_mirror_rule(port_id_0) + raise ("Set uplink and downlink mirror failed!") =20 def test_two_vms_vlan_and_pool_and_uplink_and_downlink(self): - self.vm0_testpmd.execute_cmd('vlan set strip on 0') - self.vm1_testpmd.execute_cmd('vlan set strip on 0') - self.vm0_testpmd.execute_cmd('stop') - self.vm1_testpmd.execute_cmd('stop') - + """ + Test Case8: Mirror Traffic between 2VMs with Vlan & with up link m= irroring & down link mirroring + """ port_id_0 =3D 0 - vlan_id =3D 3 + vlan_id =3D random.randint(1, 4095) vf_mask =3D '0x2' packet_num =3D 1 + fail_log =3D "Vlan and downlink mirror failed between VM0 and VM1 = when set vlan, pool, uplink and downlink mirror!" + + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0=3D"mac",=20 + fwd1=3D"rxonly") =20 + # set mirror rule + self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on') self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on') - self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') - self.host_testpmd.execute_cmd("rx_vlan add %d port %d vf %s" % - (vlan_id, port_id_0, vf_mask)) + self.host_testpmd.execute_cmd("rx_vlan add %d port %d vf %s" %=20 + (vlan_id, port_id_0, vf_mask)) self.set_port_vlan_mirror(port_id_0, '%d dst-pool 0 on' % vlan_id) - self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on') =20 - self.vm1_testpmd.execute_cmd('set fwd rxonly') - self.vm1_testpmd.execute_cmd('start') - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) - vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) - self.vm0_testpmd.execute_cmd('start tx_first') - vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + if self.nic.startswith('niantic'): + self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') =20 - vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_st= ats) - vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) + # get vm port stats + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) =20 - self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['TX-p= ackets'], - "Downlink mirror failed between VM0 and VM1 " + - "when set vlan, pool, uplink and downlink mirror!") + # send packets + self.vm0_testpmd.execute_cmd('stop') + self.vm0_testpmd.execute_cmd('set fwd rxonly') + self.vm0_testpmd.execute_cmd('start tx_first') =20 - self.vm0_testpmd.execute_cmd('stop') - self.vm0_testpmd.execute_cmd('set fwd mac') - self.vm0_testpmd.execute_cmd('start') + # get vm port stats + vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # verify vm1 receive packets + vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_en= d_stats) + vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_en= d_stats) + try: + self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_sta= ts['TX-packets'], "failed") + except: + self.reset_port_all_mirror_rule(port_id_0) + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s= " % (vlan_id, port_id_0, vf_mask)) + raise (fail_log) + + # get vm port stats vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets + ether_ip =3D {} + ether_ip['vlan'] =3D {'vlan': '%d' % vlan_id} self.send_packet( - self.vm_dut_0, - self.vm0_dut_ports, + self.vm_dut_1, + self.vm1_dut_ports, port_id_0, - count=3Dpacket_num) + count=3Dpacket_num, + **ether_ip) + # get vm port stats vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_st= ats) vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) =20 - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX-pack= ets'], packet_num) and - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-pack= ets'], packet_num) and - self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-pack= ets'], 2 * packet_num), - "Uplink and downlink mirror failed between VM0 and VM1= " + - "when set vlan, pool, uplink and downlink mirror!") - - self.vm0_testpmd.execute_cmd('stop') - self.vm0_testpmd.execute_cmd('set fwd mac') - self.vm0_testpmd.execute_cmd('start') + if self.nic.startswith('niantic'): + try: + self.verify(vm0_ret_stats['RX-packets'] =3D=3D packet_num = and vm1_ret_stats['RX-packets'] =3D=3D packet_num, "failed") + except: + self.reset_port_all_mirror_rule(port_id_0) + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s= " % (vlan_id, port_id_0, vf_mask)) + raise (fail_log) + else: + try: + self.verify(vm0_ret_stats['RX-packets'] =3D=3D packet_num = and vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, "failed") + except: + self.reset_port_all_mirror_rule(port_id_0) + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s= " % (vlan_id, port_id_0, vf_mask)) + raise (fail_log) =20 - ether_ip =3D {} - ether_ip['vlan'] =3D {'vlan': '%d' % vlan_id} - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + # get vm port stats vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) + # send packets self.send_packet( - self.vm_dut_1, - self.vm1_dut_ports, + self.vm_dut_0, + self.vm0_dut_ports, port_id_0, - count=3Dpacket_num, - **ether_ip) + count=3Dpacket_num) + # get vm port stats vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) =20 + # verify vm1 receive packets vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_st= ats) vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_st= ats) =20 - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX-pack= ets'], packet_num) and - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-pack= ets'], packet_num) and - vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, - "Vlan and downlink mirror failed between VM0 and VM1 "= + - "when set vlan, pool, uplink and downlink mirror!") - self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" % - (vlan_id, port_id_0, vf_mask)) - self.reset_port_all_mirror_rule(port_id_0) + try: + self.verify(vm0_ret_stats['RX-packets'] =3D=3D packet_num and = vm0_ret_stats['TX-packets'] =3D=3D packet_num and + vm1_ret_stats['RX-packets'] =3D=3D packet_num, "fa= iled") + except: + self.reset_port_all_mirror_rule(port_id_0) + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" % = (vlan_id, port_id_0, vf_mask)) + raise (fail_log) + + # reset env. + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" %=20 + (vlan_id, port_id_0, vf_mask)) =20 def test_two_vms_add_multi_exact_mac_on_vf(self): port_id_0 =3D 0 @@ -1261,8 +1366,11 @@ class TestSriovKvm(TestCase): error, "Execute command '%s' successfully, it should be fa= iled!" % command) =20 def tear_down(self): + port_id_0 =3D 0 self.vm0_testpmd.execute_cmd('quit', '# ') self.vm1_testpmd.execute_cmd('quit', '# ') + self.reset_port_all_mirror_rule(port_id_0) + self.setup_2vm_prerequisite_flag =3D 0 time.sleep(1) =20 def tear_down_all(self): -- 2.17.0