mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +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
|
set -eu
|
||||||
mkdir -p /run/systemd/network
|
mkdir -p /run/systemd/network
|
||||||
mkdir -p /run/systemd/netif
|
mkdir -p /run/systemd/netif
|
||||||
|
mkdir -p /var/lib/systemd/network
|
||||||
mount -t tmpfs none /run/systemd/network
|
mount -t tmpfs none /run/systemd/network
|
||||||
mount -t tmpfs none /run/systemd/netif
|
mount -t tmpfs none /run/systemd/netif
|
||||||
|
mount -t tmpfs none /var/lib/systemd/network
|
||||||
[ ! -e /run/dbus ] || mount -t tmpfs none /run/dbus
|
[ ! -e /run/dbus ] || mount -t tmpfs none /run/dbus
|
||||||
# create router/client veth pair
|
# create router/client veth pair
|
||||||
cat <<EOF >/run/systemd/network/50-test.netdev
|
cat <<EOF >/run/systemd/network/50-test.netdev
|
||||||
|
@ -917,6 +919,10 @@ DNS=192.168.5.1
|
||||||
{dhopts}
|
{dhopts}
|
||||||
EOF
|
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
|
# run networkd as in systemd-networkd.service
|
||||||
exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ {{ s/^.*=//; s/^[@+-]//; s/^!*//; p}}')
|
exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ {{ s/^.*=//; s/^[@+-]//; s/^!*//; p}}')
|
||||||
'''.format(ifr=self.if_router,
|
'''.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=-/etc/systemd/network',
|
||||||
'-p', 'InaccessibleDirectories=-/run/systemd/network',
|
'-p', 'InaccessibleDirectories=-/run/systemd/network',
|
||||||
'-p', 'InaccessibleDirectories=-/run/systemd/netif',
|
'-p', 'InaccessibleDirectories=-/run/systemd/netif',
|
||||||
|
'-p', 'InaccessibleDirectories=-/var/lib/systemd/network',
|
||||||
'--service-type=notify', script])
|
'--service-type=notify', script])
|
||||||
|
|
||||||
# wait until devices got created
|
# wait until devices got created
|
||||||
|
|
|
@ -378,6 +378,9 @@ def setup_systemd_udev_rules():
|
||||||
continue
|
continue
|
||||||
cp(os.path.join(path, rule), udev_rules_dir)
|
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):
|
def copy_udev_rule(*rules):
|
||||||
"""Copy udev rules"""
|
"""Copy udev rules"""
|
||||||
mkdir_p(udev_rules_dir)
|
mkdir_p(udev_rules_dir)
|
||||||
|
@ -412,11 +415,12 @@ def create_unit_dropin(unit, contents):
|
||||||
f.write('\n'.join(contents))
|
f.write('\n'.join(contents))
|
||||||
|
|
||||||
def create_service_dropin(service, command, additional_settings=None):
|
def create_service_dropin(service, command, additional_settings=None):
|
||||||
drop_in = [
|
drop_in = ['[Service]']
|
||||||
'[Service]',
|
if command:
|
||||||
'ExecStart=',
|
drop_in += [
|
||||||
f'ExecStart=!!{valgrind_cmd}{command}',
|
'ExecStart=',
|
||||||
]
|
f'ExecStart=!!{valgrind_cmd}{command}',
|
||||||
|
]
|
||||||
if enable_debug:
|
if enable_debug:
|
||||||
drop_in += ['Environment=SYSTEMD_LOG_LEVEL=debug']
|
drop_in += ['Environment=SYSTEMD_LOG_LEVEL=debug']
|
||||||
if asan_options:
|
if asan_options:
|
||||||
|
@ -451,6 +455,7 @@ def setup_system_units():
|
||||||
for unit in [
|
for unit in [
|
||||||
'systemd-networkd.service',
|
'systemd-networkd.service',
|
||||||
'systemd-networkd.socket',
|
'systemd-networkd.socket',
|
||||||
|
'systemd-networkd-persistent-storage.service',
|
||||||
'systemd-resolved.service',
|
'systemd-resolved.service',
|
||||||
'systemd-timesyncd.service',
|
'systemd-timesyncd.service',
|
||||||
'systemd-udevd.service',
|
'systemd-udevd.service',
|
||||||
|
@ -487,9 +492,22 @@ def setup_system_units():
|
||||||
'StartLimitIntervalSec=0',
|
'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')
|
check_output('systemctl daemon-reload')
|
||||||
print(check_output('systemctl cat systemd-networkd.service'))
|
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-resolved.service'))
|
||||||
print(check_output('systemctl cat systemd-timesyncd.service'))
|
print(check_output('systemctl cat systemd-timesyncd.service'))
|
||||||
print(check_output('systemctl cat systemd-udevd.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.service')
|
||||||
rm_unit('systemd-networkd.socket')
|
rm_unit('systemd-networkd.socket')
|
||||||
|
rm_unit('systemd-networkd-persistent-storage.service')
|
||||||
rm_unit('systemd-resolved.service')
|
rm_unit('systemd-resolved.service')
|
||||||
rm_unit('systemd-timesyncd.service')
|
rm_unit('systemd-timesyncd.service')
|
||||||
rm_unit('systemd-udevd.service')
|
rm_unit('systemd-udevd.service')
|
||||||
|
@ -896,6 +915,7 @@ def tear_down_common():
|
||||||
# 6. remove configs
|
# 6. remove configs
|
||||||
clear_network_units()
|
clear_network_units()
|
||||||
clear_networkd_conf_dropins()
|
clear_networkd_conf_dropins()
|
||||||
|
clear_networkd_state_files()
|
||||||
|
|
||||||
# 7. flush settings
|
# 7. flush settings
|
||||||
flush_fou_ports()
|
flush_fou_ports()
|
||||||
|
@ -909,6 +929,7 @@ def setUpModule():
|
||||||
|
|
||||||
clear_network_units()
|
clear_network_units()
|
||||||
clear_networkd_conf_dropins()
|
clear_networkd_conf_dropins()
|
||||||
|
clear_networkd_state_files()
|
||||||
clear_udev_rules()
|
clear_udev_rules()
|
||||||
|
|
||||||
setup_systemd_udev_rules()
|
setup_systemd_udev_rules()
|
||||||
|
@ -928,6 +949,7 @@ def tearDownModule():
|
||||||
clear_udev_rules()
|
clear_udev_rules()
|
||||||
clear_network_units()
|
clear_network_units()
|
||||||
clear_networkd_conf_dropins()
|
clear_networkd_conf_dropins()
|
||||||
|
clear_networkd_state_files()
|
||||||
|
|
||||||
restore_timezone()
|
restore_timezone()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue