From 6b84bb4b137389085331648bedd1209c0beaf9f8 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 14 Dec 2023 10:41:25 +0100 Subject: [PATCH] test: new test, verify dhcp option 3 (router) Signed-off-by: Joachim Wiberg --- test/case/infix_dhcp/all.yaml | 1 + test/case/infix_dhcp/dhcp_router.py | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 test/case/infix_dhcp/dhcp_router.py diff --git a/test/case/infix_dhcp/all.yaml b/test/case/infix_dhcp/all.yaml index 6de11c86..d185d99c 100644 --- a/test/case/infix_dhcp/all.yaml +++ b/test/case/infix_dhcp/all.yaml @@ -1,2 +1,3 @@ --- - case: dhcp_basic.py +- case: dhcp_router.py diff --git a/test/case/infix_dhcp/dhcp_router.py b/test/case/infix_dhcp/dhcp_router.py new file mode 100755 index 00000000..c686f8fe --- /dev/null +++ b/test/case/infix_dhcp/dhcp_router.py @@ -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()