From ffaece68bcdc3dcb01f808a210028cd7c8af2e1b Mon Sep 17 00:00:00 2001 From: borna-blazevic Date: Thu, 27 May 2021 14:50:19 +0900 Subject: [PATCH] test-network: add a testcase for DHCP static lease --- .../conf/dhcp-client-static-lease.network | 9 +++++++++ .../conf/dhcp-server-static-lease.network | 17 +++++++++++++++++ test/test-network/systemd-networkd-tests.py | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100644 test/test-network/conf/dhcp-client-static-lease.network create mode 100644 test/test-network/conf/dhcp-server-static-lease.network diff --git a/test/test-network/conf/dhcp-client-static-lease.network b/test/test-network/conf/dhcp-client-static-lease.network new file mode 100644 index 00000000000..dd0b5818222 --- /dev/null +++ b/test/test-network/conf/dhcp-client-static-lease.network @@ -0,0 +1,9 @@ +[Match] +Name=veth99 + +[Network] +IPv6AcceptRA=no +DHCP=ipv4 + +[DHCPv4] +ClientIdentifier=mac diff --git a/test/test-network/conf/dhcp-server-static-lease.network b/test/test-network/conf/dhcp-server-static-lease.network new file mode 100644 index 00000000000..0b75063dc13 --- /dev/null +++ b/test/test-network/conf/dhcp-server-static-lease.network @@ -0,0 +1,17 @@ +[Match] +Name=veth-peer + +[Network] +IPv6AcceptRA=no +Address=10.1.1.1/24 +DHCPServer=yes + +[DHCPServer] +PoolOffset=0 +PoolSize=20 +EmitDNS=yes +DNS=9.9.9.9 + +[DHCPServerStaticLease] +MACAddress=12:34:56:78:9a:bc +Address=10.1.1.3 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 0c5fe461f44..971e180b8f4 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3673,8 +3673,10 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities): units = [ '25-veth.netdev', 'dhcp-client.network', + 'dhcp-client-static-lease.network', 'dhcp-client-timezone-router.network', 'dhcp-server.network', + 'dhcp-server-static-lease.network', 'dhcp-server-timezone-router.network'] def setUp(self): @@ -3709,6 +3711,15 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities): self.assertRegex(output, '192.168.5.*') self.assertRegex(output, 'Europe/Berlin') + def test_dhcp_server_static_lease(self): + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-client-static-lease.network', 'dhcp-server-static-lease.network') + start_networkd() + self.wait_online(['veth99:routable', 'veth-peer:routable']) + + output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth99', env=env) + print(output) + self.assertIn('10.1.1.3 (DHCP4 via 10.1.1.1)', output) + class NetworkdDHCPServerRelayAgentTests(unittest.TestCase, Utilities): links = [ 'client', -- 2.47.3