From: Yu Watanabe Date: Fri, 5 Jul 2019 21:43:28 +0000 (+0900) Subject: test-network: add tests for DHCP.UseRoutes=no with custom route settings X-Git-Tag: v243~306 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c38d2d4d593b9d1a2aae3e58218df6f5768b3d2d;p=platform%2Fupstream%2Fsystemd.git test-network: add tests for DHCP.UseRoutes=no with custom route settings This adds test for b5799eeb0787deacb30d5984f6ac78f88f23b97e. Closes #12951. --- diff --git a/test/test-network/conf/dhcp-client-use-routes-no.network b/test/test-network/conf/dhcp-client-use-routes-no.network new file mode 100644 index 0000000..0c97ef5 --- /dev/null +++ b/test/test-network/conf/dhcp-client-use-routes-no.network @@ -0,0 +1,18 @@ +[Match] +Name=veth99 + +[Network] +DHCP=ipv4 +IPv6AcceptRA=no + +[Route] +Destination=192.168.5.0/24 + +[Route] +Destination=192.168.6.0/24 + +[Route] +Destination=192.168.7.0/24 + +[DHCP] +UseRoutes=no diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index ba8fb72..7aacad2 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2119,6 +2119,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): 'dhcp-client-listen-port.network', 'dhcp-client-route-metric.network', 'dhcp-client-route-table.network', + 'dhcp-client-use-routes-no.network', 'dhcp-client-vrf.network', 'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network', 'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network', @@ -2295,6 +2296,38 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'metric 24') + def test_dhcp_client_use_routes_no(self): + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', + 'dhcp-client-use-routes-no.network') + start_networkd() + wait_online(['veth-peer:carrier']) + start_dnsmasq(lease_time='2m') + wait_online(['veth99:routable', 'veth-peer:routable']) + + output = check_output('ip address show dev veth99 scope global') + print(output) + self.assertRegex(output, r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99') + + output = check_output('ip route show dev veth99') + print(output) + self.assertRegex(output, r'192.168.5.0/24 proto kernel scope link src 192.168.5.[0-9]*') + self.assertRegex(output, r'192.168.5.0/24 proto static') + self.assertRegex(output, r'192.168.6.0/24 proto static') + self.assertRegex(output, r'192.168.7.0/24 proto static') + + # 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) + + wait_online(['veth99:routable']) + + output = check_output('ip route show dev veth99') + print(output) + self.assertRegex(output, r'192.168.5.0/24 proto kernel scope link src 192.168.5.[0-9]*') + self.assertRegex(output, r'192.168.5.0/24 proto static') + self.assertRegex(output, r'192.168.6.0/24 proto static') + self.assertRegex(output, r'192.168.7.0/24 proto static') + def test_dhcp_keep_configuration_dhcp(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-v4-server-veth-peer.network', 'dhcp-client-keep-configuration-dhcp.network') start_networkd()