On 26. 8. 2024 18:54, Jeremy Spewock wrote:
I just had one question below, otherwise:

Reviewed-by: Jeremy Spewock <jspew...@iol.unh.edu>

On Wed, Aug 21, 2024 at 10:53 AM Juraj Linkeš
<juraj.lin...@pantheon.tech> wrote:
<snip>
diff --git a/dts/framework/testbed_model/topology.py 
b/dts/framework/testbed_model/topology.py
new file mode 100644
index 0000000000..19632ee890
--- /dev/null
+++ b/dts/framework/testbed_model/topology.py
<snip>
+
+
+class TopologyType(IntEnum):
+    """Supported topology types."""
+
+    #: A topology with no Traffic Generator.
+    no_link = 0
+    #: A topology with one physical link between the SUT node and the TG node.
+    one_link = 1
+    #: A topology with two physical links between the Sut node and the TG node.
+    two_links = 2
+
+
+class Topology:
+    """Testbed topology.
+
+    The topology contains ports processed into ingress and egress ports.
+    It's assumed that port0 of the SUT node is connected to port0 of the TG 
node and so on.

Do we need to make this assumption when you are comparing the port
directly to its peer and matching the addresses? I think you could
specify in conf.yaml that port 0 on the SUT is one of your ports and
its peer is port 1 on the TG and because you do the matching, this
would work fine.


Yes, the assumption is not adhered to yet. I guess I put this here because we've been discussing this in the calls, but the actual code doesn't use this. I'll remove this line.

+    If there are no ports on a node, dummy ports (ports with no actual values) 
are stored.
+    If there is only one link available, the ports of this link are stored
+    as both ingress and egress ports.
+
+    The dummy ports shouldn't be used. It's up to 
:class:`~framework.runner.DTSRunner`
+    to ensure no test case or suite requiring actual links is executed
+    when the topology prohibits it and up to the developers to make sure that 
test cases
+    not requiring any links don't use any ports. Otherwise, the underlying 
methods
+    using the ports will fail.
+
+    Attributes:
+        type: The type of the topology.
+        tg_port_egress: The egress port of the TG node.
+        sut_port_ingress: The ingress port of the SUT node.
+        sut_port_egress: The egress port of the SUT node.
+        tg_port_ingress: The ingress port of the TG node.
+    """
+
+    type: TopologyType
+    tg_port_egress: Port
+    sut_port_ingress: Port
+    sut_port_egress: Port
+    tg_port_ingress: Port
+
+    def __init__(self, sut_ports: Iterable[Port], tg_ports: Iterable[Port]):
+        """Create the topology from `sut_ports` and `tg_ports`.
+
+        Args:
+            sut_ports: The SUT node's ports.
+            tg_ports: The TG node's ports.
+        """
+        port_links = []
+        for sut_port in sut_ports:
+            for tg_port in tg_ports:
+                if (sut_port.identifier, sut_port.peer) == (
+                    tg_port.peer,
+                    tg_port.identifier,
+                ):
+                    port_links.append(PortLink(sut_port=sut_port, 
tg_port=tg_port))
+
+        self.type = TopologyType(len(port_links))
<snip>


Reply via email to