test: new test, verify dhcp option 3 (router)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-12-14 16:40:41 +01:00
committed by Mattias Walström
parent a61b3b8aef
commit 6b84bb4b13
2 changed files with 37 additions and 0 deletions
+1
View File
@@ -1,2 +1,3 @@
---
- case: dhcp_basic.py
- case: dhcp_router.py
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# Verify DHCP option 3 (router)
import time
import infamy, infamy.dhcp
import infamy.iface as iface
import infamy.route as route
from infamy.util import until
with infamy.Test() as test:
ROUTER = '192.168.0.254'
with test.step("Initialize"):
env = infamy.Env(infamy.std_topology("1x2"))
target = env.attach("target", "mgmt")
_, host = env.ltop.xlate("host", "data")
with infamy.IsolatedMacVlan(host) as netns:
netns.addip("192.168.0.1")
with infamy.dhcp.Server(netns, router=ROUTER):
_, port = env.ltop.xlate("target", "data")
config = {
"dhcp-client": {
"client-if": [{
"if-name": f"{port}",
"option": [
{ "name": "router" }
]
}]
}
}
target.put_config_dict("infix-dhcp-client", config)
with test.step(f"Wait for client to set up default route via {ROUTER}"):
until(lambda: route.ipv4_route_exist(target, "0.0.0.0/0", ROUTER))
test.succeed()