summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-08-13 23:55:29 +0200
committerGitHub <noreply@github.com>2022-08-13 23:55:29 +0200
commite3e7185a704fbf934b8b64cc624cfecea46f91b4 (patch)
treeb3d13d266008da04344a1def57417e45f576be27
parentUse correct label for boot related issues (diff)
parenttest-network: use "systemctl restart" to restart networkd (diff)
downloadsystemd-e3e7185a704fbf934b8b64cc624cfecea46f91b4.tar.xz
systemd-e3e7185a704fbf934b8b64cc624cfecea46f91b4.zip
Merge pull request #24305 from yuwata/test-network
test-network: also set StartLimitIntervalSec=0 for systemd-networkd.socket
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index fddae84259..ca96f79428 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -346,6 +346,11 @@ def restore_active_units():
for u in active_units:
call(f'systemctl restart {u}')
+def create_unit_dropin(unit, contents):
+ mkdir_p(f'/run/systemd/system/{unit}.d')
+ with open(f'/run/systemd/system/{unit}.d/00-override.conf', mode='w', encoding='utf-8') as f:
+ f.write('\n'.join(contents))
+
def create_service_dropin(service, command, reload_command=None, additional_settings=None):
drop_in = [
'[Service]',
@@ -382,9 +387,7 @@ def create_service_dropin(service, command, reload_command=None, additional_sett
if additional_settings:
drop_in += additional_settings
- mkdir_p(f'/run/systemd/system/{service}.service.d')
- with open(f'/run/systemd/system/{service}.service.d/00-override.conf', mode='w', encoding='utf-8') as f:
- f.write('\n'.join(drop_in))
+ create_unit_dropin(f'{service}.service', drop_in)
def link_exists(link):
return os.path.exists(os.path.join('/sys/class/net', link, 'ifindex'))
@@ -598,8 +601,11 @@ def start_networkd():
check_output('systemctl start systemd-networkd')
def restart_networkd(show_logs=True):
- stop_networkd(show_logs)
- start_networkd()
+ if show_logs:
+ invocation_id = check_output('systemctl show systemd-networkd.service -p InvocationID --value')
+ check_output('systemctl restart systemd-networkd.service')
+ if show_logs:
+ print(check_output('journalctl _SYSTEMD_INVOCATION_ID=' + invocation_id))
def networkctl_reconfigure(*links):
check_output(*networkctl_cmd, 'reconfigure', *links, env=env)
@@ -669,17 +675,23 @@ def setUpModule():
# TODO: also run udevd with sanitizers, valgrind, or coverage
#create_service_dropin('systemd-udevd', udevd_bin,
# f'{udevadm_bin} control --reload --timeout 0')
- drop_in = [
- '[Service]',
- 'ExecStart=',
- f'ExecStart=!!{udevd_bin}',
- 'ExecReload=',
- f'ExecReload={udevadm_bin} control --reload --timeout 0',
- ]
-
- mkdir_p('/run/systemd/system/systemd-udevd.service.d')
- with open('/run/systemd/system/systemd-udevd.service.d/00-override.conf', mode='w', encoding='utf-8') as f:
- f.write('\n'.join(drop_in))
+ create_unit_dropin(
+ 'systemd-udevd.service',
+ [
+ '[Service]',
+ 'ExecStart=',
+ f'ExecStart=!!{udevd_bin}',
+ 'ExecReload=',
+ f'ExecReload={udevadm_bin} control --reload --timeout 0',
+ ]
+ )
+ create_unit_dropin(
+ 'systemd-networkd.socket',
+ [
+ '[Unit]',
+ 'StartLimitIntervalSec=0',
+ ]
+ )
check_output('systemctl daemon-reload')
print(check_output('systemctl cat systemd-networkd.service'))
@@ -699,6 +711,7 @@ def tearDownModule():
restore_timezone()
rm_rf('/run/systemd/system/systemd-networkd.service.d')
+ rm_rf('/run/systemd/system/systemd-networkd.socket.d')
rm_rf('/run/systemd/system/systemd-resolved.service.d')
rm_rf('/run/systemd/system/systemd-timesyncd.service.d')
rm_rf('/run/systemd/system/systemd-udevd.service.d')