Files
Mattias Walström f50f6add9c test: veth_delete: Adapt to new yangerd
Operational is now not instantly availible, is some lag.
2026-06-27 08:41:21 +02:00

104 lines
3.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""Verify that VETH pairs can be deleted
```
veth0b veth0a data1 data2
`---------'
```
Each test step to create, add address, or delete an interace is distinct
from any other step. This to trigger a new configuration "generation".
"""
import infamy
import infamy.iface as iface
from infamy.util import until
with infamy.Test() as test:
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
target = env.attach("target", "mgmt")
_, data1 = env.ltop.xlate("target", "data1")
_, data2 = env.ltop.xlate("target", "data2")
veth0a = "veth0a"
veth0b = "veth0b"
with test.step("Create VETH pair"):
target.put_config_dicts({"ietf-interfaces": {
"interfaces": {
"interface": [
{
"name": veth0a,
"type": "infix-if-type:veth",
"enabled": True,
"infix-interfaces:veth": {
"peer": veth0b
}
},
{
"name": veth0b,
"type": "infix-if-type:veth",
"enabled": True,
"infix-interfaces:veth": {
"peer": veth0a
}
}
]
}
}})
with test.step("Verify interfaces 'veth0a' and 'veth0b' exist"):
until(lambda: iface.exist(target, veth0a), attempts=30)
until(lambda: iface.exist(target, veth0b))
with test.step("Set IP address on target:data1 (dummy op)"):
target.put_config_dicts({"ietf-interfaces": {
"interfaces": {
"interface": [{
"name": f"{data1}",
"ipv4": {
"address": [{
"ip": "10.0.0.1",
"prefix-length": 24
}]
}
}]
}
}})
with test.step("Set IP address on target:data2 (dummy op)"):
target.put_config_dicts({"ietf-interfaces": {
"interfaces": {
"interface": [{
"name": f"{data2}",
"ipv4": {
"address": [{
"ip": "20.0.0.1",
"prefix-length": 24
}]
}
}]
}
}})
with test.step("Delete VETH pair"):
# Both ends are mutually mandatory leafrefs, so they must be
# removed in a single transaction.
target.delete_xpaths([
f"/ietf-interfaces:interfaces/interface[name='{veth0a}']",
f"/ietf-interfaces:interfaces/interface[name='{veth0b}']",
])
with test.step("Verify target:data1 and target:data2 still exist"):
until(lambda: iface.exist(target, data1))
until(lambda: iface.exist(target, data2))
with test.step("Verify VETH pair have been removed"):
until(lambda: not iface.exist(target, veth0a))
until(lambda: not iface.exist(target, veth0b))
test.succeed()