diff options
| author | Luca Vizzarro <[email protected]> | 2024-10-28 12:16:31 +0000 |
|---|---|---|
| committer | Luca Vizzarro <[email protected]> | 2024-11-08 18:39:29 +0100 |
| commit | c72ff85d259287c7ec9880b94891310050fe54e6 (patch) | |
| tree | fbb252f983a89e2b7a10d33704cafc44a33ef94b | |
| parent | c64af3c7a80ee76a771017b56487be1062c7ae1f (diff) | |
dts: refactor build and node info classes
The DPDKBuildInfo and NodeInfo classes, representing information
gathered in runtime, were erroneously placed in the configuration
package. This moves them in more appropriate modules.
NodeInfo, specifically, is moved to os_session instead of node mostly
as a consequence of circular dependencies. And given os_session is the
top-most module to reference it, it appears to be the most suitable
place outside of node.
Finally NodeInfo, is better renamed to OSSessionInfo as it represents
the information on the target OS session.
Signed-off-by: Luca Vizzarro <[email protected]>
Reviewed-by: Paul Szczepanek <[email protected]>
Reviewed-by: Nicholas Pratte <[email protected]>
Reviewed-by: Patrick Robb <[email protected]>
| -rw-r--r-- | dts/framework/config/__init__.py | 31 | ||||
| -rw-r--r-- | dts/framework/test_result.py | 6 | ||||
| -rw-r--r-- | dts/framework/testbed_model/os_session.py | 23 | ||||
| -rw-r--r-- | dts/framework/testbed_model/posix_session.py | 8 | ||||
| -rw-r--r-- | dts/framework/testbed_model/sut_node.py | 22 |
5 files changed, 46 insertions, 44 deletions
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py index d0d95d00c7..7403ccbf14 100644 --- a/dts/framework/config/__init__.py +++ b/dts/framework/config/__init__.py @@ -319,24 +319,6 @@ class TGNodeConfiguration(NodeConfiguration): @dataclass(slots=True, frozen=True) -class NodeInfo: - """Supplemental node information. - - Attributes: - os_name: The name of the running operating system of - the :class:`~framework.testbed_model.node.Node`. - os_version: The version of the running operating system of - the :class:`~framework.testbed_model.node.Node`. - kernel_version: The kernel version of the running operating system of - the :class:`~framework.testbed_model.node.Node`. - """ - - os_name: str - os_version: str - kernel_version: str - - -@dataclass(slots=True, frozen=True) class DPDKBuildConfiguration: """DPDK build configuration. @@ -494,19 +476,6 @@ class DPDKConfiguration: @dataclass(slots=True, frozen=True) -class DPDKBuildInfo: - """Various versions and other information about a DPDK build. - - Attributes: - dpdk_version: The DPDK version that was built. - compiler_version: The version of the compiler used to build DPDK. - """ - - dpdk_version: str | None - compiler_version: str | None - - -@dataclass(slots=True, frozen=True) class TestSuiteConfig: """Test suite configuration. diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py index 00263ad69e..6014d281b5 100644 --- a/dts/framework/test_result.py +++ b/dts/framework/test_result.py @@ -30,11 +30,13 @@ from typing import Union from framework.testbed_model.capability import Capability -from .config import DPDKBuildInfo, NodeInfo, TestRunConfiguration, TestSuiteConfig +from .config import TestRunConfiguration, TestSuiteConfig from .exception import DTSError, ErrorSeverity from .logger import DTSLogger from .settings import SETTINGS from .test_suite import TestCase, TestSuite +from .testbed_model.os_session import OSSessionInfo +from .testbed_model.sut_node import DPDKBuildInfo @dataclass(slots=True, frozen=True) @@ -421,7 +423,7 @@ class TestRunResult(BaseResult): ) self._test_suites_with_cases = test_suites_with_cases - def add_sut_info(self, sut_info: NodeInfo) -> None: + def add_sut_info(self, sut_info: OSSessionInfo) -> None: """Add SUT information gathered at runtime. Args: diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py index 6194ddb989..db37424954 100644 --- a/dts/framework/testbed_model/os_session.py +++ b/dts/framework/testbed_model/os_session.py @@ -24,11 +24,12 @@ Example: """ from abc import ABC, abstractmethod from collections.abc import Iterable +from dataclasses import dataclass from ipaddress import IPv4Interface, IPv6Interface from pathlib import Path, PurePath, PurePosixPath from typing import Union -from framework.config import Architecture, NodeConfiguration, NodeInfo +from framework.config import Architecture, NodeConfiguration from framework.logger import DTSLogger from framework.remote_session import ( InteractiveRemoteSession, @@ -44,6 +45,24 @@ from .cpu import LogicalCore from .port import Port +@dataclass(slots=True, frozen=True) +class OSSessionInfo: + """Supplemental OS session information. + + Attributes: + os_name: The name of the running operating system of + the :class:`~framework.testbed_model.node.Node`. + os_version: The version of the running operating system of + the :class:`~framework.testbed_model.node.Node`. + kernel_version: The kernel version of the running operating system of + the :class:`~framework.testbed_model.node.Node`. + """ + + os_name: str + os_version: str + kernel_version: str + + class OSSession(ABC): """OS-unaware to OS-aware translation API definition. @@ -482,7 +501,7 @@ class OSSession(ABC): """ @abstractmethod - def get_node_info(self) -> NodeInfo: + def get_node_info(self) -> OSSessionInfo: """Collect additional information about the node. Returns: diff --git a/dts/framework/testbed_model/posix_session.py b/dts/framework/testbed_model/posix_session.py index 5ab7c18fb7..d7a1f38cad 100644 --- a/dts/framework/testbed_model/posix_session.py +++ b/dts/framework/testbed_model/posix_session.py @@ -15,7 +15,7 @@ import re from collections.abc import Iterable from pathlib import Path, PurePath, PurePosixPath -from framework.config import Architecture, NodeInfo +from framework.config import Architecture from framework.exception import DPDKBuildError, RemoteCommandExecutionError from framework.settings import SETTINGS from framework.utils import ( @@ -26,7 +26,7 @@ from framework.utils import ( extract_tarball, ) -from .os_session import OSSession +from .os_session import OSSession, OSSessionInfo class PosixSession(OSSession): @@ -386,11 +386,11 @@ class PosixSession(OSSession): case _: raise ValueError(f"Unknown compiler {compiler_name}") - def get_node_info(self) -> NodeInfo: + def get_node_info(self) -> OSSessionInfo: """Overrides :meth:`~.os_session.OSSession.get_node_info`.""" os_release_info = self.send_command( "awk -F= '$1 ~ /^NAME$|^VERSION$/ {print $2}' /etc/os-release", SETTINGS.timeout, ).stdout.split("\n") kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout - return NodeInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version) + return OSSessionInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version) diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index e160386324..5474d436a1 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -14,13 +14,12 @@ An SUT node is where this SUT runs. import os import time +from dataclasses import dataclass from pathlib import PurePath from framework.config import ( DPDKBuildConfiguration, - DPDKBuildInfo, DPDKLocation, - NodeInfo, SutNodeConfiguration, TestRunConfiguration, ) @@ -30,10 +29,23 @@ from framework.remote_session.remote_session import CommandResult from framework.utils import MesonArgs, TarCompressionFormat from .node import Node -from .os_session import OSSession +from .os_session import OSSession, OSSessionInfo from .virtual_device import VirtualDevice +@dataclass(slots=True, frozen=True) +class DPDKBuildInfo: + """Various versions and other information about a DPDK build. + + Attributes: + dpdk_version: The DPDK version that was built. + compiler_version: The version of the compiler used to build DPDK. + """ + + dpdk_version: str | None + compiler_version: str | None + + class SutNode(Node): """The system under test node. @@ -63,7 +75,7 @@ class SutNode(Node): _app_compile_timeout: float _dpdk_kill_session: OSSession | None _dpdk_version: str | None - _node_info: NodeInfo | None + _node_info: OSSessionInfo | None _compiler_version: str | None _path_to_devbind_script: PurePath | None _ports_bound_to_dpdk: bool @@ -125,7 +137,7 @@ class SutNode(Node): return self._dpdk_version @property - def node_info(self) -> NodeInfo: + def node_info(self) -> OSSessionInfo: """Additional node information.""" if self._node_info is None: self._node_info = self.main_session.get_node_info() |
