test: lag_*: Ensure that links making up a LAG are compatible

Do not allow the topology matcher to setup a LAG where one link is
running at 10G while the other one runs at 1G, since the bond will
never use the 1G port as long as there the 10G link is up.
This commit is contained in:
Tobias Waldekranz
2025-02-12 23:22:10 +01:00
parent da39855cec
commit fb394db981
5 changed files with 36 additions and 9 deletions
+2 -2
View File
@@ -14,9 +14,9 @@ each test step using the `mon` interface.
from time import sleep, time
from datetime import datetime
import infamy
import infamy.lag
from infamy.util import parallel, until
class DumbLinkBreaker:
"""Encapsulates basic, dumb link-breaking ops over SSH."""
@@ -135,7 +135,7 @@ def dut_init(dut, mode, addr):
with infamy.Test() as test:
with test.step("Set up topology and attach to target DUTs"):
env = infamy.Env()
env = infamy.Env(edge_mappings=infamy.lag.edge_mappings)
dut1 = env.attach("dut1", "mgmt")
dut2 = env.attach("dut2", "mgmt")
@@ -28,6 +28,6 @@ graph "lag" {
host:mon -- dut1:mon // Monitor connection to dut2 via dut1
host:mgmt2 -- dut2:mgmt [requires="mgmt", color=lightgrey]
dut1:link1 -- dut2:link1 [color=black, fontcolor=black, penwidth=3]
dut1:link2 -- dut2:link2 [color=black, fontcolor=black, penwidth=3]
dut1:link1 -- dut2:link1 [lag=true, color=black, fontcolor=black, penwidth=3]
dut1:link2 -- dut2:link2 [lag=true, color=black, fontcolor=black, penwidth=3]
}
@@ -13,6 +13,7 @@ each failure mode step using the `mon` interface.
"""
from time import time
import infamy
import infamy.lag
from infamy.netns import TPMR
from infamy.util import parallel
@@ -120,7 +121,7 @@ def dut_init(dut, addr, peer):
with infamy.Test() as test:
with test.step("Set up topology and attach to target DUTs"):
env = infamy.Env()
env = infamy.Env(edge_mappings=infamy.lag.edge_mappings)
dut1 = env.attach("dut1")
dut2 = env.attach("dut2")
@@ -28,9 +28,9 @@ graph "lag" {
host:mon -- dut1:mon // Monitor connection to dut2 via dut1
host:mgmt2 -- dut2:mgmt [requires="mgmt", color=lightgrey]
dut1:link1 -- host:lb1a [requires="ieee-mc", color=black, fontcolor=black]
host:lb1b -- dut2:link1 [requires="ieee-mc", color=black, fontcolor=black]
dut1:link1 -- host:lb1a [requires="ieee-mc", lag=true, color=black, fontcolor=black]
host:lb1b -- dut2:link1 [requires="ieee-mc", lag=true, color=black, fontcolor=black]
dut1:link2 -- host:lb2a [requires="ieee-mc", color=black, fontcolor=black]
host:lb2b -- dut2:link2 [requires="ieee-mc", color=black, fontcolor=black]
dut1:link2 -- host:lb2a [requires="ieee-mc", lag=true, color=black, fontcolor=black]
host:lb2b -- dut2:link2 [requires="ieee-mc", lag=true, color=black, fontcolor=black]
}
+26
View File
@@ -0,0 +1,26 @@
from . import topology
def edge_mappings(les, pes):
"""Specialized topology edge mapper for LAG tests
In addition to the standard provides/requires validation, ensure
that for all logical ports marked with a "lag" attribute, the
corresponding physical ports are all of the same link type
(e.g. "link-10gbase-r").
"""
def links_compatible(candidate):
seen = None
for (le, pe) in candidate:
if le.get("lag"):
link = set(filter(lambda f: f.startswith("link-"), pe["provides"]))
if seen is None:
seen = link
elif link != seen:
return False
return True
for candidate in topology.edge_mappings(les, pes):
if links_compatible(candidate):
yield candidate