mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 15:43:02 +02:00
test: new test, verify dhcp option 3 (router)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Mattias Walström
parent
a61b3b8aef
commit
6b84bb4b13
@@ -1,2 +1,3 @@
|
||||
---
|
||||
- case: dhcp_basic.py
|
||||
- case: dhcp_router.py
|
||||
|
||||
Executable
+36
@@ -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()
|
||||
Reference in New Issue
Block a user