networkd-test: fix test_dropin()

- This test needs resolved, so make sure it is started. In some Debian
   environments it is not.
 - It was an unnecessary, and now failing assumption that name servers
   get atomically written to the resolved's resolv.conf. Wait until both
   expected name servers are in the file.
This commit is contained in:
Martin Pitt 2019-02-21 12:34:23 +01:00
parent ca56805c8d
commit f5cf985e9c

View file

@ -950,12 +950,12 @@ DNS=192.168.42.1''')
[Network] [Network]
DNS=127.0.0.1''') DNS=127.0.0.1''')
subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) subprocess.check_call(['systemctl', 'start', 'systemd-resolved', 'systemd-networkd'])
for timeout in range(50): for timeout in range(50):
with open(RESOLV_CONF) as f: with open(RESOLV_CONF) as f:
contents = f.read() contents = f.read()
if ' 127.0.0.1' in contents: if ' 127.0.0.1' in contents and '192.168.42.1' in contents:
break break
time.sleep(0.1) time.sleep(0.1)
self.assertIn('nameserver 192.168.42.1\n', contents) self.assertIn('nameserver 192.168.42.1\n', contents)