mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
test-network: add support for systemd-networkd-persistent-storage.service
This commit is contained in:
parent
91676b6458
commit
c84a5f5eaf
|
@ -888,8 +888,10 @@ class NetworkdClientTest(ClientTestBase, unittest.TestCase):
|
|||
set -eu
|
||||
mkdir -p /run/systemd/network
|
||||
mkdir -p /run/systemd/netif
|
||||
mkdir -p /var/lib/systemd/network
|
||||
mount -t tmpfs none /run/systemd/network
|
||||
mount -t tmpfs none /run/systemd/netif
|
||||
mount -t tmpfs none /var/lib/systemd/network
|
||||
[ ! -e /run/dbus ] || mount -t tmpfs none /run/dbus
|
||||
# create router/client veth pair
|
||||
cat <<EOF >/run/systemd/network/50-test.netdev
|
||||
|
@ -917,6 +919,10 @@ DNS=192.168.5.1
|
|||
{dhopts}
|
||||
EOF
|
||||
|
||||
# For the networkd instance invoked below cannot support varlink connection.
|
||||
# Hence, 'networkctl persistent-storage yes' cannot be used.
|
||||
touch /run/systemd/netif/persistent-storage-ready
|
||||
|
||||
# run networkd as in systemd-networkd.service
|
||||
exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ {{ s/^.*=//; s/^[@+-]//; s/^!*//; p}}')
|
||||
'''.format(ifr=self.if_router,
|
||||
|
@ -930,6 +936,7 @@ exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ {{ s/^.*=/
|
|||
'-p', 'InaccessibleDirectories=-/etc/systemd/network',
|
||||
'-p', 'InaccessibleDirectories=-/run/systemd/network',
|
||||
'-p', 'InaccessibleDirectories=-/run/systemd/netif',
|
||||
'-p', 'InaccessibleDirectories=-/var/lib/systemd/network',
|
||||
'--service-type=notify', script])
|
||||
|
||||
# wait until devices got created
|
||||
|
|
|
@ -378,6 +378,9 @@ def setup_systemd_udev_rules():
|
|||
continue
|
||||
cp(os.path.join(path, rule), udev_rules_dir)
|
||||
|
||||
def clear_networkd_state_files():
|
||||
rm_rf('/var/lib/systemd/network/')
|
||||
|
||||
def copy_udev_rule(*rules):
|
||||
"""Copy udev rules"""
|
||||
mkdir_p(udev_rules_dir)
|
||||
|
@ -412,8 +415,9 @@ def create_unit_dropin(unit, contents):
|
|||
f.write('\n'.join(contents))
|
||||
|
||||
def create_service_dropin(service, command, additional_settings=None):
|
||||
drop_in = [
|
||||
'[Service]',
|
||||
drop_in = ['[Service]']
|
||||
if command:
|
||||
drop_in += [
|
||||
'ExecStart=',
|
||||
f'ExecStart=!!{valgrind_cmd}{command}',
|
||||
]
|
||||
|
@ -451,6 +455,7 @@ def setup_system_units():
|
|||
for unit in [
|
||||
'systemd-networkd.service',
|
||||
'systemd-networkd.socket',
|
||||
'systemd-networkd-persistent-storage.service',
|
||||
'systemd-resolved.service',
|
||||
'systemd-timesyncd.service',
|
||||
'systemd-udevd.service',
|
||||
|
@ -487,9 +492,22 @@ def setup_system_units():
|
|||
'StartLimitIntervalSec=0',
|
||||
]
|
||||
)
|
||||
create_unit_dropin(
|
||||
'systemd-networkd-persistent-storage.service',
|
||||
[
|
||||
'[Unit]',
|
||||
'StartLimitIntervalSec=0',
|
||||
'[Service]',
|
||||
'ExecStart=',
|
||||
f'ExecStart={networkctl_bin} persistent-storage yes',
|
||||
'ExecStop=',
|
||||
f'ExecStop={networkctl_bin} persistent-storage no'
|
||||
]
|
||||
)
|
||||
|
||||
check_output('systemctl daemon-reload')
|
||||
print(check_output('systemctl cat systemd-networkd.service'))
|
||||
print(check_output('systemctl cat systemd-networkd-persistent-storage.service'))
|
||||
print(check_output('systemctl cat systemd-resolved.service'))
|
||||
print(check_output('systemctl cat systemd-timesyncd.service'))
|
||||
print(check_output('systemctl cat systemd-udevd.service'))
|
||||
|
@ -504,6 +522,7 @@ def clear_system_units():
|
|||
|
||||
rm_unit('systemd-networkd.service')
|
||||
rm_unit('systemd-networkd.socket')
|
||||
rm_unit('systemd-networkd-persistent-storage.service')
|
||||
rm_unit('systemd-resolved.service')
|
||||
rm_unit('systemd-timesyncd.service')
|
||||
rm_unit('systemd-udevd.service')
|
||||
|
@ -896,6 +915,7 @@ def tear_down_common():
|
|||
# 6. remove configs
|
||||
clear_network_units()
|
||||
clear_networkd_conf_dropins()
|
||||
clear_networkd_state_files()
|
||||
|
||||
# 7. flush settings
|
||||
flush_fou_ports()
|
||||
|
@ -909,6 +929,7 @@ def setUpModule():
|
|||
|
||||
clear_network_units()
|
||||
clear_networkd_conf_dropins()
|
||||
clear_networkd_state_files()
|
||||
clear_udev_rules()
|
||||
|
||||
setup_systemd_udev_rules()
|
||||
|
@ -928,6 +949,7 @@ def tearDownModule():
|
|||
clear_udev_rules()
|
||||
clear_network_units()
|
||||
clear_networkd_conf_dropins()
|
||||
clear_networkd_state_files()
|
||||
|
||||
restore_timezone()
|
||||
|
||||
|
|
Loading…
Reference in a new issue