Skip to content

Commit

Permalink
tests:ethernets: wait-online DNS testing
Browse files Browse the repository at this point in the history
  • Loading branch information
slyon committed Feb 3, 2025
1 parent 8bf3f10 commit 5e8a3da
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/integration/ethernets.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ def test_link_local_disabled(self):

def test_systemd_networkd_wait_online(self):
self.addCleanup(subprocess.call, ['ip', 'link', 'del', 'br0'])
self.setup_eth(None, False)
# Start dnsmasq DNS server to validate s-d-wait-online --dns option,
# which needs to reach the DNS server at UDP/53 on self.dev_e2_ap
self.setup_eth(None, True)
with open(self.config, 'w') as f:
f.write('''network:
renderer: %(r)s
Expand All @@ -446,9 +448,17 @@ def test_systemd_networkd_wait_online(self):
addresses: ["10.0.0.1/24"]
bridges:
br0:
addresses: ["10.0.0.2/24"]
interfaces: [%(e2c)s]
''' % {'r': self.backend, 'ec_mac': self.dev_e_client_mac, 'e2c': self.dev_e2_client})
addresses: ["192.168.6.7/24"] # from self.dev_e2_ap range
nameservers:
addresses: [%(dnsip)s]
interfaces: [%(e2c)s]''' % {'r': self.backend,
'ec_mac': self.dev_e_client_mac,
'e2c': self.dev_e2_client,
'dnsip': self.dev_e2_ap_ip4.split('/')[0]})
# make sure 'findme' still gets found after the rename (we cannot match
# PermanentMacAddress on veth), so it does not get into unmanaged and
# 'no-carrier' state.
self.match_veth_by_non_permanent_mac_quirk('findme', self.dev_e_client_mac)
self.generate_and_settle([self.dev_e2_client, 'br0'])
override = os.path.join('/run', 'systemd', 'system', 'systemd-networkd-wait-online.service.d', '10-netplan.conf')
self.assertTrue(os.path.isfile(override))
Expand All @@ -460,12 +470,16 @@ def test_systemd_networkd_wait_online(self):
# <dev_e2_client> should be listed normally
self.assertEqual(f.read(), '''[Unit]
ConditionPathIsSymbolicLink=/run/systemd/generator/network-online.target.wants/systemd-networkd-wait-online.service
After=systemd-resolved.service
[Service]
ExecStart=
ExecStart=/lib/systemd/systemd-networkd-wait-online -i %(e2c)s:carrier -i br0:degraded -i findme:carrier
ExecStart=/lib/systemd/systemd-networkd-wait-online --any -o routable -i %(e2c)s -i br0
ExecStart=/lib/systemd/systemd-networkd-wait-online --any --dns -o routable -i %(e2c)s -i br0
''' % {'e2c': self.dev_e2_client})
# Restart sd-nd-wait-online.service and check that it was launched correctly.
# XXX: Enable extra testing once systemd#34640 is available on the SUT (i.e. systemd v258+).
# subprocess.check_call(['systemctl', 'restart', 'systemd-networkd-wait-online.service'])


@unittest.skipIf("NetworkManager" not in test_backends,
Expand Down

0 comments on commit 5e8a3da

Please sign in to comment.