Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/124463/?format=api
http://patches.dpdk.org/api/patches/124463/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230223152840.634183-3-juraj.linkes@pantheon.tech/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20230223152840.634183-3-juraj.linkes@pantheon.tech>", "list_archive_url": "https://inbox.dpdk.org/dev/20230223152840.634183-3-juraj.linkes@pantheon.tech", "date": "2023-02-23T15:28:32", "name": "[v5,02/10] dts: add ssh command verification", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "bf94a6df536083c6f2be537bfbc706adba5c3c41", "submitter": { "id": 1626, "url": "http://patches.dpdk.org/api/people/1626/?format=api", "name": "Juraj Linkeš", "email": "juraj.linkes@pantheon.tech" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230223152840.634183-3-juraj.linkes@pantheon.tech/mbox/", "series": [ { "id": 27159, "url": "http://patches.dpdk.org/api/series/27159/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=27159", "date": "2023-02-23T15:28:30", "name": "dts: add hello world testcase", "version": 5, "mbox": "http://patches.dpdk.org/series/27159/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/124463/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/124463/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id ECE0C41D52;\n\tThu, 23 Feb 2023 16:29:04 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 8FE3942D55;\n\tThu, 23 Feb 2023 16:28:51 +0100 (CET)", "from mail-ed1-f53.google.com (mail-ed1-f53.google.com\n [209.85.208.53]) by mails.dpdk.org (Postfix) with ESMTP id 4177342B7E\n for <dev@dpdk.org>; Thu, 23 Feb 2023 16:28:47 +0100 (CET)", "by mail-ed1-f53.google.com with SMTP id cq23so43170966edb.1\n for <dev@dpdk.org>; Thu, 23 Feb 2023 07:28:47 -0800 (PST)", "from localhost.localdomain ([84.245.121.112])\n by smtp.gmail.com with ESMTPSA id\n r6-20020a50c006000000b004af6a8617ffsm1158892edb.46.2023.02.23.07.28.45\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 23 Feb 2023 07:28:46 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=pantheon-tech.20210112.gappssmtp.com; s=20210112;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=cITyQzQ1yMMw0k6eIsv77ruoFg0csPndwFcLwVrtIFk=;\n b=7iJ0pj0bK2zhE6KMpZn5cjySu0gffGX+R+XQyFpj8HVctYYaikmh45rt9FQGkfUBAT\n 97LzF1oPv/D42xqgEcZkdv3yrpJ3AnbY8Ti8GPP0aJacMj6D6nbtdCSVwwn+oesATXkd\n 8A8yd4ZPDwiPke+uOIPyB6YcmBRS25urqCNyc92RLUIxhO3NHe++KxhariWJIYg0Zk/j\n HaSPxCm8CqX4Gju/WO8F0eeJ5tDvWihbg8Bbf8n/qSfXT1NLrT+q2WWnnTfn0YHgc4Uk\n NhwUUIjBa7Gq3fI6QjRCYDA+aYRTs1+qD58GAx/MOr1SPKmoN+O7bG9u1vvtBnKnyYYT\n yu9Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=cITyQzQ1yMMw0k6eIsv77ruoFg0csPndwFcLwVrtIFk=;\n b=Cyfv5ISSt5v3P6y9o9Fh+BYUPNYR3bZ9HkaAQ5Y3GfLeyWcYH5O8n94m362DZlOG1V\n W1CcSHjMmDJmpPuqoQZwNQMFnmdpshdJME8U+M5pS1cFVuVieX9LRlo5QB3FQX4aVS7i\n +YSHr8eV9JTlgroH+axAqRLtwbGiunWvza+GkAoeGdBU3j1HiO7qykkJdBBzczhIoQsG\n wSgnvfnm0TQYYPXl3GwqVVF/9e0BgP24RubpWCvnm73d2e+Zb+oudJ5rGMm0/X+j2F+d\n CVUX3JMUvm5usM4OoNj4V1DT9NUARc2rHAiryP+VEi6YgyILSqp2G1zyKBk+gRt6V5pp\n Svgg==", "X-Gm-Message-State": "AO0yUKXjFuQBJeLQiPjzbfzCWjd7kVlkMoYBK6v5ohrrfFg/wl3L3wlE\n TPggzbwV4Klol87FuUpNxvHLkA==", "X-Google-Smtp-Source": "\n AK7set+MXbSkMZHmJuj9VTWl8dDc09s93KExOWxh36e3bglTyUZQd6XqgPl4Q2sjfBs2ZjjAtDAyJg==", "X-Received": "by 2002:a50:fc05:0:b0:4af:59c0:5a30 with SMTP id\n i5-20020a50fc05000000b004af59c05a30mr8059674edr.38.1677166127004;\n Thu, 23 Feb 2023 07:28:47 -0800 (PST)", "From": "=?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>", "To": "thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, lijuan.tu@intel.com,\n bruce.richardson@intel.com, probb@iol.unh.edu", "Cc": "dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>", "Subject": "[PATCH v5 02/10] dts: add ssh command verification", "Date": "Thu, 23 Feb 2023 16:28:32 +0100", "Message-Id": "<20230223152840.634183-3-juraj.linkes@pantheon.tech>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20230223152840.634183-1-juraj.linkes@pantheon.tech>", "References": "<20230213152846.284191-1-juraj.linkes@pantheon.tech>\n <20230223152840.634183-1-juraj.linkes@pantheon.tech>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "This is a basic capability needed to check whether the command execution\nwas successful or not. If not, raise a RemoteCommandExecutionError. When\na failure is expected, the caller is supposed to catch the exception.\n\nSigned-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>\n---\n dts/framework/exception.py | 23 +++++++-\n .../remote_session/remote/remote_session.py | 55 +++++++++++++------\n .../remote_session/remote/ssh_session.py | 12 +++-\n 3 files changed, 69 insertions(+), 21 deletions(-)", "diff": "diff --git a/dts/framework/exception.py b/dts/framework/exception.py\nindex 121a0f7296..e776b42bd9 100644\n--- a/dts/framework/exception.py\n+++ b/dts/framework/exception.py\n@@ -21,7 +21,8 @@ class ErrorSeverity(IntEnum):\n NO_ERR = 0\n GENERIC_ERR = 1\n CONFIG_ERR = 2\n- SSH_ERR = 3\n+ REMOTE_CMD_EXEC_ERR = 3\n+ SSH_ERR = 4\n \n \n class DTSError(Exception):\n@@ -90,3 +91,23 @@ class ConfigurationError(DTSError):\n \"\"\"\n \n severity: ClassVar[ErrorSeverity] = ErrorSeverity.CONFIG_ERR\n+\n+\n+class RemoteCommandExecutionError(DTSError):\n+ \"\"\"\n+ Raised when a command executed on a Node returns a non-zero exit status.\n+ \"\"\"\n+\n+ command: str\n+ command_return_code: int\n+ severity: ClassVar[ErrorSeverity] = ErrorSeverity.REMOTE_CMD_EXEC_ERR\n+\n+ def __init__(self, command: str, command_return_code: int):\n+ self.command = command\n+ self.command_return_code = command_return_code\n+\n+ def __str__(self) -> str:\n+ return (\n+ f\"Command {self.command} returned a non-zero exit code: \"\n+ f\"{self.command_return_code}\"\n+ )\ndiff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py\nindex 7c7b30225f..5ac395ec79 100644\n--- a/dts/framework/remote_session/remote/remote_session.py\n+++ b/dts/framework/remote_session/remote/remote_session.py\n@@ -7,15 +7,29 @@\n from abc import ABC, abstractmethod\n \n from framework.config import NodeConfiguration\n+from framework.exception import RemoteCommandExecutionError\n from framework.logger import DTSLOG\n from framework.settings import SETTINGS\n \n \n @dataclasses.dataclass(slots=True, frozen=True)\n-class HistoryRecord:\n+class CommandResult:\n+ \"\"\"\n+ The result of remote execution of a command.\n+ \"\"\"\n+\n name: str\n command: str\n- output: str | int\n+ stdout: str\n+ stderr: str\n+ return_code: int\n+\n+ def __str__(self) -> str:\n+ return (\n+ f\"stdout: '{self.stdout}'\\n\"\n+ f\"stderr: '{self.stderr}'\\n\"\n+ f\"return_code: '{self.return_code}'\"\n+ )\n \n \n class RemoteSession(ABC):\n@@ -34,7 +48,7 @@ class RemoteSession(ABC):\n port: int | None\n username: str\n password: str\n- history: list[HistoryRecord]\n+ history: list[CommandResult]\n _logger: DTSLOG\n _node_config: NodeConfiguration\n \n@@ -68,28 +82,33 @@ def _connect(self) -> None:\n Create connection to assigned node.\n \"\"\"\n \n- def send_command(self, command: str, timeout: float = SETTINGS.timeout) -> str:\n+ def send_command(\n+ self, command: str, timeout: float = SETTINGS.timeout, verify: bool = False\n+ ) -> CommandResult:\n \"\"\"\n- Send a command and return the output.\n+ Send a command to the connected node and return CommandResult.\n+ If verify is True, check the return code of the executed command\n+ and raise a RemoteCommandExecutionError if the command failed.\n \"\"\"\n- self._logger.info(f\"Sending: {command}\")\n- out = self._send_command(command, timeout)\n- self._logger.debug(f\"Received from {command}: {out}\")\n- self._history_add(command=command, output=out)\n- return out\n+ self._logger.info(f\"Sending: '{command}'\")\n+ result = self._send_command(command, timeout)\n+ if verify and result.return_code:\n+ self._logger.debug(\n+ f\"Command '{command}' failed with return code '{result.return_code}'\"\n+ )\n+ self._logger.debug(f\"stdout: '{result.stdout}'\")\n+ self._logger.debug(f\"stderr: '{result.stderr}'\")\n+ raise RemoteCommandExecutionError(command, result.return_code)\n+ self._logger.debug(f\"Received from '{command}':\\n{result}\")\n+ self.history.append(result)\n+ return result\n \n @abstractmethod\n- def _send_command(self, command: str, timeout: float) -> str:\n+ def _send_command(self, command: str, timeout: float) -> CommandResult:\n \"\"\"\n- Use the underlying protocol to execute the command and return the output\n- of the command.\n+ Use the underlying protocol to execute the command and return CommandResult.\n \"\"\"\n \n- def _history_add(self, command: str, output: str) -> None:\n- self.history.append(\n- HistoryRecord(name=self.name, command=command, output=output)\n- )\n-\n def close(self, force: bool = False) -> None:\n \"\"\"\n Close the remote session and free all used resources.\ndiff --git a/dts/framework/remote_session/remote/ssh_session.py b/dts/framework/remote_session/remote/ssh_session.py\nindex 96175f5284..c2362e2fdf 100644\n--- a/dts/framework/remote_session/remote/ssh_session.py\n+++ b/dts/framework/remote_session/remote/ssh_session.py\n@@ -12,7 +12,7 @@\n from framework.logger import DTSLOG\n from framework.utils import GREEN, RED\n \n-from .remote_session import RemoteSession\n+from .remote_session import CommandResult, RemoteSession\n \n \n class SSHSession(RemoteSession):\n@@ -66,6 +66,7 @@ def _connect(self) -> None:\n \n self.send_expect(\"stty -echo\", \"#\")\n self.send_expect(\"stty columns 1000\", \"#\")\n+ self.send_expect(\"bind 'set enable-bracketed-paste off'\", \"#\")\n except Exception as e:\n self._logger.error(RED(str(e)))\n if getattr(self, \"port\", None):\n@@ -163,7 +164,14 @@ def _flush(self) -> None:\n def is_alive(self) -> bool:\n return self.session.isalive()\n \n- def _send_command(self, command: str, timeout: float) -> str:\n+ def _send_command(self, command: str, timeout: float) -> CommandResult:\n+ output = self._send_command_get_output(command, timeout)\n+ return_code = int(self._send_command_get_output(\"echo $?\", timeout))\n+\n+ # we're capturing only stdout\n+ return CommandResult(self.name, command, output, \"\", return_code)\n+\n+ def _send_command_get_output(self, command: str, timeout: float) -> str:\n try:\n self._clean_session()\n self._send_line(command)\n", "prefixes": [ "v5", "02/10" ] }{ "id": 124463, "url": "