]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd-test: first wait for interface being configured
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 31 May 2024 01:56:30 +0000 (10:56 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 31 May 2024 08:00:21 +0000 (10:00 +0200)
DNS setting propagation to resolved may take some time.

test/networkd-test.py

index 7911c816d719ef915d3c8a8a4ca586a322674b07..47a3ad79632f9343b011c97d296651e4b2d2442d 100755 (executable)
@@ -1024,17 +1024,19 @@ DNS=127.0.0.1
         self.start_unit('systemd-resolved')
         self.start_unit('systemd-networkd')
 
-        for timeout in range(50):
+        subprocess.check_call([NETWORKD_WAIT_ONLINE, '--interface', 'dummy0', '--timeout=10'])
+
+        out = subprocess.check_output(['networkctl', 'status', 'dummy0'])
+        self.assertIn(b'50-test.network.d/dns.conf', out)
+
+        for _ in range(50):
             with open(RESOLV_CONF) as f:
                 contents = f.read()
-            if ' 127.0.0.1' in contents and '192.168.42.1' in contents:
+            if 'nameserver 127.0.0.1\n' in contents and 'nameserver 192.168.42.1\n' in contents:
                 break
             time.sleep(0.1)
-        self.assertIn('nameserver 192.168.42.1\n', contents)
-        self.assertIn('nameserver 127.0.0.1\n', contents)
-
-        out = subprocess.check_output(['networkctl', 'status', 'dummy0'])
-        self.assertIn(b'50-test.network.d/dns.conf', out)
+        else:
+            self.fail(f'Expected DNS servers not found in resolv.conf: {contents}')
 
     def test_dhcp_timezone(self):
         '''networkd sets time zone from DHCP'''