From: Yu Watanabe Date: Tue, 16 Jul 2019 05:28:40 +0000 (+0900) Subject: test-network: add tests for routes to DNS servers provided by DHCPv4 X-Git-Tag: v243~197^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=195a18c17dea101c578b8b09f8eb1f9e0f813c1c;p=platform%2Fupstream%2Fsystemd.git test-network: add tests for routes to DNS servers provided by DHCPv4 --- 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 c980bf9..b0d0d86 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 9ef9b02..a5656d5 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',