[v4,1/7] dts: enable arch self-discovery

Message ID 20250124113909.137128-2-luca.vizzarro@arm.com (mailing list archive)
State Accepted
Delegated to: Paul Szczepanek
Headers
Series dts: refactor configuration |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation warning apply patch failure
ci/iol-testing warning apply patch failure

Commit Message

Luca Vizzarro Jan. 24, 2025, 11:39 a.m. UTC
From: Nicholas Pratte <npratte@iol.unh.edu>

The 'arch' attribute in the conf.yaml is unnecessary, as this can be
readily discovered directly from any given node.

Bugzilla ID: 1360

Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
Reviewed-by: Dean Marx <dmarx@iol.unh.edu>
---
 dts/conf.yaml                                | 2 --
 dts/framework/config/__init__.py             | 2 --
 dts/framework/testbed_model/node.py          | 3 +++
 dts/framework/testbed_model/os_session.py    | 8 ++++++++
 dts/framework/testbed_model/posix_session.py | 4 ++++
 5 files changed, 15 insertions(+), 4 deletions(-)
  

Comments

Nicholas Pratte Jan. 24, 2025, 6:09 p.m. UTC | #1
Reviewed-by: Nicholas Pratte <npratte@iol.unh.edu>

On Fri, Jan 24, 2025 at 6:39 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:
>
> From: Nicholas Pratte <npratte@iol.unh.edu>
>
> The 'arch' attribute in the conf.yaml is unnecessary, as this can be
> readily discovered directly from any given node.
>
> Bugzilla ID: 1360
>
> Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
> Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
> Reviewed-by: Dean Marx <dmarx@iol.unh.edu>
> ---
>  dts/conf.yaml                                | 2 --
>  dts/framework/config/__init__.py             | 2 --
>  dts/framework/testbed_model/node.py          | 3 +++
>  dts/framework/testbed_model/os_session.py    | 8 ++++++++
>  dts/framework/testbed_model/posix_session.py | 4 ++++
>  5 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/dts/conf.yaml b/dts/conf.yaml
> index f83dbb0e90..80aba0d63a 100644
> --- a/dts/conf.yaml
> +++ b/dts/conf.yaml
> @@ -42,7 +42,6 @@ nodes:
>    - name: "SUT 1"
>      hostname: sut1.change.me.localhost
>      user: dtsuser
> -    arch: x86_64
>      os: linux
>      lcores: "" # use all the available logical cores
>      use_first_core: false # tells DPDK to use any physical core
> @@ -68,7 +67,6 @@ nodes:
>    - name: "TG 1"
>      hostname: tg1.change.me.localhost
>      user: dtsuser
> -    arch: x86_64
>      os: linux
>      ports:
>        # sets up the physical link between "TG 1"@0000:00:08.0 and "SUT 1"@0000:00:08.0
> diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
> index 6bf4885815..1127c6474a 100644
> --- a/dts/framework/config/__init__.py
> +++ b/dts/framework/config/__init__.py
> @@ -191,8 +191,6 @@ class NodeConfiguration(FrozenModel):
>      user: str
>      #: The password of the user. The use of passwords is heavily discouraged, please use SSH keys.
>      password: str | None = None
> -    #: The architecture of the :class:`~framework.testbed_model.node.Node`.
> -    arch: Architecture
>      #: The operating system of the :class:`~framework.testbed_model.node.Node`.
>      os: OS
>      #: A comma delimited list of logical cores to use when running DPDK.
> diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
> index c6f12319ca..c56872aa99 100644
> --- a/dts/framework/testbed_model/node.py
> +++ b/dts/framework/testbed_model/node.py
> @@ -17,6 +17,7 @@
>
>  from framework.config import (
>      OS,
> +    Architecture,
>      DPDKBuildConfiguration,
>      NodeConfiguration,
>      TestRunConfiguration,
> @@ -57,6 +58,7 @@ class Node(ABC):
>      main_session: OSSession
>      config: NodeConfiguration
>      name: str
> +    arch: Architecture
>      lcores: list[LogicalCore]
>      ports: list[Port]
>      _logger: DTSLogger
> @@ -79,6 +81,7 @@ def __init__(self, node_config: NodeConfiguration):
>          self.name = node_config.name
>          self._logger = get_dts_logger(self.name)
>          self.main_session = create_session(self.config, self.name, self._logger)
> +        self.arch = Architecture(self.main_session.get_arch_info())
>
>          self._logger.info(f"Connected to node: {self.name}")
>
> diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py
> index 28eccc05ed..30d781c355 100644
> --- a/dts/framework/testbed_model/os_session.py
> +++ b/dts/framework/testbed_model/os_session.py
> @@ -507,6 +507,14 @@ def get_node_info(self) -> OSSessionInfo:
>              Node information.
>          """
>
> +    @abstractmethod
> +    def get_arch_info(self) -> str:
> +        """Discover CPU architecture of the remote host.
> +
> +        Returns:
> +            Remote host CPU architecture.
> +        """
> +
>      @abstractmethod
>      def update_ports(self, ports: list[Port]) -> None:
>          """Get additional information about ports from the operating system and update them.
> diff --git a/dts/framework/testbed_model/posix_session.py b/dts/framework/testbed_model/posix_session.py
> index 29e314db6e..220618cacc 100644
> --- a/dts/framework/testbed_model/posix_session.py
> +++ b/dts/framework/testbed_model/posix_session.py
> @@ -404,3 +404,7 @@ def get_node_info(self) -> OSSessionInfo:
>          ).stdout.split("\n")
>          kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
>          return OSSessionInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
> +
> +    def get_arch_info(self) -> str:
> +        """Overrides :meth'~.os_session.OSSession.get_arch_info'."""
> +        return self.send_command("uname -m").stdout.strip()
> --
> 2.43.0
>
  

Patch

diff --git a/dts/conf.yaml b/dts/conf.yaml
index f83dbb0e90..80aba0d63a 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -42,7 +42,6 @@  nodes:
   - name: "SUT 1"
     hostname: sut1.change.me.localhost
     user: dtsuser
-    arch: x86_64
     os: linux
     lcores: "" # use all the available logical cores
     use_first_core: false # tells DPDK to use any physical core
@@ -68,7 +67,6 @@  nodes:
   - name: "TG 1"
     hostname: tg1.change.me.localhost
     user: dtsuser
-    arch: x86_64
     os: linux
     ports:
       # sets up the physical link between "TG 1"@0000:00:08.0 and "SUT 1"@0000:00:08.0
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 6bf4885815..1127c6474a 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -191,8 +191,6 @@  class NodeConfiguration(FrozenModel):
     user: str
     #: The password of the user. The use of passwords is heavily discouraged, please use SSH keys.
     password: str | None = None
-    #: The architecture of the :class:`~framework.testbed_model.node.Node`.
-    arch: Architecture
     #: The operating system of the :class:`~framework.testbed_model.node.Node`.
     os: OS
     #: A comma delimited list of logical cores to use when running DPDK.
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index c6f12319ca..c56872aa99 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -17,6 +17,7 @@ 
 
 from framework.config import (
     OS,
+    Architecture,
     DPDKBuildConfiguration,
     NodeConfiguration,
     TestRunConfiguration,
@@ -57,6 +58,7 @@  class Node(ABC):
     main_session: OSSession
     config: NodeConfiguration
     name: str
+    arch: Architecture
     lcores: list[LogicalCore]
     ports: list[Port]
     _logger: DTSLogger
@@ -79,6 +81,7 @@  def __init__(self, node_config: NodeConfiguration):
         self.name = node_config.name
         self._logger = get_dts_logger(self.name)
         self.main_session = create_session(self.config, self.name, self._logger)
+        self.arch = Architecture(self.main_session.get_arch_info())
 
         self._logger.info(f"Connected to node: {self.name}")
 
diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py
index 28eccc05ed..30d781c355 100644
--- a/dts/framework/testbed_model/os_session.py
+++ b/dts/framework/testbed_model/os_session.py
@@ -507,6 +507,14 @@  def get_node_info(self) -> OSSessionInfo:
             Node information.
         """
 
+    @abstractmethod
+    def get_arch_info(self) -> str:
+        """Discover CPU architecture of the remote host.
+
+        Returns:
+            Remote host CPU architecture.
+        """
+
     @abstractmethod
     def update_ports(self, ports: list[Port]) -> None:
         """Get additional information about ports from the operating system and update them.
diff --git a/dts/framework/testbed_model/posix_session.py b/dts/framework/testbed_model/posix_session.py
index 29e314db6e..220618cacc 100644
--- a/dts/framework/testbed_model/posix_session.py
+++ b/dts/framework/testbed_model/posix_session.py
@@ -404,3 +404,7 @@  def get_node_info(self) -> OSSessionInfo:
         ).stdout.split("\n")
         kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
         return OSSessionInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
+
+    def get_arch_info(self) -> str:
+        """Overrides :meth'~.os_session.OSSession.get_arch_info'."""
+        return self.send_command("uname -m").stdout.strip()