From patchwork Wed Jun 19 13:35:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 141389 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id E6D1D454A8; Wed, 19 Jun 2024 15:37:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5AA94065A; Wed, 19 Jun 2024 15:37:03 +0200 (CEST) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mails.dpdk.org (Postfix) with ESMTP id E1BD54021D for ; Wed, 19 Jun 2024 15:35:30 +0200 (CEST) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57d1679ee6eso565805a12.1 for ; Wed, 19 Jun 2024 06:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1718804130; x=1719408930; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kFv4Ch4lX6CsE5LL+hWHgJd7x3/PW9QejHp01GyrzqU=; b=Lgl9y6HZ06YJfkChesjWynHFploC4gpqul+hh6oKtqmd8fO5JBp/F78+pGUOIFVgMz qIxpdF9ORplAhG8863K1hcAhtGqvIw+C5eMfQLhZxj1BAuHEWy9390RuNyjvcHaycJyR GWMpYhG0dd6j9cgcZ2+aswCwASYOGQP8y/gEWQydosRpA1V7R+ugR/gc9iQOoyTG2B7t r9zsJpbqVF23EAcrAXsqXVUIzY5P6+qBomduPwDUMmKGnjKBKnqrzXTC5h9n2teb0Xdz SnUP1YGxRv+FCSOE8Xao8iRmmy40iarjW95y2ZUh6JWDcIMDgk/15b2S544UyeqzWty8 Mqwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718804130; x=1719408930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kFv4Ch4lX6CsE5LL+hWHgJd7x3/PW9QejHp01GyrzqU=; b=MBVVb/XJmEhLvSQaQabhxEfHlv+97KOG4JQ0lW3M/qe3xZ38/Tu4WFIO216bVOhw2A okTCvryVCXLhSXynTMbOzJodl6J4n+lGQfKibqcHW0Kx9JGDld0mLKnYDRL/9dz9ivfz et+By18vrzCgHB4Yvp+QfZt5qHreVKZNDJ61mkVSOsETa3UBXZPv5xJn4ViHJlVawx0Z 18qTfmlx1zB7X0xtrxWaOADWOmImOChqWJi6f5ava8tr0y1YprDHcwgXEpWuHiDSo1nO jbFIY5Iv15GVBOYT4P7FbcUgX3QLt+vBRcKDi5yOo0eaTWGi2Gw5tvf2g4Ot/foQ0CQ8 dY/Q== X-Gm-Message-State: AOJu0Yw7kp2ZihEghvhR9Wb4kCDopQ5pO+qYGpcZGhCAUxUXZGZU6KMZ GsjF3CXgiFRYYBDGGbjTRWZIUd0j9/CHm0P9AxFf7ZLfMFiuMpdwMc+MkjZLvjs= X-Google-Smtp-Source: AGHT+IFF/GxzXqTlAgtKnT+9ct4obHJx0K7TFj5NmjIXk9ApJgsl09h82d/a/I+IC2rdOqk0FyYJSQ== X-Received: by 2002:a17:907:168b:b0:a6f:718f:39a7 with SMTP id a640c23a62f3a-a6fa410c5d5mr151603466b.16.1718804130438; Wed, 19 Jun 2024 06:35:30 -0700 (PDT) Received: from localhost.localdomain ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56da3fe5sm676723566b.18.2024.06.19.06.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 06:35:30 -0700 (PDT) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu, probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= , Luca Vizzarro Subject: [PATCH v2 1/5] dts: add tg node test run setup and teardown Date: Wed, 19 Jun 2024 15:35:22 +0200 Message-Id: <20240619133526.28614-2-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619133526.28614-1-juraj.linkes@pantheon.tech> References: <20240423091252.62924-1-juraj.linkes@pantheon.tech> <20240619133526.28614-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 The setup and teardown for the test run stage was meant to be run on the tg node too, but was mistakenly omitted. Fixes: cecfe0aabf58 ("dts: add traffic generator abstractions") Signed-off-by: Juraj Linkeš Reviewed-by: Luca Vizzarro Reviewed-by: Jeremy Spewock --- dts/framework/runner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dts/framework/runner.py b/dts/framework/runner.py index 4e0254f453..565e581310 100644 --- a/dts/framework/runner.py +++ b/dts/framework/runner.py @@ -428,6 +428,7 @@ def _run_test_run( test_run_result.add_sut_info(sut_node.node_info) try: sut_node.set_up_test_run(test_run_config) + tg_node.set_up_test_run(test_run_config) test_run_result.update_setup(Result.PASS) except Exception as e: self._logger.exception("Test run setup failed.") @@ -448,6 +449,7 @@ def _run_test_run( try: self._logger.set_stage(DtsStage.test_run_teardown) sut_node.tear_down_test_run() + tg_node.tear_down_test_run() test_run_result.update_teardown(Result.PASS) except Exception as e: self._logger.exception("Test run teardown failed.") From patchwork Wed Jun 19 13:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 141390 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id 5E473454A8; Wed, 19 Jun 2024 15:37:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 013E541149; Wed, 19 Jun 2024 15:37:05 +0200 (CEST) Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mails.dpdk.org (Postfix) with ESMTP id 0E05E4021D for ; Wed, 19 Jun 2024 15:35:32 +0200 (CEST) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a6f04afcce1so861044666b.2 for ; Wed, 19 Jun 2024 06:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1718804131; x=1719408931; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B4za1AWsBUJILJk9ptv+C01mPajRv4RpwyF+Z9+5c1o=; b=v0OM0uiN3arZKe+qMW/kJN6m12YnRhEPMkAe0YQNXLWEArFmA3tmdOTtooU5N4A/eB BvTtRXs/FOOmmNHM2rHvDuqHnsaZR8f1u1qkUC6V/lF2SioE23cJ1kGpQnbGIguDvjvQ SWQG12ahEorv1m/kqREGlZYwyeCGxw/d7wr6+TUqodslmPfly0n/lsedWVM/QA2HqleV MfZqeDqwWCL1MPuinL85RVKUMrdgONkGROT6wW5vrmyPdDDN5V0Km8QI9x7mNrYO5+4Q G0pb4OlLsBCLTGrrsixh8BAbakCj1u7DmMwdGgSl0SOY6I3RFv39vV2E5QJeLqMLD0GW w4uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718804131; x=1719408931; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B4za1AWsBUJILJk9ptv+C01mPajRv4RpwyF+Z9+5c1o=; b=LAeRD046OxMByTQzVZurZGIvuBpEZocpPcscv/IrESZzk4YHoD31n0GjRTI41zkUUS wFGU1fXRLQaaZ752rns4S/7N8UjEaX0uTsHoD9i8ay8T1N46FrT1hAZpSjzUFw+mXtol zWCaGXF88iNOfOnH7M5FIYAifmZMRVyMNp4ywIiGdQNTee7iI3fB40MBcmz9ofj0aE+T 8GKDMfWELWOyjhn+JtCIT8R9RGfDlrCtXAgF8nXQc7m9nQT4/P/3ciakvPXAutgweB6l YOkIXDIgn0V2L33m3E6wtjGx9t5uudr6mbQrH9gAyxxjlphATIiW5xp0HY/58R6ljtsa sEzg== X-Gm-Message-State: AOJu0Yxss2Y6Jg5BcK4VfeQ2CpsPCSZRRbyPpkR8muFTPmmJIfdiHe4Y 3hKKZmjTMCwzrnQy7C3zktwWlBaliU3Us+OZMXZNARX+r5VcsguJnRVBaasSjfQ= X-Google-Smtp-Source: AGHT+IE+szJE/5cEY37Nrg84/BFDZWxfPEg8wI4jdjz3stT5BKAO4ioL+9IAt9GPM3hJxJ093F0E9Q== X-Received: by 2002:a17:907:765c:b0:a6f:a54:1598 with SMTP id a640c23a62f3a-a6fab779292mr142312666b.49.1718804131690; Wed, 19 Jun 2024 06:35:31 -0700 (PDT) Received: from localhost.localdomain ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56da3fe5sm676723566b.18.2024.06.19.06.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 06:35:31 -0700 (PDT) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu, probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= , Luca Vizzarro Subject: [PATCH v2 2/5] dts: unify class inheritance from object Date: Wed, 19 Jun 2024 15:35:23 +0200 Message-Id: <20240619133526.28614-3-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619133526.28614-1-juraj.linkes@pantheon.tech> References: <20240423091252.62924-1-juraj.linkes@pantheon.tech> <20240619133526.28614-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 There are two ways we specify that a class inherits from object - implicitly and explicitly. There's no need to explicitly specify that a class inherits from object and is in fact mostly a remnant from Python2. Leaving it implicit is the standard in Python3 and offers a small bonus in cases where something would assign something else to the builtin object variable. Signed-off-by: Juraj Linkeš Reviewed-by: Luca Vizzarro Reviewed-by: Patrick Robb Reviewed-by: Jeremy Spewock --- dts/framework/remote_session/testpmd_shell.py | 2 +- dts/framework/test_result.py | 4 ++-- dts/framework/test_suite.py | 2 +- dts/framework/testbed_model/cpu.py | 4 ++-- dts/framework/testbed_model/sut_node.py | 2 +- dts/framework/testbed_model/virtual_device.py | 2 +- dts/framework/utils.py | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index cb2ab6bd00..9456de941d 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -27,7 +27,7 @@ from .interactive_shell import InteractiveShell -class TestPmdDevice(object): +class TestPmdDevice: """The data of a device that testpmd can recognize. Attributes: diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py index 4693519bbc..5deccb6fd4 100644 --- a/dts/framework/test_result.py +++ b/dts/framework/test_result.py @@ -96,7 +96,7 @@ def __bool__(self) -> bool: return self is self.PASS -class FixtureResult(object): +class FixtureResult: """A record that stores the result of a setup or a teardown. :attr:`~Result.FAIL` is a sensible default since it prevents false positives (which could happen @@ -132,7 +132,7 @@ def __bool__(self) -> bool: return bool(self.result) -class BaseResult(object): +class BaseResult: """Common data and behavior of DTS results. Stores the results of the setup and teardown portions of the corresponding stage. diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py index 8768f756a6..b9f8daab1a 100644 --- a/dts/framework/test_suite.py +++ b/dts/framework/test_suite.py @@ -27,7 +27,7 @@ from .utils import get_packet_summaries -class TestSuite(object): +class TestSuite: """The base class with building blocks needed by most test cases. * Test suite setup/cleanup methods to override, diff --git a/dts/framework/testbed_model/cpu.py b/dts/framework/testbed_model/cpu.py index 9e33b2825d..a50cf44c19 100644 --- a/dts/framework/testbed_model/cpu.py +++ b/dts/framework/testbed_model/cpu.py @@ -26,7 +26,7 @@ @dataclass(slots=True, frozen=True) -class LogicalCore(object): +class LogicalCore: """Representation of a logical CPU core. A physical core is represented in OS by multiple logical cores (lcores) @@ -50,7 +50,7 @@ def __int__(self) -> int: return self.lcore -class LogicalCoreList(object): +class LogicalCoreList: r"""A unified way to store :class:`LogicalCore`\s. Create a unified format used across the framework and allow the user to use diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 97aa26d419..10d56eba8d 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -34,7 +34,7 @@ from .virtual_device import VirtualDevice -class EalParameters(object): +class EalParameters: """The environment abstraction layer parameters. The string representation can be created by converting the instance to a string. diff --git a/dts/framework/testbed_model/virtual_device.py b/dts/framework/testbed_model/virtual_device.py index e9b5e9c3be..569d67b007 100644 --- a/dts/framework/testbed_model/virtual_device.py +++ b/dts/framework/testbed_model/virtual_device.py @@ -7,7 +7,7 @@ """ -class VirtualDevice(object): +class VirtualDevice: """Base class for virtual devices used by DPDK. Attributes: diff --git a/dts/framework/utils.py b/dts/framework/utils.py index 862bafb46c..6b5d5a805f 100644 --- a/dts/framework/utils.py +++ b/dts/framework/utils.py @@ -108,7 +108,7 @@ def __str__(self) -> str: return self.name -class MesonArgs(object): +class MesonArgs: """Aggregate the arguments needed to build DPDK.""" _default_library: str @@ -157,7 +157,7 @@ class _TarCompressionFormat(StrEnum): zstd = "zst" -class DPDKGitTarball(object): +class DPDKGitTarball: """Compressed tarball of DPDK from the repository. The class supports the :class:`os.PathLike` protocol, From patchwork Wed Jun 19 13:35:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 141391 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id D86BC454A8; Wed, 19 Jun 2024 15:37:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC3AC427C0; Wed, 19 Jun 2024 15:37:12 +0200 (CEST) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mails.dpdk.org (Postfix) with ESMTP id 4917A4021D for ; Wed, 19 Jun 2024 15:35:33 +0200 (CEST) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57d05e0017aso1634877a12.1 for ; Wed, 19 Jun 2024 06:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1718804133; x=1719408933; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qFu2ejPOUUGeiY4Uj+kKcKxtjG3UnV2OPdHHGTIM+oQ=; b=YPhB8/5QBpCrtXJNvzPGR/VtT2ui0JKlTMz7uvARB4tUE7LsGsyxPxmwIDyGXh7ie7 vLLi9AUR27bwJjLeBd9UwHByKDPS4mMMGLikB3CYy14ij9U2vTiJfmjUfKZI3mH38XMz 1qOhFkb3e6+mSBq2hMOAnMFNTUXgYuxP0lpM5YPExWHgikJKaEpsFhWky1YVuwyidHOB CwjvzQOHyI3gB/S014rRIjG74G8YzvkYvv4hDTVDC9Bi0pCANpYINfFtaAhFkPVlOWD3 j5KKSgzS5xT8LZjYxR9zlS7V9ELxdeQ6Nn1os7FJLXBC6tDGYi70H9HhQ9X84AlEf6Tb X2ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718804133; x=1719408933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qFu2ejPOUUGeiY4Uj+kKcKxtjG3UnV2OPdHHGTIM+oQ=; b=s4WeBWJCKJm/1wjRlb9D5GLzWrwNM20I83urpwbOssgnzjUQ/mdbArdGi0KGHa6+aI h6PwLiAc517g0norl6sEMTPJq6ZJW3Z7J89q8rxGqYbXivJjQE2tm/4eSEIUp9Zd10Hk ++TgRyYQPdHeSX/sFv+CoNhkuGNyVcXg3lZuWcTZYxok/OBCGv/hhGPIQz6p78nwd2Fj 8HfefqVUZJ9LWLtx41CNVPsULtUkHJpq9G07E23j2LzAnxzD5jsTF1QvChzzA/3O65yU 918AMSLJwFk4ahnKMB2xZuGu+tXnu6KKKrkd4kBoyaav+v2oGX0oOCPAHSz4yUf3ibXo b2WA== X-Gm-Message-State: AOJu0Ywgpju0NZ38hyzdKrcvhbp9AxuIGVHTg4Ca3X85L0E48kghFZRI QWGbcPITZEPz5a5vMJ9Xi9RuZveIEYvtL4eK/Tc7cgynZGc7SafBUdpCc/kLMu0= X-Google-Smtp-Source: AGHT+IFPmBp18xWMhP7v+p3aq5pk/IOU31gwSFe8/BMkdTPgN/6jTcrd5qT50lKjcbA58G0RJ8CfCg== X-Received: by 2002:a17:907:874e:b0:a6f:1e06:29e4 with SMTP id a640c23a62f3a-a6fab77a25emr180167866b.57.1718804132825; Wed, 19 Jun 2024 06:35:32 -0700 (PDT) Received: from localhost.localdomain ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56da3fe5sm676723566b.18.2024.06.19.06.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 06:35:32 -0700 (PDT) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu, probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= , Luca Vizzarro Subject: [PATCH v2 3/5] dts: unify super calls Date: Wed, 19 Jun 2024 15:35:24 +0200 Message-Id: <20240619133526.28614-4-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619133526.28614-1-juraj.linkes@pantheon.tech> References: <20240423091252.62924-1-juraj.linkes@pantheon.tech> <20240619133526.28614-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 We have two ways of calling super() in the codebase. For single inheritance, there's no benefit in listing the arguments, as the function will do exactly what we need it to do. Signed-off-by: Juraj Linkeš Reviewed-by: Luca Vizzarro Reviewed-by: Patrick Robb Reviewed-by: Jeremy Spewock --- dts/framework/test_result.py | 12 ++++++------ dts/framework/testbed_model/sut_node.py | 2 +- dts/framework/testbed_model/tg_node.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py index 5deccb6fd4..5694a2482b 100644 --- a/dts/framework/test_result.py +++ b/dts/framework/test_result.py @@ -249,7 +249,7 @@ def __init__(self, logger: DTSLogger): Args: logger: The logger instance the whole result will use. """ - super(DTSResult, self).__init__() + super().__init__() self.dpdk_version = None self._logger = logger self._errors = [] @@ -338,7 +338,7 @@ def __init__(self, test_run_config: TestRunConfiguration): Args: test_run_config: A test run configuration. """ - super(TestRunResult, self).__init__() + super().__init__() self._config = test_run_config self._test_suites_with_cases = [] @@ -432,7 +432,7 @@ def __init__( test_suites_with_cases: The test suites with test cases to be run in this build target. build_target_config: The build target's test run configuration. """ - super(BuildTargetResult, self).__init__() + super().__init__() self.arch = build_target_config.arch self.os = build_target_config.os self.cpu = build_target_config.cpu @@ -493,7 +493,7 @@ def __init__(self, test_suite_with_cases: TestSuiteWithCases): Args: test_suite_with_cases: The test suite with test cases. """ - super(TestSuiteResult, self).__init__() + super().__init__() self.test_suite_name = test_suite_with_cases.test_suite_class.__name__ self._test_suite_with_cases = test_suite_with_cases @@ -536,7 +536,7 @@ def __init__(self, test_case_name: str): Args: test_case_name: The test case's name. """ - super(TestCaseResult, self).__init__() + super().__init__() self.test_case_name = test_case_name def update(self, result: Result, error: Exception | None = None) -> None: @@ -594,7 +594,7 @@ def __init__(self, dpdk_version: str | None): Args: dpdk_version: The version of tested DPDK. """ - super(Statistics, self).__init__() + super().__init__() for result in Result: self[result.name] = 0 self["PASS RATE"] = 0.0 diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 10d56eba8d..800fbef860 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -130,7 +130,7 @@ def __init__(self, node_config: SutNodeConfiguration): Args: node_config: The SUT node's test run configuration. """ - super(SutNode, self).__init__(node_config) + super().__init__(node_config) self._dpdk_prefix_list = [] self._build_target_config = None self._env_vars = {} diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py index 164f790383..9dae56ed9c 100644 --- a/dts/framework/testbed_model/tg_node.py +++ b/dts/framework/testbed_model/tg_node.py @@ -48,7 +48,7 @@ def __init__(self, node_config: TGNodeConfiguration): Args: node_config: The TG node's test run configuration. """ - super(TGNode, self).__init__(node_config) + super().__init__(node_config) self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator) self._logger.info(f"Created node: {self.name}") @@ -90,4 +90,4 @@ def close(self) -> None: This extends the superclass method with TG cleanup. """ self.traffic_generator.close() - super(TGNode, self).close() + super().close() From patchwork Wed Jun 19 13:35:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 141392 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id 42BC0454A8; Wed, 19 Jun 2024 15:37:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C75442D2B; Wed, 19 Jun 2024 15:37:14 +0200 (CEST) Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by mails.dpdk.org (Postfix) with ESMTP id 800A44021D for ; Wed, 19 Jun 2024 15:35:34 +0200 (CEST) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-57d0eca877cso994693a12.2 for ; Wed, 19 Jun 2024 06:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1718804134; x=1719408934; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FiYH2tUxOmb+MpstNiD1lgczCg96HeVDnDS6Y02YQGM=; b=PwEN+ajj5hJ/utc7XjC2S4FWutV2EZQDGN23wJumIWql4I5d5Xzg1S6yUEuNA032O8 KClyoz+dDcpiWZKIwpY5Vum3Dz9Jl95gc+Mb9hyUpAztUGTl6Aq59qFDiexlZGh8Dn+L 1G+Fbm73NENuCGe8opGpZnYtWXHAfA22eOadm40LHnqWkIRqUg+I+JWNnCL/zYzVUioz eRinI8XpOgs/LtI0Sw3F5sg7KcLczkXOK82li9zlbta0vmwVsJAbp03qMPOrkD68B/S0 4t9hKf4HWE1cDwKrPU8dYrhV9HluzHRk2U1lqYcaKu9Zbd3jd2C/B/I9r4py3YRMqpoH QVOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718804134; x=1719408934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FiYH2tUxOmb+MpstNiD1lgczCg96HeVDnDS6Y02YQGM=; b=FgteEAdUuE3v2HqHqPTfvm513ITyKDwY9CASB/V7KsGrqRzlw3UeE5GyQT330KesIC u8EljfNb6ETZxPfN0bx7avW+vc8FR8gSw8Qr0+Q7gMcWKfpYzYtOzMsbJGcwtm8/y6x9 sHs7cqQJFTOfY5ViwCZGWx++a9bagS4j6TfZ+ZgMO1XOf1pwUNZxtb9r+q01tSdvgT62 1M1T1ALpD4AOTgqphXiTVyxu1K2fLCdrn4EmrOjGYtz97ZEURcTSY1oHHlHWuWxLrrUR 77nKz0mTrsYkGyGWlDY6WymL7Z5UV3Q1pW/8Hjm5zuqJZd+yl0uXdKifjznL+5uPfcum NMpQ== X-Gm-Message-State: AOJu0YziLPGzEiIlFOCh4tXrBjv1IvmRbFBdUDr6o76Up5e32IbWSjOZ KzVnhyRBdK+TN7rIwXMAgWmxS5CmrNmAmxGQjXhRiIY202ew9/yLzVDesDYt24c= X-Google-Smtp-Source: AGHT+IF6VKuE3G44r+8AbUyeZ6JSFpaZSJQ837wFFZmTbccPrZghTXhBSOtYDJgU4NWw1OcNSjmswA== X-Received: by 2002:a17:906:2584:b0:a6f:4804:d41a with SMTP id a640c23a62f3a-a6fab7790admr166062266b.55.1718804134092; Wed, 19 Jun 2024 06:35:34 -0700 (PDT) Received: from localhost.localdomain ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56da3fe5sm676723566b.18.2024.06.19.06.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 06:35:33 -0700 (PDT) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu, probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= , Luca Vizzarro Subject: [PATCH v2 4/5] dts: refine pre-test setup and teardown steps Date: Wed, 19 Jun 2024 15:35:25 +0200 Message-Id: <20240619133526.28614-5-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619133526.28614-1-juraj.linkes@pantheon.tech> References: <20240423091252.62924-1-juraj.linkes@pantheon.tech> <20240619133526.28614-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 The major part is the removal of _set_up_test_run() and _tear_down_test_run() of Node in lieu of using super() in the superclasses, which simplifies the code while achieving the same thing. The minor changes are the move of virtual devices and build target setup/teardown into SutNode from Node since both are DPDK-related which are only going to run on the SutNode. Signed-off-by: Juraj Linkeš Reviewed-by: Luca Vizzarro Reviewed-by: Jeremy Spewock --- dts/framework/testbed_model/node.py | 66 ++----------------------- dts/framework/testbed_model/sut_node.py | 49 +++++++++++++----- 2 files changed, 41 insertions(+), 74 deletions(-) diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py index fd01533d0e..d7f5d45826 100644 --- a/dts/framework/testbed_model/node.py +++ b/dts/framework/testbed_model/node.py @@ -16,12 +16,7 @@ from ipaddress import IPv4Interface, IPv6Interface from typing import Any, Callable, Type, Union -from framework.config import ( - OS, - BuildTargetConfiguration, - NodeConfiguration, - TestRunConfiguration, -) +from framework.config import OS, NodeConfiguration, TestRunConfiguration from framework.exception import ConfigurationError from framework.logger import DTSLogger, get_dts_logger from framework.settings import SETTINGS @@ -36,7 +31,6 @@ from .linux_session import LinuxSession from .os_session import InteractiveShellType, OSSession from .port import Port -from .virtual_device import VirtualDevice class Node(ABC): @@ -55,7 +49,6 @@ class Node(ABC): lcores: The list of logical cores that DTS can use on the node. It's derived from logical cores present on the node and the test run configuration. ports: The ports of this node specified in the test run configuration. - virtual_devices: The virtual devices used on the node. """ main_session: OSSession @@ -66,7 +59,6 @@ class Node(ABC): _logger: DTSLogger _other_sessions: list[OSSession] _test_run_config: TestRunConfiguration - virtual_devices: list[VirtualDevice] def __init__(self, node_config: NodeConfiguration): """Connect to the node and gather info during initialization. @@ -94,7 +86,6 @@ def __init__(self, node_config: NodeConfiguration): ).filter() self._other_sessions = [] - self.virtual_devices = [] self._init_ports() def _init_ports(self) -> None: @@ -106,67 +97,20 @@ def _init_ports(self) -> None: def set_up_test_run(self, test_run_config: TestRunConfiguration) -> None: """Test run setup steps. - Configure hugepages and call :meth:`_set_up_test_run` where - the rest of the configuration steps (if any) are implemented. + Configure hugepages on all DTS node types. Additional steps can be added by + extending the method in subclasses with the use of super(). Args: test_run_config: A test run configuration according to which the setup steps will be taken. """ self._setup_hugepages() - self._set_up_test_run(test_run_config) - self._test_run_config = test_run_config - for vdev in test_run_config.vdevs: - self.virtual_devices.append(VirtualDevice(vdev)) - - def _set_up_test_run(self, test_run_config: TestRunConfiguration) -> None: - """Optional additional test run setup steps for subclasses. - - Subclasses should override this if they need to add additional test run setup steps. - """ def tear_down_test_run(self) -> None: """Test run teardown steps. - There are currently no common test run teardown steps common to all DTS node types. - """ - self.virtual_devices = [] - self._tear_down_test_run() - - def _tear_down_test_run(self) -> None: - """Optional additional test run teardown steps for subclasses. - - Subclasses should override this if they need to add additional test run teardown steps. - """ - - def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None: - """Build target setup steps. - - There are currently no common build target setup steps common to all DTS node types. - - Args: - build_target_config: The build target test run configuration according to which - the setup steps will be taken. - """ - self._set_up_build_target(build_target_config) - - def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None: - """Optional additional build target setup steps for subclasses. - - Subclasses should override this if they need to add additional build target setup steps. - """ - - def tear_down_build_target(self) -> None: - """Build target teardown steps. - - There are currently no common build target teardown steps common to all DTS node types. - """ - self._tear_down_build_target() - - def _tear_down_build_target(self) -> None: - """Optional additional build target teardown steps for subclasses. - - Subclasses should override this if they need to add additional build target teardown steps. + There are currently no common execution teardown steps common to all DTS node types. + Additional steps can be added by extending the method in subclasses with the use of super(). """ def create_session(self, name: str) -> OSSession: diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 800fbef860..e2a520fede 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -22,6 +22,7 @@ BuildTargetInfo, NodeInfo, SutNodeConfiguration, + TestRunConfiguration, ) from framework.remote_session import CommandResult from framework.settings import SETTINGS @@ -107,10 +108,12 @@ class SutNode(Node): or the git commit ID, tag ID or tree ID to test. Attributes: - config: The SUT node configuration + config: The SUT node configuration. + virtual_devices: The virtual devices used on the node. """ config: SutNodeConfiguration + virtual_devices: list[VirtualDevice] _dpdk_prefix_list: list[str] _dpdk_timestamp: str _build_target_config: BuildTargetConfiguration | None @@ -131,6 +134,7 @@ def __init__(self, node_config: SutNodeConfiguration): node_config: The SUT node's test run configuration. """ super().__init__(node_config) + self.virtual_devices = [] self._dpdk_prefix_list = [] self._build_target_config = None self._env_vars = {} @@ -228,25 +232,44 @@ def get_build_target_info(self) -> BuildTargetInfo: def _guess_dpdk_remote_dir(self) -> PurePath: return self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir) - def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None: - """Setup DPDK on the SUT node. + def set_up_test_run(self, test_run_config: TestRunConfiguration) -> None: + """Extend the test run setup with vdev config. - Additional build target setup steps on top of those in :class:`Node`. + Args: + test_run_config: A test run configuration according to which + the setup steps will be taken. + """ + super().set_up_test_run(test_run_config) + for vdev in test_run_config.vdevs: + self.virtual_devices.append(VirtualDevice(vdev)) + + def tear_down_test_run(self) -> None: + """Extend the test run teardown with virtual device teardown.""" + super().tear_down_test_run() + self.virtual_devices = [] + + def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None: + """Set up DPDK the SUT node and bind ports. + + DPDK setup includes setting all internals needed for the build, the copying of DPDK tarball + and then building DPDK. The drivers are bound to those that DPDK needs. + + Args: + build_target_config: The build target test run configuration according to which + the setup steps will be taken. """ - # we want to ensure that dpdk_version and compiler_version is reset for new - # build targets - self._dpdk_version = None - self._compiler_version = None self._configure_build_target(build_target_config) self._copy_dpdk_tarball() self._build_dpdk() self.bind_ports_to_driver() - def _tear_down_build_target(self) -> None: - """Bind ports to the operating system drivers. - - Additional build target teardown steps on top of those in :class:`Node`. - """ + def tear_down_build_target(self) -> None: + """Reset DPDK variables and bind port driver to the OS driver.""" + self._env_vars = {} + self._build_target_config = None + self.__remote_dpdk_dir = None + self._dpdk_version = None + self._compiler_version = None self.bind_ports_to_driver(for_dpdk=False) def _configure_build_target(self, build_target_config: BuildTargetConfiguration) -> None: From patchwork Wed Jun 19 13:35:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 141393 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id B1E7B454A8; Wed, 19 Jun 2024 15:37:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8477942D7F; Wed, 19 Jun 2024 15:37:15 +0200 (CEST) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by mails.dpdk.org (Postfix) with ESMTP id 872DC4021D for ; Wed, 19 Jun 2024 15:35:35 +0200 (CEST) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-57d07f07a27so1044773a12.3 for ; Wed, 19 Jun 2024 06:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1718804135; x=1719408935; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dos7DmZuljpljeDAdZujU/FDqFNJGG6cXh8AVtg97PY=; b=vSMVwvgwn4+4moUlp8S1VS4BmHfySAzpmsCgtVA7NsyE+LTpopAnx4lPpWzZmy927q 5sVqJkgJDYc7c8G0rqxfPrtD3KSQzvb1i+WdkEfh4DE2pKDqeOlgYK+RiRumM/WnmXtW QCipDyl8PRF54R45HpwfXQTIpEvCHDCAa3C+gOyEVjDIKAPZbnkdvCX/gMbF+aYIg9VK ryl/WmQ6/iwd0Au4JC9z5Bxh16DP4j0BFqmsIojVcFkkue8TE4DqF2h/GEmDHaHnbRRA kaiwAaApMlWNcvg8pZcPCGs4NFPLpfoCGZofqPwWPN+C5LCYULNGf/N1qY+BHBozQqYV 6BeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718804135; x=1719408935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dos7DmZuljpljeDAdZujU/FDqFNJGG6cXh8AVtg97PY=; b=K7SMT4wTt5WrQPbQcgdrbjwR9A5+MsacmszC89B/XXNHEC8GIQhmZbWKeKMhHCkokU 6XqS85ycPnNiRWDOuC6SbslSybbtowFN4pQ7XuPfxrsP0iefQA536jsVASJdSkdIsLvn HJJ5CupalQWsXqSj1mhsdwUPPAS7feNMlT022IIPTg7lUTglxajph3RPf6kyV/fV3mu5 kWSBSD4B/00/Hv84MqojfI7pjv+9lAme6j6sWfZiRexpXOAsG4LOQOTvoub2k/zUOEEr nZA/hiwqN1SjK6u7EWdJT8LO6bcbFxsjn1tlJxWjlxLaPMmNVaofaeOP/C0sxecLub2q p1Rg== X-Gm-Message-State: AOJu0YzA9yrA/a+uOkQQc4Pgo4E9kzky33BepC4VL1Ybroj97rYEcNut 6dudmdHti2JOin2CzxYJDOO+Ynp+ebAya3rbIcTyH0m55cXeT9VQW07gAsl0EXo= X-Google-Smtp-Source: AGHT+IE/bt8mZov5RiUy8PGnuggiQ4+mMRIAfgAlf/Mog7JemMXNuVsCb+491j7LsP88+7Kr0Hlvrw== X-Received: by 2002:a17:906:f150:b0:a6e:f701:384d with SMTP id a640c23a62f3a-a6fab61cf2amr119582466b.29.1718804135145; Wed, 19 Jun 2024 06:35:35 -0700 (PDT) Received: from localhost.localdomain ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56da3fe5sm676723566b.18.2024.06.19.06.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 06:35:34 -0700 (PDT) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu, probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= , Luca Vizzarro Subject: [PATCH v2 5/5] dts: clean up close in remote session Date: Wed, 19 Jun 2024 15:35:26 +0200 Message-Id: <20240619133526.28614-6-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619133526.28614-1-juraj.linkes@pantheon.tech> References: <20240423091252.62924-1-juraj.linkes@pantheon.tech> <20240619133526.28614-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 The close method was split into two methods, one with common code and one that's subclass specific. There wasn't any common code so the split doesn't make sense. And if we ever need such a split, we can use super() in the future. There was also an unused argument, force and the order of methods was cleaned up a little (close is usually the last thing we call in the lifecycle of a session object, so it was moved to the last place among public methods). Signed-off-by: Juraj Linkeš Reviewed-by: Jeremy Spewock Reviewed-by: Luca Vizzarro --- .../remote_session/remote_session.py | 21 ++++--------------- dts/framework/remote_session/ssh_session.py | 11 +++++----- dts/framework/testbed_model/os_session.py | 12 ++++------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/dts/framework/remote_session/remote_session.py b/dts/framework/remote_session/remote_session.py index 8db26e9efc..8c580b070f 100644 --- a/dts/framework/remote_session/remote_session.py +++ b/dts/framework/remote_session/remote_session.py @@ -191,23 +191,6 @@ def _send_command(self, command: str, timeout: float, env: dict | None) -> Comma * SSHTimeoutError if the command execution times out. """ - def close(self, force: bool = False) -> None: - """Close the remote session and free all used resources. - - Args: - force: Force the closure of the connection. This may not clean up all resources. - """ - self._close(force) - - @abstractmethod - def _close(self, force: bool = False) -> None: - """Protocol specific steps needed to close the session properly. - - Args: - force: Force the closure of the connection. This may not clean up all resources. - This doesn't have to be implemented in the overloaded method. - """ - @abstractmethod def is_alive(self) -> bool: """Check whether the remote session is still responding.""" @@ -243,3 +226,7 @@ def copy_to( source_file: The file on the local filesystem. destination_file: A file or directory path on the remote Node. """ + + @abstractmethod + def close(self) -> None: + """Close the remote session and free all used resources.""" diff --git a/dts/framework/remote_session/ssh_session.py b/dts/framework/remote_session/ssh_session.py index 216bd25aed..66f8176833 100644 --- a/dts/framework/remote_session/ssh_session.py +++ b/dts/framework/remote_session/ssh_session.py @@ -74,10 +74,6 @@ def _connect(self) -> None: else: raise SSHConnectionError(self.hostname, errors) - def is_alive(self) -> bool: - """Overrides :meth:`~.remote_session.RemoteSession.is_alive`.""" - return self.session.is_connected - def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult: """Send a command and return the result of the execution. @@ -103,6 +99,10 @@ def _send_command(self, command: str, timeout: float, env: dict | None) -> Comma return CommandResult(self.name, command, output.stdout, output.stderr, output.return_code) + def is_alive(self) -> bool: + """Overrides :meth:`~.remote_session.RemoteSession.is_alive`.""" + return self.session.is_connected + def copy_from( self, source_file: str | PurePath, @@ -119,5 +119,6 @@ def copy_to( """Overrides :meth:`~.remote_session.RemoteSession.copy_to`.""" self.session.put(str(source_file), str(destination_file)) - def _close(self, force: bool = False) -> None: + def close(self) -> None: + """Overrides :meth:`~.remote_session.RemoteSession.close`.""" self.session.close() diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py index bba4aca9ce..34b0a9e749 100644 --- a/dts/framework/testbed_model/os_session.py +++ b/dts/framework/testbed_model/os_session.py @@ -88,14 +88,6 @@ def __init__( self.remote_session = create_remote_session(node_config, name, logger) self.interactive_session = create_interactive_session(node_config, logger) - def close(self, force: bool = False) -> None: - """Close the underlying remote session. - - Args: - force: Force the closure of the connection. - """ - self.remote_session.close(force) - def is_alive(self) -> bool: """Check whether the underlying remote session is still responding.""" return self.remote_session.is_alive() @@ -161,6 +153,10 @@ def create_interactive_shell( timeout, ) + def close(self) -> None: + """Close the underlying remote session.""" + self.remote_session.close() + @staticmethod @abstractmethod def _get_privileged_command(command: str) -> str: