From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 602B0A04A5; Wed, 26 Jan 2022 07:52:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5BE4842701; Wed, 26 Jan 2022 07:52:53 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id DD98C4069D for ; Wed, 26 Jan 2022 07:52:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643179972; x=1674715972; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MZz8AKJH2TOm/a9G2USGp0u1quqxHHD7EEO5xFwRBAw=; b=DyRI3XogruKZkotrX2yhM3sb4VFy26u2YI7bkBm98Nm4n9YktgXWFqE4 ev+ZGBzSyfbOWF+FqBraBjoXAcPMQ7cSYebXLiY9aFty83W/JGeaWzlu/ rPMP2YR5PxIzQvOmq036WAJM7Clo51JulTsULzopvK9OY9YF1hXi3pkAZ SDQ6V8WKdEYULukL7X3MJyDpe01YaBKiAngbHb/UwKiD4y1tLvE8Umyy1 +pOO400XJnamrY1y1NG43velUCghZbURwzua+6sVemq+a/yQ0EZTO/Zvn vtL09zdiX0+rmNv5d4c0vInYLIJBSwLKU7GbAPrryKRnQ6T/pOonf/lX/ w==; X-IronPort-AV: E=McAfee;i="6200,9189,10238"; a="309807453" X-IronPort-AV: E=Sophos;i="5.88,317,1635231600"; d="scan'208";a="309807453" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 22:52:51 -0800 X-IronPort-AV: E=Sophos;i="5.88,317,1635231600"; d="scan'208";a="628212732" Received: from unknown (HELO localhost.localdomain) ([10.239.251.226]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 22:52:50 -0800 From: Yu Jiang To: lijuan.tu@intel.com, dts@dpdk.org Cc: Yu Jiang Subject: [dts][PATCH V2 2/2] tests/shutdown_api: wait for interface/link up Date: Wed, 26 Jan 2022 14:52:39 +0000 Message-Id: <20220126145239.2274454-3-yux.jiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126145239.2274454-1-yux.jiang@intel.com> References: <20220126145239.2274454-1-yux.jiang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 1, use new method: is_interface_up/down to replace redundant code, ensure link up/down. 2, add tester's link check before send package. 3, add testpmd's wait_link_status_up to ensure port is up. Signed-off-by: Yu Jiang --- v2: add self.verify for check tester's link up before send package. tests/TestSuite_shutdown_api.py | 42 ++++++++++----------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_api.py index 9f40d232..375918b7 100644 --- a/tests/TestSuite_shutdown_api.py +++ b/tests/TestSuite_shutdown_api.py @@ -105,6 +105,9 @@ class TestShutdownApi(TestCase): if ports is None: ports = self.ports if len(ports) == 1: + # check tester's link status before send pkg + tester_intf = self.tester.get_interface(self.tester.get_local_port(ports[0])) + self.verify(self.tester.is_interface_up(intf=tester_intf), "Wrong link status, should be up") self.send_packet(ports[0], ports[0], pktSize, received, vlan, promisc, allmulti, vlan_strip) return @@ -177,16 +180,14 @@ class TestShutdownApi(TestCase): def check_ports(self, status=True): """ - Check link status of the ports. + Check link status of the ports from tester side. """ for port in self.ports: - out = self.tester.send_expect( - "ethtool %s" % self.tester.get_interface(self.tester.get_local_port(port)), "# ") + tester_intf = self.tester.get_interface(self.tester.get_local_port(port)) if status: - self.verify("Link detected: yes" in out, "Wrong link status") + self.verify(self.tester.is_interface_up(intf=tester_intf), "Wrong link status, should be up") else: - self.verify("Link detected: no" in out, "Wrong link status") - + self.verify(self.tester.is_interface_down(intf=tester_intf), "Wrong link status, should be down") def check_linkspeed_config(self, configs): ret_val = False @@ -206,15 +207,7 @@ class TestShutdownApi(TestCase): def check_vf_link_status(self): self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology=chained') - time.sleep(2) - for i in range(15): - out = self.vm0_testpmd.execute_cmd('show port info 0') - print(out) - if 'Link status: down' in out: - time.sleep(2) - else : - break - self.verify("Link status: up" in out, "VF link down!!!") + self.vm0_testpmd.wait_link_status_up('all') def setup_vm_env(self, driver='default'): """ @@ -266,7 +259,6 @@ class TestShutdownApi(TestCase): self.vm_env_done = True - def destroy_vm_env(self): if getattr(self, 'self.vm0_testpmd', None): self.vm0_testpmd.quit() @@ -289,12 +281,8 @@ class TestShutdownApi(TestCase): if not self.vm_env_done: return - self.vm_env_done = False - - - def test_stop_restart(self): """ Stop and Restar. @@ -308,14 +296,11 @@ class TestShutdownApi(TestCase): self.dut.send_expect("stop", "testpmd> ") self.check_forwarding(received=False) self.dut.send_expect("port stop all", "testpmd> ", 100) - time.sleep(5) if self.nic in ["columbiaville_25g", "columbiaville_100g"]: self.check_ports(status=True) else: self.check_ports(status=False) self.dut.send_expect("port start all", "testpmd> ", 100) - time.sleep(5) - self.check_ports(status=True) self.dut.send_expect("start", "testpmd> ") self.check_forwarding() @@ -477,7 +462,8 @@ class TestShutdownApi(TestCase): config[0], config[1].lower()), "testpmd> ") self.dut.send_expect("set fwd mac", "testpmd>") self.dut.send_expect("port start all", "testpmd> ", 100) - time.sleep(8) # sleep few seconds for link stable + # wait NIC link status stable within 15s + self.pmdout.wait_link_status_up('all') for port in self.ports: out = self.dut.send_expect("show port info %s" % port, "testpmd>") @@ -501,6 +487,7 @@ class TestShutdownApi(TestCase): self.dut.send_expect("start", "testpmd> ") self.check_forwarding() self.dut.send_expect("stop", "testpmd> ") + def test_change_linkspeed_vf(self): """ Change Link Speed VF . @@ -561,7 +548,6 @@ class TestShutdownApi(TestCase): self.verify(config[1].lower() == linktype[0].lower(), "Wrong VF link type reported by the self.tester.") - def test_enable_disablejumbo(self): """ Enable/Disable Jumbo Frames. @@ -752,14 +738,12 @@ class TestShutdownApi(TestCase): # link down test for i in range(ports_num): self.dut.send_expect("set link-down port %d" % i, "testpmd>") - # leep few seconds for NIC link status update - time.sleep(5) + # check NIC link status update within 15s self.check_ports(status=False) # link up test for j in range(ports_num): self.dut.send_expect("set link-up port %d" % j, "testpmd>") - time.sleep(5) self.check_ports(status=True) self.check_forwarding() @@ -815,8 +799,6 @@ class TestShutdownApi(TestCase): # start ports, to avodi failing further tests if ports are stoped self.dut.send_expect("port start all", "testpmd> ", 100) self.dut.send_expect("quit", "# ") - - def tear_down_all(self): """ -- 2.25.1