Skip to content

Commit 1c6c772

Browse files
committed
test: iface_phys_address: use chassis MAC and add until() guards
Replace fragile SSH+jq approach for reading the chassis MAC with a NETCONF query to ietf-hardware:hardware/component[name='mainboard'], reading phys-address directly from the YANG model. Also add until() polling to the chassis MAC and chassis+offset MAC verification steps, consistent with the reset-to-default steps. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 94a036b commit 1c6c772

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

  • test/case/interfaces/iface_phys_address

test/case/interfaces/iface_phys_address/test.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ def reset_mac(tgt, port):
3535

3636

3737
with infamy.Test() as test:
38-
CMD = "jq -r '.[\"mac-address\"]' /run/system.json"
39-
4038
with test.step("Set up topology and attach to target DUT"):
4139
env = infamy.Env()
4240
target = env.attach("target", "mgmt")
43-
tgtssh = env.attach("target", "mgmt", "ssh")
4441
_, tport = env.ltop.xlate("target", "data")
4542
pmac = iface.get_phys_address(target, tport)
46-
cmac = tgtssh.runsh(CMD).stdout.strip()
43+
data = target.get_data("/ietf-hardware:hardware/component[name='mainboard']")
44+
components = data.get("hardware", {}).get("component", {})
45+
cmac = components["mainboard"].get("phys-address", "") \
46+
if "mainboard" in components else ""
4747
STATIC = "02:01:00:c0:ff:ee"
4848
OFFSET = "00:00:00:00:ff:aa"
4949

@@ -88,9 +88,7 @@ def reset_mac(tgt, port):
8888
target.put_config_dict("ietf-interfaces", config)
8989

9090
with test.step("Verify target:data has chassis MAC"):
91-
mac = iface.get_phys_address(target, tport)
92-
print(f"Current MAC: {mac}, should be: {cmac}")
93-
assert mac == cmac
91+
until(lambda: iface.get_phys_address(target, tport) == cmac)
9492

9593
with test.step("Set target:data to chassis MAC + offset"):
9694
print(f"Setting chassis MAC {cmac} + offset {OFFSET}")
@@ -109,10 +107,8 @@ def reset_mac(tgt, port):
109107
target.put_config_dict("ietf-interfaces", config)
110108

111109
with test.step("Verify target:data has chassis MAC + offset"):
112-
mac = iface.get_phys_address(target, tport)
113110
BMAC = calc_mac(cmac, OFFSET)
114-
print(f"Current MAC: {mac}, should be: {BMAC} (calculated)")
115-
assert mac == BMAC
111+
until(lambda: iface.get_phys_address(target, tport) == BMAC)
116112

117113
with test.step("Reset target:data MAC address to default"):
118114
reset_mac(target, tport)

0 commit comments

Comments
 (0)