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 E1651A0613 for ; Thu, 26 Sep 2019 04:50:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF6162BCE; Thu, 26 Sep 2019 04:50:31 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id EA5D42BB5 for ; Thu, 26 Sep 2019 04:50:29 +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 fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2019 19:50:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,550,1559545200"; d="scan'208";a="340614765" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 25 Sep 2019 19:50:28 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 25 Sep 2019 19:50:27 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.113]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.32]) with mapi id 14.03.0439.000; Thu, 26 Sep 2019 10:50:26 +0800 From: "Mo, YufengX" 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: AQHVc2UPOipYclPbzkm3JjJO4H13Qac9QzBg Date: Thu, 26 Sep 2019 02:50:25 +0000 Message-ID: References: <20190925174918.19030-1-xiaoxiaox.zeng@intel.com> In-Reply-To: <20190925174918.19030-1-xiaoxiaox.zeng@intel.com> Accept-Language: zh-CN, 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,zeng xiaoxiao Weather test case fail or pass, tear_down will be executed at the end of a = test case. When some your new test cases fail, reset_port_all_mirror_rule will be exec= uted twice. BRs Yufen, Mo > -----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 >=20 > *.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(). >=20 > Signed-off-by: Xiaoxiao Zeng > --- > tests/TestSuite_sriov_kvm.py | 368 ++++++++++++++++++++++------------- > 1 file changed, 238 insertions(+), 130 deletions(-) >=20 > diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py > index 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"= mac"): >=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= on') > + > + # 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= _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_= stats) >=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 an= d 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", fwd1=3D"rxon= ly") > + > + # set Pool down mirror rule > + rule_id =3D self.set_port_mirror_rule(port_id_0, mirror_name, '0= x1 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_= stats) > + vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > + 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 o= n') > + > + # 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= _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_= stats) > - > - 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 an= d 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= 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) > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", fwd1=3D"rxon= ly") > + > + # 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_= stats) > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > - > - self.verify(self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-pa= ckets'], 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_mas= k)) > - rule_id =3D self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 o= n') > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", fwd1=3D"rxon= ly") > + > + # add rx vlan on VF0 > + self.host_testpmd.execute_cmd('rx_vlan add %d port %d vf %s' % (= 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 = 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_= stats) > + 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' % (v= lan_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 +946,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 &= down 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", fwd1=3D"rxon= ly") > + > + # 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_= stats) > - vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['TX= -packets'], > - "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, c= ount=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_= stats) > - > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, > - "Uplink and down link mirror failed between VM0 and = VM1 " + > - "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= mirroring & 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 VM= 1 when set vlan, pool, uplink and downlink mirror!" > + > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", fwd1=3D"rxon= ly") >=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" % (= vlan_id, port_id_0, vf_mask)) > self.set_port_vlan_mirror(port_id_0, '%d dst-pool 0 on' % vlan_i= d) > - 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_= stats) > - vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > + # 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= -packets'], > - "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_= end_stats) > + vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_= end_stats) > + try: > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_s= tats['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_= stats) > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX-pa= ckets'], packet_num) and > - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-pa= ckets'], packet_num) and > - self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-pa= ckets'], 2 * packet_num), > - "Uplink and downlink mirror failed between VM0 and V= M1 " + > - "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_nu= m 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_nu= m 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_= stats) > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX-pa= ckets'], packet_num) and > - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-pa= ckets'], 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 an= d vm0_ret_stats['TX-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) > + > + # reset env. > + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" % (v= lan_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 = failed!" % 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