mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
test-network: add tests for DHCP.UseRoutes=no with custom route settings
This adds test for b5799eeb07
.
Closes #12951.
This commit is contained in:
parent
1ccbb359a1
commit
c38d2d4d59
18
test/test-network/conf/dhcp-client-use-routes-no.network
Normal file
18
test/test-network/conf/dhcp-client-use-routes-no.network
Normal file
@ -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
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user