Skip to content

Commit

Permalink
topotato: pass node ID into TopotatoNetwork
Browse files Browse the repository at this point in the history
Allow identifying what test class a network was created for, both for
debugging as well as special-casing.

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Sep 5, 2024
1 parent a337fa6 commit 7c3b1ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion topotato/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def setup(self):
tcls = self.getparent(TopotatoClass)
# pylint: disable=protected-access
try:
tcls.netinst = tcls.obj._setup(self.session).prepare()
tcls.netinst = tcls.obj._setup(self.session, tcls.nodeid).prepare()
except Exception as e:
e.topotato_node = self
self.parent.skipall = e
Expand Down
7 changes: 6 additions & 1 deletion topotato/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TestSetup(TopotatoNetwork, topo=topology):

timeline: Timeline
session: "ISession"
nodeid: str

_network: ClassVar["toponom.Network"]

Expand All @@ -75,10 +76,14 @@ class TestSetup(TopotatoNetwork, topo=topology):
instances, which matches the behavior implied by the type annotations.
"""

def __repr__(self):
return f"{self.__class__.__name__}(..., {self.nodeid!r})"

def make(self, name: str) -> NetworkInstance.RouterNS:
return self._params[name].instantiate()

def __init__(self, session: "ISession"):
def __init__(self, session: "ISession", nodeid: str):
self.nodeid = nodeid
super().__init__(self.__class__._network)
self.session = session
self.timeline = Timeline()
Expand Down

0 comments on commit 7c3b1ae

Please sign in to comment.