mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-29 04:03:01 +02:00
Let's drop the leading IETF or Infix prefixes from tests. Initially the idea was to mimnic the YANG models, but it's difficult to navigate and does not provide any real benefit to developers or end-users. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
42 lines
1.2 KiB
Python
Executable File
42 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""DHCP Basic
|
|
|
|
This is a very basic DHCP test that requests an IPv4 lease
|
|
from a DHCP server and checks that the lease is set on the
|
|
interface.
|
|
|
|
"""
|
|
|
|
import infamy, infamy.dhcp
|
|
import infamy.iface as iface
|
|
from infamy.util import until
|
|
|
|
with infamy.Test() as test:
|
|
ADDRESS = '10.0.0.42'
|
|
|
|
with test.step("Initialize"):
|
|
env = infamy.Env()
|
|
client = env.attach("client", "mgmt")
|
|
_, host = env.ltop.xlate("host", "data")
|
|
|
|
with infamy.IsolatedMacVlan(host) as netns:
|
|
netns.addip("10.0.0.1")
|
|
with infamy.dhcp.Server(netns, ip=ADDRESS):
|
|
_, port = env.ltop.xlate("client", "data")
|
|
config = {
|
|
"interfaces": {
|
|
"interface": [{
|
|
"name": f"{port}",
|
|
"ipv4": {
|
|
"infix-dhcp-client:dhcp": {}
|
|
}
|
|
}]
|
|
}
|
|
}
|
|
client.put_config_dict("ietf-interfaces", config)
|
|
|
|
with test.step("Verify client lease for 10.0.0.42"):
|
|
until(lambda: iface.address_exist(client, port, ADDRESS))
|
|
|
|
test.succeed()
|