]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add a testcase for DHCP static lease 19743/head
authorborna-blazevic <borna.blazevic@sartura.hr>
Thu, 27 May 2021 05:50:19 +0000 (14:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 27 May 2021 06:57:33 +0000 (15:57 +0900)
test/test-network/conf/dhcp-client-static-lease.network [new file with mode: 0644]
test/test-network/conf/dhcp-server-static-lease.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

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 (file)
index 0000000..dd0b581
--- /dev/null
@@ -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 (file)
index 0000000..0b75063
--- /dev/null
@@ -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
index 0c5fe461f44be2e8098400052be3b38545f7c612..971e180b8f4453572b938c4897b41599810919f9 100755 (executable)
@@ -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',