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 E72EEA0096 for ; Tue, 4 Jun 2019 07:20:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BF9D21B95D; Tue, 4 Jun 2019 07:20:34 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 6AB0D1B94E for ; Tue, 4 Jun 2019 07:20:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 22:20:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,549,1549958400"; d="scan'208";a="181406840" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.240.176.135]) by fmsmga002.fm.intel.com with ESMTP; 03 Jun 2019 22:20:28 -0700 From: "zhang,yan" To: dts@dpdk.org Cc: "zhang,yan" Date: Tue, 4 Jun 2019 13:24:50 +0800 Message-Id: <1559625890-133337-1-git-send-email-yanx.a.zhang@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH V1] tests/TestSuite_vf_kernel:Optimize validation results and scripts 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" 1.Modify the verification result of the case. --Before each case runs, we need to check that the connection state of the corresponding NIC is yes. If no, we need to call the restore_interfaces_linux() method to restore the NIC state to yes, and there is no need to do any other operations. 2.Add code to check NIC status. --Sometimes, ifconfig %s up does not take effect due to the case running too fast, and it needs to wait for a certain period of time. 3.Add time.sleep() to enable tcpdump to start normally. --Sometimes, the tcpdump command requires a certain open time, otherwise the corresponding packet cannot be fetched. 4.Replace the virtual NIC intf0 to intf1. --When all cases run together, it will affect the intf0 NIC required by test_vlan, so replace intf0 to intf1. Signed-off-by: zhang,yan --- tests/TestSuite_vf_kernel.py | 38 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/TestSuite_vf_kernel.py b/tests/TestSuite_vf_kernel.py index f80c9e9..92b1202 100644 --- a/tests/TestSuite_vf_kernel.py +++ b/tests/TestSuite_vf_kernel.py @@ -226,8 +226,16 @@ class TestVfKernel(TestCase): """ for i in range(5): # pf up + vf up -> vf up + start_time = time.time() self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf0, "#") out = self.vm0_dut.send_expect("ethtool %s" % self.vm0_intf0, "#") + while "Link detected: yes" not in out: + end_time = time.time() + if end_time - start_time >= 3: + break + else: + out = self.vm0_dut.send_expect("ethtool %s" % self.vm0_intf0, "#") + time.sleep(1) self.verify("Link detected: yes" in out, "Wrong link status") time.sleep(3) @@ -391,6 +399,7 @@ class TestVfKernel(TestCase): def verify_vm_tcpdump(self, vm_dut, intf, mac, pkt_lens=64, num=1, vlan_id='', param=''): vm_dut.send_expect("tcpdump -i %s %s -e ether src %s" % (intf, param, self.tester_mac), "tcpdump", 10) + time.sleep(2) self.send_packet(mac, pkt_lens, num, vlan_id) out = vm_dut.get_session_output(timeout=10) vm_dut.send_expect("^C", "#", 10) @@ -417,8 +426,8 @@ class TestVfKernel(TestCase): vlan_ids = random.randint(1, 4095) self.dut_testpmd.execute_cmd("vlan set filter on 0") self.dut_testpmd.execute_cmd("vlan set strip on 0") - self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf0, "#") - vm0_vf0_mac = self.vm0_dut.ports_info[0]['port'].get_mac_addr() + self.vm0_dut.send_expect("ifconfig %s up" % self.vm0_intf1, "#") + vm0_vf1_mac = self.vm0_dut.ports_info[1]['port'].get_mac_addr() self.vm0_dut.send_expect("modprobe 8021q", "#") out = self.vm0_dut.send_expect("lsmod |grep 8021q", "#") @@ -426,33 +435,33 @@ class TestVfKernel(TestCase): # Add random vlan id(0~4095) on kernel VF0 self.vm0_dut.send_expect("vconfig add %s %s" % - (self.vm0_intf0, vlan_ids), "#") + (self.vm0_intf1, vlan_ids), "#") out = self.vm0_dut.send_expect("ls /proc/net/vlan/ ", "#") - self.verify("%s.%s" % (self.vm0_intf0, vlan_ids) + self.verify("%s.%s" % (self.vm0_intf1, vlan_ids) in out, "take vlan id failure") # Send packet from tester to VF MAC with not-matching vlan id, check # the packet can't be received at the vlan device # fortville nic need add -p parameter to disable promisc mode wrong_vlan = vlan_ids % 4095 + 1 - self.verify(self.verify_vm_tcpdump(self.vm0_dut, self.vm0_intf0, vm0_vf0_mac, + self.verify(self.verify_vm_tcpdump(self.vm0_dut, self.vm0_intf1, vm0_vf1_mac, vlan_id='%d' % wrong_vlan, param='-p') == False, "received wrong vlan packet") # Send packet from tester to VF MAC with matching vlan id, check the packet can be received at the vlan device. # check_result = self.verify_vm_tcpdump(self.vm0_dut, self.vm0_intf0, self.vm0_vf0_mac, vlan_id='%d' %vlan_ids) check_result = self.verify_vm_tcpdump( - self.vm0_dut, self.vm0_intf0, vm0_vf0_mac, vlan_id='%d' % vlan_ids, param='-p') + self.vm0_dut, self.vm0_intf1, vm0_vf1_mac, vlan_id='%d' % vlan_ids, param='-p') self.verify(check_result, "can't received vlan_id=%d packet" % vlan_ids) # Delete configured vlan device self.vm0_dut.send_expect("vconfig rem %s.%s" % - (self.vm0_intf0, vlan_ids), "#") + (self.vm0_intf1, vlan_ids), "#") out = self.vm0_dut.send_expect("ls /proc/net/vlan/ ", "#") - self.verify("%s.%s" % (self.vm0_intf0, vlan_ids) + self.verify("%s.%s" % (self.vm0_intf1, vlan_ids) not in out, "vlan error") # behavior is different between niantic and fortville ,because of kernel # driver - self.verify(self.verify_vm_tcpdump(self.vm0_dut, self.vm0_intf0, - vm0_vf0_mac, vlan_id='%d' % vlan_ids, param='-p') == False, "delete vlan error") + self.verify(self.verify_vm_tcpdump(self.vm0_dut, self.vm0_intf1, + vm0_vf1_mac, vlan_id='%d' % vlan_ids, param='-p') == False, "delete vlan error") self.dut_testpmd.execute_cmd("vlan set filter off 0") def test_packet_statistic(self): @@ -486,18 +495,15 @@ class TestVfKernel(TestCase): for i in range(5): # down-up get new mac form pf. # because dpdk pf will give an random mac when dpdk pf restart. - session.send_expect("ifconfig %s down" % intf, "#") - out = session.send_expect("ifconfig %s up" % intf, "#") + out = session.send_expect("ethtool %s" % intf, "#") # SIOCSIFFLAGS: Network is down # i think the pf link abnormal - if "Network is down" in out: + if "Link detected: no" in out: print GREEN(out) print GREEN("Try again") session.restore_interfaces_linux() else: - out = session.send_expect("ethtool %s" % intf, "#") - if "Link detected: yes" in out: - return True + return True time.sleep(1) return False -- 2.17.2