DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nicholas Pratte <npratte@iol.unh.edu>
To: yoan.picchi@foss.arm.com, luca.vizzarro@arm.com,
	probb@iol.unh.edu, paul.szczepanek@arm.com,
	Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech,
	dmarx@iol.unh.edu, jspewock@iol.unh.edu, alex.chapman@arm.com
Cc: dev@dpdk.org, Nicholas Pratte <npratte@iol.unh.edu>
Subject: [PATCH v1 3/3] dts: rework test suite and dts runner to include test_run configs
Date: Wed, 21 Aug 2024 14:43:06 -0400	[thread overview]
Message-ID: <20240821184305.28028-5-npratte@iol.unh.edu> (raw)
In-Reply-To: <20240821184305.28028-2-npratte@iol.unh.edu>

The TestSuite object needs to access the running test run config in
order to identify the ports that need to be linked. To do this,
DTSRunner needs to be tweaked to accept test run configs to test suites,
and the TestSuite constructor needs to be reworked to accept test run
configs.

Bugzilla ID: 1478

Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
---
 dts/framework/runner.py     | 16 +++++++++++++---
 dts/framework/test_suite.py | 33 +++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/dts/framework/runner.py b/dts/framework/runner.py
index 6b6f6a05f5..a5629c2072 100644
--- a/dts/framework/runner.py
+++ b/dts/framework/runner.py
@@ -444,6 +444,7 @@ def _run_test_run(
                     tg_node,
                     build_target_config,
                     build_target_result,
+                    test_run_config,
                     test_suites_with_cases,
                 )
 
@@ -463,6 +464,7 @@ def _run_build_target(
         tg_node: TGNode,
         build_target_config: BuildTargetConfiguration,
         build_target_result: BuildTargetResult,
+        test_run_config: TestRunConfiguration,
         test_suites_with_cases: Iterable[TestSuiteWithCases],
     ) -> None:
         """Run the given build target.
@@ -477,6 +479,7 @@ def _run_build_target(
             build_target_config: A build target's test run configuration.
             build_target_result: The build target level result object associated
                 with the current build target.
+            test_run_config: The current test run configuration to be used by test suites.
             test_suites_with_cases: The test suites with test cases to run.
         """
         self._logger.set_stage(DtsStage.build_target_setup)
@@ -492,7 +495,9 @@ def _run_build_target(
             build_target_result.update_setup(Result.FAIL, e)
 
         else:
-            self._run_test_suites(sut_node, tg_node, build_target_result, test_suites_with_cases)
+            self._run_test_suites(
+                sut_node, tg_node, build_target_result, test_suites_with_cases, test_run_config
+            )
 
         finally:
             try:
@@ -509,6 +514,7 @@ def _run_test_suites(
         tg_node: TGNode,
         build_target_result: BuildTargetResult,
         test_suites_with_cases: Iterable[TestSuiteWithCases],
+        test_run_config: TestRunConfiguration,
     ) -> None:
         """Run `test_suites_with_cases` with the current build target.
 
@@ -524,12 +530,15 @@ def _run_test_suites(
             build_target_result: The build target level result object associated
                 with the current build target.
             test_suites_with_cases: The test suites with test cases to run.
+            test_run_config: The current test run config running the test suites.
         """
         end_build_target = False
         for test_suite_with_cases in test_suites_with_cases:
             test_suite_result = build_target_result.add_test_suite(test_suite_with_cases)
             try:
-                self._run_test_suite(sut_node, tg_node, test_suite_result, test_suite_with_cases)
+                self._run_test_suite(
+                    sut_node, tg_node, test_suite_result, test_run_config, test_suite_with_cases
+                )
             except BlockingTestSuiteError as e:
                 self._logger.exception(
                     f"An error occurred within {test_suite_with_cases.test_suite_class.__name__}. "
@@ -546,6 +555,7 @@ def _run_test_suite(
         sut_node: SutNode,
         tg_node: TGNode,
         test_suite_result: TestSuiteResult,
+        test_run_config: TestRunConfiguration,
         test_suite_with_cases: TestSuiteWithCases,
     ) -> None:
         """Set up, execute and tear down `test_suite_with_cases`.
@@ -572,7 +582,7 @@ def _run_test_suite(
         self._logger.set_stage(
             DtsStage.test_suite_setup, Path(SETTINGS.output_dir, test_suite_name)
         )
-        test_suite = test_suite_with_cases.test_suite_class(sut_node, tg_node)
+        test_suite = test_suite_with_cases.test_suite_class(sut_node, tg_node, test_run_config)
         try:
             self._logger.info(f"Starting test suite setup: {test_suite_name}")
             test_suite.set_up_suite()
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 694b2eba65..fd51796a06 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -20,6 +20,7 @@
 from scapy.layers.l2 import Ether  # type: ignore[import-untyped]
 from scapy.packet import Packet, Padding  # type: ignore[import-untyped]
 
+from framework.config import TestRunConfiguration
 from framework.testbed_model.port import Port, PortLink
 from framework.testbed_model.sut_node import SutNode
 from framework.testbed_model.tg_node import TGNode
@@ -64,6 +65,7 @@ class TestSuite:
 
     sut_node: SutNode
     tg_node: TGNode
+    test_run_config: TestRunConfiguration
     #: Whether the test suite is blocking. A failure of a blocking test suite
     #: will block the execution of all subsequent test suites in the current build target.
     is_blocking: ClassVar[bool] = False
@@ -78,11 +80,7 @@ class TestSuite:
     _tg_ip_address_ingress: Union[IPv4Interface, IPv6Interface]
     _tg_ip_address_egress: Union[IPv4Interface, IPv6Interface]
 
-    def __init__(
-        self,
-        sut_node: SutNode,
-        tg_node: TGNode,
-    ):
+    def __init__(self, sut_node: SutNode, tg_node: TGNode, test_run_config: TestRunConfiguration):
         """Initialize the test suite testbed information and basic configuration.
 
         Find links between ports and set up default IP addresses to be used when
@@ -91,9 +89,11 @@ def __init__(
         Args:
             sut_node: The SUT node where the test suite will run.
             tg_node: The TG node where the test suite will run.
+            test_run_config: The test run configuration that the test suite is running in.
         """
         self.sut_node = sut_node
         self.tg_node = tg_node
+        self.test_run_config = test_run_config
         self._logger = get_dts_logger(self.__class__.__name__)
         self._port_links = []
         self._process_links()
@@ -112,13 +112,22 @@ def __init__(
 
     def _process_links(self) -> None:
         """Construct links between SUT and TG ports."""
-        for sut_port in self.sut_node.ports:
-            for tg_port in self.tg_node.ports:
-                if (sut_port.identifier, sut_port.peer) == (
-                    tg_port.peer,
-                    tg_port.identifier,
-                ):
-                    self._port_links.append(PortLink(sut_port=sut_port, tg_port=tg_port))
+        sut_ports = []
+        for port in self.sut_node.ports:
+            if port.name in [
+                sut_port.name for sut_port in self.test_run_config.system_under_test_node.ports
+            ]:
+                sut_ports.append(port)
+        tg_ports = []
+        for port in self.tg_node.ports:
+            if port.name in [
+                tg_port.name for tg_port in self.test_run_config.traffic_generator_node.ports
+            ]:
+                tg_ports.append(port)
+
+        # Both the TG and SUT nodes will have an equal number of ports.
+        for i in range(len(sut_ports)):
+            self._port_links.append(PortLink(sut_ports[i], tg_ports[i]))
 
     def set_up_suite(self) -> None:
         """Set up test fixtures common to all test cases.
-- 
2.44.0


  parent reply	other threads:[~2024-08-21 18:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21 18:43 [PATCH v1 0/3] dts: rework topology definition in dts config Nicholas Pratte
2024-08-21 18:43 ` [PATCH v1 1/3] dts: rework port attributes in config module Nicholas Pratte
2024-09-04 18:18   ` Jeremy Spewock
2024-09-10 10:11   ` Juraj Linkeš
2024-08-21 18:43 ` [PATCH v1 2/3] dts: rework testbed_model Port objects to contain unique identifiers Nicholas Pratte
2024-09-04 18:18   ` Jeremy Spewock
2024-09-10 10:17   ` Juraj Linkeš
2024-08-21 18:43 ` Nicholas Pratte [this message]
2024-09-04 18:18   ` [PATCH v1 3/3] dts: rework test suite and dts runner to include test_run configs Jeremy Spewock
2024-09-10 11:05     ` Juraj Linkeš

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240821184305.28028-5-npratte@iol.unh.edu \
    --to=npratte@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=alex.chapman@arm.com \
    --cc=dev@dpdk.org \
    --cc=dmarx@iol.unh.edu \
    --cc=jspewock@iol.unh.edu \
    --cc=juraj.linkes@pantheon.tech \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).