]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add one more test for LinkLocalAddressing=fallback 12481/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 5 May 2019 15:42:05 +0000 (17:42 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 7 May 2019 15:12:09 +0000 (17:12 +0200)
test/test-network/conf/dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network [moved from test/test-network/conf/dhcp-client-with-ipv4ll-fallback.network with 100% similarity]
test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network b/test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network
new file mode 100644 (file)
index 0000000..7faff5f
--- /dev/null
@@ -0,0 +1,10 @@
+[Match]
+Name=veth99
+
+[Network]
+DHCP=ipv4
+LinkLocalAddressing=fallback
+IPv6AcceptRA=no
+
+[DHCP]
+MaxAttempts=1
index 184ab2d03a33d86939c2ddc31fdf7d1f94e7d06b..4301f8c5dc73b36fe625596249309fd1bed45c1b 100755 (executable)
@@ -1880,7 +1880,8 @@ class NetworkdNetworkDHCPClientTests(unittest.TestCase, Utilities):
         'dhcp-client-route-metric.network',
         'dhcp-client-route-table.network',
         'dhcp-client-vrf.network',
-        'dhcp-client-with-ipv4ll-fallback.network',
+        'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network',
+        'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network',
         'dhcp-client.network',
         'dhcp-server-veth-peer.network',
         'dhcp-v4-server-veth-peer.network',
@@ -2177,10 +2178,11 @@ class NetworkdNetworkDHCPClientTests(unittest.TestCase, Utilities):
         print(output)
         self.assertRegex(output, 'onlink')
 
-    def test_dhcp_client_with_ipv4ll_fallback(self):
+    def test_dhcp_client_with_ipv4ll_fallback_with_dhcp_server(self):
         self.copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
-                                             'dhcp-client-with-ipv4ll-fallback.network')
+                                             'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network')
         self.start_networkd(0)
+        self.wait_online(['veth-peer:carrier'])
         self.start_dnsmasq(lease_time='2m')
         self.wait_online(['veth99:routable', 'veth-peer:routable'])
 
@@ -2213,6 +2215,24 @@ class NetworkdNetworkDHCPClientTests(unittest.TestCase, Utilities):
 
         self.search_words_in_dnsmasq_log('DHCPOFFER', show_all=True)
 
+    def test_dhcp_client_with_ipv4ll_fallback_without_dhcp_server(self):
+        self.copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
+                                             'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network')
+        self.start_networkd(0)
+        self.wait_online(['veth99:degraded', 'veth-peer:routable'])
+
+        output = subprocess.check_output(['ip', 'address', 'show', 'dev', 'veth99']).rstrip().decode('utf-8')
+        print(output)
+
+        output = subprocess.check_output(['ip', '-6', 'address', 'show', 'dev', 'veth99', 'scope', 'global', 'dynamic']).rstrip().decode('utf-8')
+        self.assertNotRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global dynamic')
+        output = subprocess.check_output(['ip', '-6', 'address', 'show', 'dev', 'veth99', 'scope', 'link']).rstrip().decode('utf-8')
+        self.assertRegex(output, 'inet6 .* scope link')
+        output = subprocess.check_output(['ip', '-4', 'address', 'show', 'dev', 'veth99', 'scope', 'global', 'dynamic']).rstrip().decode('utf-8')
+        self.assertNotRegex(output, 'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99')
+        output = subprocess.check_output(['ip', '-4', 'address', 'show', 'dev', 'veth99', 'scope', 'link']).rstrip().decode('utf-8')
+        self.assertRegex(output, 'inet .* scope link')
+
 if __name__ == '__main__':
     unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
                                                      verbosity=3))