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 25DA243EE8; Tue, 23 Apr 2024 11:13:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D280540F16; Tue, 23 Apr 2024 11:13:02 +0200 (CEST) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mails.dpdk.org (Postfix) with ESMTP id B68AD40ED6 for ; Tue, 23 Apr 2024 11:12:58 +0200 (CEST) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-56e1baf0380so6341177a12.3 for ; Tue, 23 Apr 2024 02:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1713863578; x=1714468378; 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=D8KFfjKjySeDHyHvuEdeBQcDpTwTmqzSHRmB+Cnwggo=; b=vYiEkQ40c3nTjPBSFInb0WTrilEgOhAVwaynXgc2yk0b6Ht9UXORfiAESfyxh7KNdr 94RK9SKdsDSv+Z6IhrOILZS65lbYCrCBLFWMjC814v1/mBhrjWNKRX1k44eQaUL70N7s i8ASM80Cpiaa04VaWRf4fPmWeavnksdEPH3SSzTSNzqUij2ORUL7wb94AxOMSVsWHgyO CiTUXDDtC7KNumbYf7R0dkK1AdbHOhzakHaqOIAyheczxMtuzhQu/d6tLYI5FhJNoinA /GPzNpRohqwbrqawigH/30Lcs/+DxcTwXsocXGf9ZuKIJJ2Crcj0WNegd6OIk87klIrg Ybyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713863578; x=1714468378; 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=D8KFfjKjySeDHyHvuEdeBQcDpTwTmqzSHRmB+Cnwggo=; b=LeUj7gA/ruSLkH+nQBUS7UO6iMdFhLRCzMgFp5FPRm9R2RHOqMg0fUeadb6wFufRRe 1i56XxyJVi2eR9gzraHZ6fj64zLRpDlbSV6ejgUrWvRBidhJkV1HLRIkc/0+oDCtKeUT 0X1DXwXP9PK6H6CFvKUJfH9r5NRR4AepQw7x/d+u8aKzL0AsZbj1Y6XUTwbduEPJcR6g g3/heHnTJjZ+b0Mh2LOygwjfImO3sOAi2AsQemWSOGv8DZ2RToM3qf8Do8iHXyzvcwgl uxF2QA4nQW/DuASwHiQVf6Ypv3ThBdo7A+Jud8qo6i3624oQ6mg0hMjsTQOkhoETQ7Zd aL0w== X-Gm-Message-State: AOJu0YxgYaUhmKY0cDRqsWBJnCU7D9DVqJuGJUOJ+5P4RuUlJwv5bZ52 jWbX5Hly9yMmYrgn6StmJHc/fqor1FT+L2UH7auqd8RT7CMVjJu+szE/kkDB1mqgmmrQLl76kxo +iso= X-Google-Smtp-Source: AGHT+IEofA+sGkb+sv4LYoii0OEbQ1PmechdFnInbYx3oh1Tev8MdhcIefsWHs9GUl5R00q6BcYdsA== X-Received: by 2002:a50:d5ce:0:b0:568:bfcd:e895 with SMTP id g14-20020a50d5ce000000b00568bfcde895mr6851427edj.41.1713863578401; Tue, 23 Apr 2024 02:12:58 -0700 (PDT) Received: from jlinkes-PT-Latitude-5530.pantheon.local (81.89.53.154.host.vnet.sk. [81.89.53.154]) by smtp.gmail.com with ESMTPSA id be12-20020a0564021a2c00b0056bf7f92346sm6440534edb.50.2024.04.23.02.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 02:12:57 -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?= Subject: [PATCH v1 4/4] dts: refine pre-test setup and teardown steps Date: Tue, 23 Apr 2024 11:12:52 +0200 Message-Id: <20240423091252.62924-5-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423091252.62924-1-juraj.linkes@pantheon.tech> References: <20240423091252.62924-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_execution() and _tear_down_execution() 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š --- dts/framework/testbed_model/node.py | 65 ++----------------------- dts/framework/testbed_model/sut_node.py | 49 ++++++++++++++----- 2 files changed, 40 insertions(+), 74 deletions(-) diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py index 74061f6262..1a98209822 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, - ExecutionConfiguration, - NodeConfiguration, -) +from framework.config import OS, ExecutionConfiguration, NodeConfiguration 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 @@ -65,8 +58,6 @@ class Node(ABC): ports: list[Port] _logger: DTSLogger _other_sessions: list[OSSession] - _execution_config: ExecutionConfiguration - virtual_devices: list[VirtualDevice] def __init__(self, node_config: NodeConfiguration): """Connect to the node and gather info during initialization. @@ -94,7 +85,6 @@ def __init__(self, node_config: NodeConfiguration): ).filter() self._other_sessions = [] - self.virtual_devices = [] self._init_ports() def _init_ports(self) -> None: @@ -106,67 +96,20 @@ def _init_ports(self) -> None: def set_up_execution(self, execution_config: ExecutionConfiguration) -> None: """Execution setup steps. - Configure hugepages and call :meth:`_set_up_execution` 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: execution_config: The execution test run configuration according to which the setup steps will be taken. """ self._setup_hugepages() - self._set_up_execution(execution_config) - self._execution_config = execution_config - for vdev in execution_config.vdevs: - self.virtual_devices.append(VirtualDevice(vdev)) - - def _set_up_execution(self, execution_config: ExecutionConfiguration) -> None: - """Optional additional execution setup steps for subclasses. - - Subclasses should override this if they need to add additional execution setup steps. - """ def tear_down_execution(self) -> None: """Execution teardown steps. There are currently no common execution teardown steps common to all DTS node types. - """ - self.virtual_devices = [] - self._tear_down_execution() - - def _tear_down_execution(self) -> None: - """Optional additional execution teardown steps for subclasses. - - Subclasses should override this if they need to add additional execution 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. + 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..ead6cc5a43 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -20,6 +20,7 @@ from framework.config import ( BuildTargetConfiguration, BuildTargetInfo, + ExecutionConfiguration, NodeInfo, SutNodeConfiguration, ) @@ -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_execution(self, execution_config: ExecutionConfiguration) -> None: + """Extend the execution setup with vdev config. - Additional build target setup steps on top of those in :class:`Node`. + Args: + execution_config: The execution test run configuration according to which + the setup steps will be taken. + """ + super().set_up_execution(execution_config) + for vdev in execution_config.vdevs: + self.virtual_devices.append(VirtualDevice(vdev)) + + def tear_down_execution(self) -> None: + """Extend the execution teardown with virtual device teardown.""" + super().tear_down_execution() + 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