test: Always log logical-to-physical mappings

For tests using a logical topology, log the resulting mapping to the
physical one. This way, we always have a record of the entire
environment.
This commit is contained in:
Tobias Waldekranz
2024-05-20 16:21:06 +02:00
parent b6cf866f52
commit 7d6792a638
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -35,6 +35,8 @@ class Env(object):
if not self.ltop.map_to(self.ptop):
raise tap.TestSkip()
print(repr(self.ltop))
def attach(self, node, port, factory_default=True):
if self.ltop:
mapping = self.ltop.mapping[node]
+16
View File
@@ -51,6 +51,22 @@ class Topology:
attrs[dn] = dp
self.g.add_edge(sn, dn, **attrs)
def __repr__(self):
if not self.mapping:
return ""
out = ""
for n in self.mapping:
out += f"{n + ':':<8} {self.mapping[n][None]}\n"
for e in self.mapping[n]:
if not e:
continue
out += f" {e + ':':<8} {self.mapping[n][e]}\n"
return out
def map_to(self, phy):
mapper = isomorphism.MultiGraphMatcher(phy.g, self.g,
edge_match=match_edge,