diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-16 14:28:40 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-19 01:56:14 +0900 |
commit | 195a18c17dea101c578b8b09f8eb1f9e0f813c1c (patch) | |
tree | 0178d29e94efc08e488ad436d4cc1ca0d99afe83 | |
parent | a24e12f0209b075e2db80cc3adac1c5afb17031e (diff) | |
download | systemd-195a18c17dea101c578b8b09f8eb1f9e0f813c1c.tar.gz |
test-network: add tests for routes to DNS servers provided by DHCPv4
-rw-r--r-- | test/test-network/conf/dhcp-client-ipv4-only-ipv6-disabled.network | 3 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/test/test-network/conf/dhcp-client-ipv4-only-ipv6-disabled.network b/test/test-network/conf/dhcp-client-ipv4-only-ipv6-disabled.network index c980bf9fca..b0d0d8605e 100644 --- a/test/test-network/conf/dhcp-client-ipv4-only-ipv6-disabled.network +++ b/test/test-network/conf/dhcp-client-ipv4-only-ipv6-disabled.network @@ -4,3 +4,6 @@ Name=veth99 [Network] DHCP=ipv4 IPv6AcceptRA=false + +[DHCPv4] +RoutesToDNS=yes diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 9ef9b023e9..a5656d5b72 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2384,13 +2384,47 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): start_networkd() self.wait_online(['veth-peer:carrier']) - start_dnsmasq() + start_dnsmasq(additional_options='--dhcp-option=option:dns-server,192.168.5.6,192.168.5.7', lease_time='2m') + self.wait_online(['veth99:routable', 'veth-peer:routable']) + + output = check_output(*networkctl_cmd, 'status', 'veth99', env=env) + print(output) + self.assertNotRegex(output, '2600::') + self.assertRegex(output, '192.168.5') + self.assertRegex(output, '192.168.5.6') + self.assertRegex(output, '192.168.5.7') + + # checking routes to DNS servers + output = check_output('ip route show dev veth99') + print(output) + self.assertRegex(output, r'192.168.5.1 proto dhcp scope link src 192.168.5.181 metric 1024') + self.assertRegex(output, r'192.168.5.6 proto dhcp scope link src 192.168.5.181 metric 1024') + self.assertRegex(output, r'192.168.5.7 proto dhcp scope link src 192.168.5.181 metric 1024') + + stop_dnsmasq(dnsmasq_pid_file) + start_dnsmasq(additional_options='--dhcp-option=option:dns-server,192.168.5.1,192.168.5.7,192.168.5.8', lease_time='2m') + + # Sleep for 120 sec as the dnsmasq minimum lease time can only be set to 120 + print('Wait for the dynamic address to be renewed') + time.sleep(125) + self.wait_online(['veth99:routable', 'veth-peer:routable']) output = check_output(*networkctl_cmd, 'status', 'veth99', env=env) print(output) self.assertNotRegex(output, '2600::') self.assertRegex(output, '192.168.5') + self.assertNotRegex(output, '192.168.5.6') + self.assertRegex(output, '192.168.5.7') + self.assertRegex(output, '192.168.5.8') + + # checking routes to DNS servers + output = check_output('ip route show dev veth99') + print(output) + self.assertNotRegex(output, r'192.168.5.6') + self.assertRegex(output, r'192.168.5.1 proto dhcp scope link src 192.168.5.181 metric 1024') + self.assertRegex(output, r'192.168.5.7 proto dhcp scope link src 192.168.5.181 metric 1024') + self.assertRegex(output, r'192.168.5.8 proto dhcp scope link src 192.168.5.181 metric 1024') def test_dhcp_client_ipv4_ipv6(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network', |