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 CEB5CA0613 for ; Wed, 25 Sep 2019 07:49:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA48C2C57; Wed, 25 Sep 2019 07:49:26 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 011162C37 for ; Wed, 25 Sep 2019 07:49:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Sep 2019 22:49:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,546,1559545200"; d="scan'208";a="201141103" Received: from unknown (HELO dpdk-zengxx-tester.localdomain) ([10.240.176.145]) by orsmga002.jf.intel.com with ESMTP; 24 Sep 2019 22:49:22 -0700 From: Xiaoxiao Zeng To: dts@dpdk.org Cc: Xiaoxiao Zeng Date: Thu, 26 Sep 2019 01:49:18 +0800 Message-Id: <20190925174918.19030-1-xiaoxiaox.zeng@intel.com> X-Mailer: git-send-email 2.17.0 Subject: [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" *.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 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 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) - def setup_two_vm_common_prerequisite(self): - self.vm0_dut_ports = self.vm_dut_0.get_ports('any') - self.vm0_testpmd = 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="rxonly", fwd1="mac"): - self.vm1_dut_ports = self.vm_dut_1.get_ports('any') - self.vm1_testpmd = 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 == 1: + self.vm0_testpmd.execute_cmd('stop') + self.vm0_testpmd.execute_cmd('set fwd %s' % fwd0) + self.vm0_testpmd.execute_cmd('start') - self.setup_2vm_prerequisite_flag = 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 = self.vm_dut_0.get_ports('any') + self.vm0_testpmd = 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 = self.vm_dut_1.get_ports('any') + self.vm1_testpmd = 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 = 1 def destroy_two_vm_common_prerequisite(self): self.vm0_testpmd = None @@ -713,78 +724,154 @@ class TestSriovKvm(TestCase): ret_stats[key] = end_stats[key] - start_stats[key] return ret_stats - 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 = 0 packet_num = 10 + # set Pool up mirror rule rule_id = self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on') + + # get vm1 port stats vm1_start_stats = 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=packet_num) + + # get vm1 port stats vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - self.verify(vm1_ret_stats['RX-packets'] == packet_num and - vm1_ret_stats['TX-packets'] == packet_num, - "Pool mirror failed between VM0 and VM1!") + try: + self.verify(vm1_ret_stats['RX-packets'] == packet_num and vm1_ret_stats['TX-packets'] == packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Pool mirror failed between VM0 and VM1!") - 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 = 0 + mirror_name = "pool-mirror-down" + packet_num = 32 + + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0="mac", fwd1="rxonly") + + # set Pool down mirror rule + rule_id = self.set_port_mirror_rule(port_id_0, mirror_name, '0x1 dst-pool 1 on') + + # get vm port stats + vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats = 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 = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + + # verify vm1 receive packets + vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) + vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) + try: + self.verify(vm1_ret_stats['RX-packets'] == vm0_ret_stats['TX-packets'] and vm1_ret_stats['RX-packets'] == packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Pool mirror failed between VM0 and VM1!") def test_two_vms_uplink_mirror(self): + """ + Test Case4: Mirror Traffic between 2VMs with Uplink mirroring + """ port_id_0 = 0 packet_num = 10 + # set uplink mirror rule rule_id = self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') + + # get vm1 port stats vm1_start_stats = 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=packet_num) + + # get vm1 port stats vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - - self.verify(vm1_ret_stats['RX-packets'] == packet_num and - vm1_ret_stats['TX-packets'] == 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'] == packet_num and vm1_ret_stats['TX-packets'] == packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Uplink mirror failed between VM0 and VM1!") 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 = 0 + packet_num = 32 + # set downlink mirror rule rule_id = self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on') - self.vm1_testpmd.execute_cmd('set fwd rxonly') - self.vm1_testpmd.execute_cmd('start') - vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0="mac", fwd1="rxonly") + + # get vms port stats vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats = 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 = self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - - self.verify(self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-packets'], 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'] == vm0_ret_stats['TX-packets'] and vm1_ret_stats['RX-packets'] == packet_num, "failed") + except: + self.reset_port_mirror_rule(port_id_0, rule_id) + raise ("Pool mirror failed between VM0 and VM1!") 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 = 0 - vlan_id = 0 + vlan_id = random.randint(1, 4095) vf_mask = '0x1' packet_num = 10 - self.host_testpmd.execute_cmd( - 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)) - rule_id = 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="mac", fwd1="rxonly") + + # 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)) + # set vlan mirror rule + rule_id = self.set_port_vlan_mirror(port_id_0, '%d dst-pool 1 on' % vlan_id) + + # get vm port stats vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets ether_ip = {} ether_ip['vlan'] = {'vlan': '%d' % vlan_id} self.send_packet( @@ -793,16 +880,23 @@ class TestSriovKvm(TestCase): port_id_0, count=packet_num, **ether_ip) + + # get vm port stats vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) + try: + self.verify(vm1_ret_stats['RX-packets'] == 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!") - self.verify(vm1_ret_stats['RX-packets'] == packet_num and - vm1_ret_stats['TX-packets'] == 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' % (vlan_id, port_id_0, vf_mask)) 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) 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 = 0 packet_num = 10 + # set up common 2VM prerequisites + self.setup_two_vm_common_prerequisite(fwd0="mac", fwd1="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') - self.vm1_testpmd.execute_cmd('set fwd rxonly') - self.vm1_testpmd.execute_cmd('start') + # get vm1 port stats vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - self.vm0_testpmd.execute_cmd('start tx_first') - vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - - vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) - vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - self.verify(vm1_ret_stats['RX-packets'] == 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, count=packet_num) - self.vm0_testpmd.execute_cmd('stop') - self.vm0_testpmd.execute_cmd('set fwd mac') - self.vm0_testpmd.execute_cmd('start') - - vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - self.send_packet( - self.vm_dut_0, - self.vm0_dut_ports, - port_id_0, - count=packet_num) + # get vm1 port stats vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - - self.verify(vm1_ret_stats['RX-packets'] == 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'] == packet_num * 2, "failed") + except: + self.reset_port_all_mirror_rule(port_id_0) + raise ("Set uplink and downlink mirror failed!") 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 = 0 - vlan_id = 3 + vlan_id = random.randint(1, 4095) vf_mask = '0x2' packet_num = 1 + fail_log = "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="mac", fwd1="rxonly") + # 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_id) - self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on') - self.vm1_testpmd.execute_cmd('set fwd rxonly') - self.vm1_testpmd.execute_cmd('start') - vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - self.vm0_testpmd.execute_cmd('start tx_first') - vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_end_stats = 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') - vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) - vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) + # get vm port stats + vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - self.verify(vm1_ret_stats['RX-packets'] == 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') - 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 = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + + # verify vm1 receive packets + vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) + vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) + try: + self.verify(vm1_ret_stats['RX-packets'] == vm0_ret_stats['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 = self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + + # send packets + ether_ip = {} + ether_ip['vlan'] = {'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=packet_num) + count=packet_num, + **ether_ip) + # get vm port stats vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX-packets'], packet_num) and - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-packets'], packet_num) and - self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-packets'], 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'] == packet_num and vm1_ret_stats['RX-packets'] == 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'] == packet_num and vm1_ret_stats['RX-packets'] == 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) - ether_ip = {} - ether_ip['vlan'] = {'vlan': '%d' % vlan_id} - vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # get vm port stats vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats = 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=packet_num, - **ether_ip) + count=packet_num) + # get vm port stats vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + # verify vm1 receive packets vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX-packets'], packet_num) and - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-packets'], packet_num) and - vm1_ret_stats['RX-packets'] == 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'] == packet_num and vm0_ret_stats['TX-packets'] == packet_num and + vm1_ret_stats['RX-packets'] == 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" % (vlan_id, port_id_0, vf_mask)) def test_two_vms_add_multi_exact_mac_on_vf(self): port_id_0 = 0 @@ -1261,8 +1366,11 @@ class TestSriovKvm(TestCase): error, "Execute command '%s' successfully, it should be failed!" % command) def tear_down(self): + port_id_0 = 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 = 0 time.sleep(1) def tear_down_all(self): -- 2.17.0