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 E982643357; Fri, 17 Nov 2023 19:10:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA64B402EA; Fri, 17 Nov 2023 19:10:04 +0100 (CET) Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by mails.dpdk.org (Postfix) with ESMTP id 8234140285 for ; Fri, 17 Nov 2023 19:10:03 +0100 (CET) Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5bdc185c449so1743249a12.0 for ; Fri, 17 Nov 2023 10:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1700244602; x=1700849402; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=w6w9EL/JY1SsQYaWbtCKZorOuAU9MSPUeDoE4DomI0w=; b=aNSKMDSyY0LvDM1qNYBGHlVUVoaNgstwRMUVzz+UH46ExTBcW7HN695qfxJ9TAmAP8 Az7X8wb88XVsZWRFvbToiOSO5cBMNYXcgVpOVp08Y39g1Z+Yes6zvXaIT34gc2b0TWOH ObWXrlnrdSVpk+Fp5YyiuX+a/Covvy0w3WKRc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700244602; x=1700849402; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w6w9EL/JY1SsQYaWbtCKZorOuAU9MSPUeDoE4DomI0w=; b=mNfKS8atbfSus4rIo8hecRaQl0BUt8ngaxS0YrDTRZfC1GYm9p0q6RVOeFPEyPwYLg JTNTrHBEg64kmjML4v2wFGP217h6Hyoq0rOt9+SVOVjzrKxp58drEc2+o8dTN6NJ1cHt IkG8hdgoXvmIsXezkkok4rk3BBimzcAX2adHHdnC6y9XskpaxTsJB1EAX4h9/CIN6X0r pl8vt23YRahlzJ13c1fx1FvCfkuLx8y61ziA1AwM7cwW6UMebDbS699wSt5mQ+L2uU0d lras64hiWFE0RNp+lc9KPoWd3WMb3HUV/5VaqSdU8VegyuhpxCTEItaFQy16JK5KPz3v iJ+g== X-Gm-Message-State: AOJu0Yxz2YWf/3FI5KsBWJltwa0UPZV0wRsOHor9m3c5VNYl6udai1lO ugd4BtGFlU/fihL+qRnf2M30EA4SSNGyUFmCrpVLtQ== X-Google-Smtp-Source: AGHT+IF43OEnCjndUxsIfYGt6g2UmZMSYOe98QEpqyFxN98FaCrYNrleGlGzek0d2IPTD6oYI7D+FI0VgpJ7rY2RXrY= X-Received: by 2002:a17:90a:31c1:b0:283:2044:158 with SMTP id j1-20020a17090a31c100b0028320440158mr295262pjf.0.1700244602688; Fri, 17 Nov 2023 10:10:02 -0800 (PST) MIME-Version: 1.0 References: <20231113202833.12900-1-jspewock@iol.unh.edu> <20231113202833.12900-3-jspewock@iol.unh.edu> In-Reply-To: From: Jeremy Spewock Date: Fri, 17 Nov 2023 13:09:51 -0500 Message-ID: Subject: Re: [PATCH v3 2/7] dts: add waiting for port up in testpmd To: =?UTF-8?Q?Juraj_Linke=C5=A1?= Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, wathsala.vithanage@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, dev@dpdk.org Content-Type: multipart/alternative; boundary="000000000000932cfa060a5d0ba0" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --000000000000932cfa060a5d0ba0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Nov 16, 2023 at 2:05=E2=80=AFPM Juraj Linke=C5=A1 wrote: > On Mon, Nov 13, 2023 at 9:28=E2=80=AFPM wrote: > > > > From: Jeremy Spewock > > > > Added a method within the testpmd interactive shell that polls the > > status of ports and verifies that the link status on a given port is > > "up." Polling will continue until either the link comes up, or the > > timeout is reached. > > > > Signed-off-by: Jeremy Spewock > > --- > > .../remote_session/remote/testpmd_shell.py | 29 +++++++++++++++++++ > > 1 file changed, 29 insertions(+) > > > > diff --git a/dts/framework/remote_session/remote/testpmd_shell.py > b/dts/framework/remote_session/remote/testpmd_shell.py > > index 1455b5a199..3ea16c7ab3 100644 > > --- a/dts/framework/remote_session/remote/testpmd_shell.py > > +++ b/dts/framework/remote_session/remote/testpmd_shell.py > > @@ -1,9 +1,12 @@ > > # SPDX-License-Identifier: BSD-3-Clause > > # Copyright(c) 2023 University of New Hampshire > > > > +import time > > from pathlib import PurePath > > from typing import Callable > > > > +from framework.settings import SETTINGS > > + > > from .interactive_shell import InteractiveShell > > > > > > @@ -47,3 +50,29 @@ def get_devices(self) -> list[TestPmdDevice]: > > if "device name:" in line.lower(): > > dev_list.append(TestPmdDevice(line)) > > return dev_list > > + > > + def wait_link_status_up(self, port_id: int, > timeout=3DSETTINGS.timeout) -> bool: > > + """Wait until the link status on the given port is "up". > > + > > + Arguments: > > + port_id: Port to check the link status on. > > + timeout: time to wait for the link to come up. > > + > > + Returns: > > + If the link came up in time or not. > > + """ > > Again with the docstrings - the new thing here is the usage of > SETTINGS. Here's an example: > > The YAML test run configuration file is specified in the > :option:`--config-file` command line > argument or the :envvar:`DTS_CFG_FILE` environment variable. > > The rule is to first mention the cmdline arg, then the env var. > > Good catch, I'll change this. > > + time_to_stop =3D time.time() + timeout > > + while time.time() < time_to_stop: > > + port_info =3D self.send_command(f"show port info {port_id}= ") > > + if "Link status: up" in port_info: > > + break > > + time.sleep(0.5) > > + else: > > + self._logger.error( > > + f"The link for port {port_id} did not come up in the > given timeout." > > + ) > > + return "Link status: up" in port_info > > + > > + def close(self) -> None: > > + self.send_command("exit", "") > > + return super().close() > > -- > > 2.42.0 > > > --000000000000932cfa060a5d0ba0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


<= div dir=3D"ltr" class=3D"gmail_attr">On Thu, Nov 16, 2023 at 2:05=E2=80=AFP= M Juraj Linke=C5=A1 <juraj.linkes@pantheon.tech> wrote:
On Mon, Nov 13, 2023 at 9:28= =E2=80=AFPM <j= spewock@iol.unh.edu> wrote:
>
> From: Jeremy Spewock <jspewock@iol.unh.edu>
>
> Added a method within the testpmd interactive shell that polls the
> status of ports and verifies that the link status on a given port is > "up." Polling will continue until either the link comes up, = or the
> timeout is reached.
>
> Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
> ---
>=C2=A0 .../remote_session/remote/testpmd_shell.py=C2=A0 =C2=A0 | 29 +++= ++++++++++++++++
>=C2=A0 1 file changed, 29 insertions(+)
>
> diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dt= s/framework/remote_session/remote/testpmd_shell.py
> index 1455b5a199..3ea16c7ab3 100644
> --- a/dts/framework/remote_session/remote/testpmd_shell.py
> +++ b/dts/framework/remote_session/remote/testpmd_shell.py
> @@ -1,9 +1,12 @@
>=C2=A0 # SPDX-License-Identifier: BSD-3-Clause
>=C2=A0 # Copyright(c) 2023 University of New Hampshire
>
> +import time
>=C2=A0 from pathlib import PurePath
>=C2=A0 from typing import Callable
>
> +from framework.settings import SETTINGS
> +
>=C2=A0 from .interactive_shell import InteractiveShell
>
>
> @@ -47,3 +50,29 @@ def get_devices(self) -> list[TestPmdDevice]: >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "device name:&= quot; in line.lower():
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_list= .append(TestPmdDevice(line))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return dev_list
> +
> +=C2=A0 =C2=A0 def wait_link_status_up(self, port_id: int, timeout=3DS= ETTINGS.timeout) -> bool:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Wait until the link sta= tus on the given port is "up".
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 Arguments:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port_id: Port to check the = link status on.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 timeout: time to wait for t= he link to come up.
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 Returns:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 If the link came up in time= or not.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 """

Again with the docstrings - the new thing here is the usage of
SETTINGS. Here's an example:

The YAML test run configuration file is specified in the
:option:`--config-file` command line
argument or the :envvar:`DTS_CFG_FILE` environment variable.

The rule is to first mention the cmdline arg, then the env var.


Good catch, I'll change this.
=C2=A0
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 time_to_stop =3D time.time() + timeout > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 while time.time() < time_to_stop:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port_info =3D self.send_com= mand(f"show port info {port_id}")
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "Link status: up&qu= ot; in port_info:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 time.sleep(0.5)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.error(
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"The li= nk for port {port_id} did not come up in the given timeout."
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return "Link status: up" in por= t_info
> +
> +=C2=A0 =C2=A0 def close(self) -> None:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.send_command("exit", "= ;")
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return super().close()
> --
> 2.42.0
>
--000000000000932cfa060a5d0ba0--