summaryrefslogtreecommitdiffstats
path: root/test/test-network/systemd-networkd-tests.py
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-16 07:28:40 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-18 18:56:14 +0200
commit195a18c17dea101c578b8b09f8eb1f9e0f813c1c (patch)
tree0178d29e94efc08e488ad436d4cc1ca0d99afe83 /test/test-network/systemd-networkd-tests.py
parentnetwork: add DHCPv4.RoutesToDNS= setting (diff)
downloadsystemd-195a18c17dea101c578b8b09f8eb1f9e0f813c1c.tar.xz
systemd-195a18c17dea101c578b8b09f8eb1f9e0f813c1c.zip
test-network: add tests for routes to DNS servers provided by DHCPv4
Diffstat (limited to '')
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py36
1 files changed, 35 insertions, 1 deletions
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',