]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for renewing DHCP lease
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Oct 2023 09:33:52 +0000 (18:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Oct 2023 09:33:52 +0000 (18:33 +0900)
test/test-network/systemd-networkd-tests.py

index f0b248917ce5b90841420f4ff20e7bf93b0d2041..7d1691c0940abe7962508595d71eb1006c4513a9 100755 (executable)
@@ -5271,6 +5271,31 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         print(f"DHCPv4 client state = {state}")
         self.assertEqual(state, 'stopped')
 
+        # restart dnsmasq to clear log
+        stop_dnsmasq()
+        start_dnsmasq('--dhcp-option=108,00:00:02:00')
+
+        # Test renew command
+        # See https://github.com/systemd/systemd/pull/29472#issuecomment-1759092138
+        check_output(*networkctl_cmd, 'renew', 'veth99', env=env)
+
+        for _ in range(100):
+            state = get_dhcp4_client_state('veth99')
+            if state == 'stopped':
+                break
+            time.sleep(.2)
+
+        print(f"DHCPv4 client state = {state}")
+        self.assertEqual(state, 'stopped')
+
+        print('## dnsmasq log')
+        output = read_dnsmasq_log_file()
+        print(output)
+        self.assertIn('DHCPDISCOVER(veth-peer) 12:34:56:78:9a:bc', output)
+        self.assertIn('DHCPOFFER(veth-peer)', output)
+        self.assertNotIn('DHCPREQUEST(veth-peer)', output)
+        self.assertNotIn('DHCPACK(veth-peer)', output)
+
     def test_dhcp_client_ipv6_only_with_custom_client_identifier(self):
         copy_network_unit('25-veth.netdev', '25-dhcp-server-veth-peer.network', '25-dhcp-client-ipv6-only-custom-client-identifier.network')