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 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=20Linke=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=20Linke=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 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 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: -- 2.34.1