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 CBB9D456F3; Tue, 30 Jul 2024 23:32:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D13634068E; Tue, 30 Jul 2024 23:32:08 +0200 (CEST) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by mails.dpdk.org (Postfix) with ESMTP id 65B4340609 for ; Tue, 30 Jul 2024 23:30:36 +0200 (CEST) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7ab34117cc2so3391722a12.0 for ; Tue, 30 Jul 2024 14:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722375035; x=1722979835; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NMOncdcznmsNgQS9EUhFp00G/BUfFHBVslarkFLP+P4=; b=QFY9CT0om3fLQrc4s1qsFkzruWhgvvYCISorGZhMkUoom93BOdirl98qwmdDFCbzsl NOC0ueCr27tcklcsdpjDx/R5M7A6+JVBWuUyamcwnoGfSBuu6TxS2rlTWeChyVaVGkMr PlhEWO7h7Sw+mOJ2XdzRFiOsjTIkTDExm1ZqU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722375035; x=1722979835; h=content-transfer-encoding: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=NMOncdcznmsNgQS9EUhFp00G/BUfFHBVslarkFLP+P4=; b=WTzxYR2AEaE2Cq7LgvGx5Z5hSOXgCpD12Bg205K3cem0AMDslHTBfidSqE+d0xk8Rj V9cy3o14OSusBBYSndM0ixmrYMYz+YUShcJOHDZxxh0f0wOodm0rB61mvAXFZIE0oqtD UVw+L4nGo2gFHNxAuWv1KHTHj9J7vUtekTF5qNGkyKhQksKqXeuIQYT0aXTaFIt9NYFN YIwnvltNJRcMIRPZdPB1y6x3Gm6lMm7pI8X0eVAlwnsGcoyW3oZmOPStx9iQMm5CjA+f k8EUJ115AIPnx8qSmmTsJzAkXuY7cnEIh9GAOMhARYe4/zNMC0JFi7cST26GU7sa0q6G fwwA== X-Forwarded-Encrypted: i=1; AJvYcCUdI5+dxkJpvjgXFr7CqYzkQsREuu6Y9XcHSiJp0hM5R8PPPGfE+24uBoZYmOLIN2UDtRjJwNaM+hl43yc= X-Gm-Message-State: AOJu0Yz5PIulRFyoFSIoQvcx6EtbV/kW1ucTWTn1iL2YEiEjW1EhLLUN o8Z7lBpmfXKUFeQhLrgOwjY+ZGcFK3OgCe167L8lB7klH3HP3vUrg/jqymql3jqiXL/LKFRw1Tf DY21myLjCedYt8ioFMvY6VOZ8AFYRfUf1Sc0w+zlmwMhIf1z2 X-Google-Smtp-Source: AGHT+IH0rHKR5YAURgNcHZZTcyEP/oLJdlX6Jnxvx32VPFi7zpSaug01QXlS1wM7GC6OX96miGw1b6UzvH/SrpYUtLY= X-Received: by 2002:a17:90a:6782:b0:2c9:75a4:cc71 with SMTP id 98e67ed59e1d1-2cf7e5c1a1bmr14180805a91.32.1722375035211; Tue, 30 Jul 2024 14:30:35 -0700 (PDT) MIME-Version: 1.0 References: <20240729203955.267942-1-jspewock@iol.unh.edu> <20240730133459.21907-1-jspewock@iol.unh.edu> <20240730133459.21907-2-jspewock@iol.unh.edu> In-Reply-To: From: Jeremy Spewock Date: Tue, 30 Jul 2024 17:30:23 -0400 Message-ID: Subject: Re: [PATCH v2 1/1] dts: add text parser for testpmd verbose output To: Nicholas Pratte Cc: yoan.picchi@foss.arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, Luca.Vizzarro@arm.com, juraj.linkes@pantheon.tech, wathsala.vithanage@arm.com, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Jul 30, 2024 at 11:41=E2=80=AFAM Nicholas Pratte wrote: > > Good work! I left some probing/clarifying comments below for you. > > > > +@dataclass > > +class TestPmdVerboseOutput(TextParser): > > + """Verbose output generated by Testpmd. > > + > > + This class is the top level of the output, containing verbose outp= ut delimited by > > + "port X/queue Y: sent/received Z packets". > > + """ > > + > > + #: ID of the port that handled the packet. > > + port_id: int =3D field(metadata=3DTextParser.find_int(r"port (\d+)= /queue \d+")) > > + #: ID of the queue that handled the packet. > > + queue_id: int =3D field(metadata=3DTextParser.find_int(r"port \d+/= queue (\d+)")) > > + #: Whether the packet was received or sent by the queue/port. > > + was_received: bool =3D field(metadata=3DTextParser.find(r"received= \d+ packets")) > > + #: List of packets handed by the port/queue in this section. > > + packets: list[TestPmdVerbosePacket] =3D field( > > + metadata=3DTextParser.wrap( > > + TextParser.find_all(r"(src=3D[\w\s=3D:-]+ol_flags: [\w ]+)= "), > > + lambda matches_arr: list(map(TestPmdVerbosePacket.parse, m= atches_arr)), > > + ) > > + ) > > + > > + > > class TestPmdShell(DPDKShell): > > """Testpmd interactive shell. > > > > @@ -645,7 +767,7 @@ def start(self, verify: bool =3D True) -> None: > > "Not all ports came up after starting packet f= orwarding in testpmd." > > ) > > > > - def stop(self, verify: bool =3D True) -> None: > > + def stop(self, verify: bool =3D True) -> str: > > """Stop packet forwarding. > > > > Args: > > @@ -656,6 +778,9 @@ def stop(self, verify: bool =3D True) -> None: > > Raises: > > InteractiveCommandExecutionError: If `verify` is :data:`Tr= ue` and the command to stop > > forwarding results in an error. > > + > > + Returns: > > + Output gathered from sending the stop command. > > """ > > stop_cmd_output =3D self.send_command("stop") > > if verify: > > @@ -665,6 +790,7 @@ def stop(self, verify: bool =3D True) -> None: > > ): > > self._logger.debug(f"Failed to stop packet forwarding:= \n{stop_cmd_output}") > > raise InteractiveCommandExecutionError("Testpmd failed= to stop packet forwarding.") > > + return stop_cmd_output > > > > > + @staticmethod > > + def extract_verbose_output(output: str) -> list[TestPmdVerboseOutp= ut]: > > + """Extract the verbose information present in given testpmd ou= tput. > > + > > + This method extracts sections of verbose output that begin wit= h the line > > + "port X/queue Y: sent/received Z packets" and end with the ol_= flags of a packet. > > + > > + Args: > > + output: Testpmd output that contains verbose information > > + > > + Returns: > > + List of parsed packet information gathered from verbose in= formation in `output`. > > + """ > > + iter =3D re.finditer(r"(port \d+/queue \d+:.*?(?=3Dport \d+/qu= eue \d+|$))", output, re.S) > > + return [TestPmdVerboseOutput.parse(s.group(0)) for s in iter] > > + > > I'm trying to think of circumstances where we as developers would be > looking for anything else besides verbose output from the stop method. > Running the command outputs some statistics, but information like port > stats is displayed after the stop command is initiated. I'm > implementing this system right now for one of my test suites, and I'm > wondering if there might be any feasible way to extract output without > needing to input any explicit outputs into this method. I'm putting > output =3D testpmd.stop() and then calling this method. It looks > something like this: > > verbose_output =3D testpmd.extract_verbose_output(testpmd.stop()) > > This is easy enough, but it might be a bit confusing for someone new > to the framework. The way that output is gathered is still elusive to > me, and I'm guessing that any commands run in-between setting verbose > mode and when you stop testpmd might influence how output is > generated. But in my experience so far, any statistics or information > I need is gathered before packets are sent, and the need for verbose > output in test cases is one after the other (i send a packet, look at > verbose output, and then move onto the next packet). You're right that in most cases it would come from the stop output, but the output from that stop command has one other thing as well that I would consider valuable which is statistics of packets handled by ports specifically for the duration of the packet forwarding you are stopping. It is also true that sending other testpmd commands while verbose output is being sent will change what is collected, so I didn't want to tie the method specifically to the stop command since if you did a start command then checked port statistics for example, it would consume all of the verbose output up until the command to check port statistics. For the reason stated above I think it actually might make sense to make it so that every testpmd method (including ones that currently return dataclasses) return their original, unmodified collected output from the testpmd shell as well. Things like port stats can return both in a tuple potentially. This way if there is asynchronous output like there is with verbose output other commands don't completely remove it. >