From 54bf13a46a826d5918861df74ace249b77a4fc7e Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 5 Sep 2023 13:14:39 +0200 Subject: [PATCH 1/3] test: bump the trigger limit interval when running w/o KVM As we might be slow enough to miss the trigger limit. Spotted in a nightly cron build on C8S. --- test/TEST-07-PID1/test.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/TEST-07-PID1/test.sh b/test/TEST-07-PID1/test.sh index 1c3d7137fe..1f9a929466 100755 --- a/test/TEST-07-PID1/test.sh +++ b/test/TEST-07-PID1/test.sh @@ -10,12 +10,12 @@ TEST_DESCRIPTION="Tests for core PID1 functionality" test_append_files() { local workspace="${1:?}" - # Collecting coverage slows this particular test quite a bit, causing - # it to fail with the default settings (20 triggers per 2 secs). - # Let's help it a bit in such case. - if get_bool "$IS_BUILT_WITH_COVERAGE"; then + # We might not be fast enough to hit the limit (20 triggers per 2 secs) + # in certain environments, i.e. when running without KVM or when collecting + # coverage. Let's help it a bit in such case. + if ! get_bool "$QEMU_KVM" || get_bool "$IS_BUILT_WITH_COVERAGE"; then mkdir -p "$workspace/etc/systemd/system/issue2467.socket.d" - printf "[Socket]\nTriggerLimitIntervalSec=10\n" >"$workspace/etc/systemd/system/issue2467.socket.d/coverage-override.conf" + printf "[Socket]\nTriggerLimitIntervalSec=10\n" >"$workspace/etc/systemd/system/issue2467.socket.d/TriggerLimitInterval.conf" fi # Issue: https://github.com/systemd/systemd/issues/2730 From 04bf0452a54a08443aa4988e402c54f6dbe8948d Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 5 Sep 2023 13:30:12 +0200 Subject: [PATCH 2/3] test: set ncat's idle timeout as well Otherwise we'll get stuck waiting indefinitely if the test socket unit fails to fail due the trigger limit, i.e.: [ 111.104906] testsuite-07.sh[743]: + systemctl start issue2467.socket [ OK ] Listening on issue2467.socket. [ 111.746465] testsuite-07.sh[743]: + nc -w20 -U /run/test.ctl Starting systemd-tmpfiles-clean.service... [ OK ] Finished systemd-tmpfiles-clean.service. qemu-system-x86_64: terminating on signal 15 from pid 565814 (timeout) E: Test timed out after 1800s With the idle timeout we should give up after 20 seconds, allowing the next statement to properly fail: [ 34.233084] testsuite-07.sh[450]: + systemctl start issue2467.socket [ 35.475392] testsuite-07.sh[450]: + nc -i20 -w20 -U /run/test.ctl [ 56.122941] testsuite-07.sh[458]: Ncat: Idle timeout expired (20000 ms). [ 56.140871] testsuite-07.sh[450]: + : [ 56.145460] testsuite-07.sh[450]: + timeout 10 bash -c 'while ! [[ "$(systemctl show issue2467.socket -P ActiveState)" == failed ]]; do sleep .5; done' [ 66.197623] testsuite-07.sh[446]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-07.issue-2467.sh failed' --- test/units/testsuite-07.issue-2467.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/testsuite-07.issue-2467.sh b/test/units/testsuite-07.issue-2467.sh index a5dcfd55dd..0d8c16e65a 100755 --- a/test/units/testsuite-07.issue-2467.sh +++ b/test/units/testsuite-07.issue-2467.sh @@ -8,7 +8,7 @@ set -o pipefail rm -f /tmp/nonexistent systemctl start issue2467.socket -nc -w20 -U /run/test.ctl || : +nc -i20 -w20 -U /run/test.ctl || : # TriggerLimitIntervalSec= by default is set to 2s. A "sleep 10" should give # systemd enough time even on slower machines, to reach the trigger limit. From 89562f08c9c7615d1a3e6bdefa4009db5a8f00dd Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 5 Sep 2023 14:38:35 +0200 Subject: [PATCH 3/3] test: create the "global" dropins in /run So the test doesn't fail if run multiple times in a succession. --- test/units/testsuite-15.sh | 56 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/test/units/testsuite-15.sh b/test/units/testsuite-15.sh index 49bcd9211b..e790b37c70 100755 --- a/test/units/testsuite-15.sh +++ b/test/units/testsuite-15.sh @@ -7,14 +7,16 @@ set -o pipefail . "$(dirname "$0")"/test-control.sh clear_unit() { - local UNIT_NAME="${1:?}" - systemctl stop "$UNIT_NAME" 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME" - rm -fr /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME".d - rm -fr /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME".{wants,requires} - if [[ $UNIT_NAME == *@ ]]; then - local base="${UNIT_NAME%@*}" - local suffix="${UNIT_NAME##*.}" + local unit_name="${1:?}" + local base suffix + + systemctl stop "$unit_name" 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/"$unit_name" + rm -fr /{etc,run,usr/lib}/systemd/system/"$unit_name".d + rm -fr /{etc,run,usr/lib}/systemd/system/"$unit_name".{wants,requires} + if [[ $unit_name == *@* ]]; then + base="${unit_name%@*}" + suffix="${unit_name##*.}" systemctl stop "$base@"*."$suffix" 2>/dev/null || : rm -f /{etc,run,usr/lib}/systemd/system/"$base@"*."$suffix" rm -fr /{etc,run,usr/lib}/systemd/system/"$base@"*."$suffix".d @@ -30,17 +32,17 @@ clear_units() { } create_service() { - local SERVICE_NAME="${1:?}" - clear_units "${SERVICE_NAME}".service + local service_name="${1:?}" + clear_units "${service_name}".service - cat >/etc/systemd/system/"$SERVICE_NAME".service </etc/systemd/system/"$service_name".service </usr/lib/systemd/system/service.d/override.conf </run/systemd/system/service.d/override.conf <"/run/systemd/system/$dropin/override.conf" </usr/lib/systemd/system/$dropin/override.conf +EOF systemctl daemon-reload check_ok a-b-c ExecCondition "echo $dropin" @@ -220,7 +222,7 @@ ExecCondition=echo $dropin systemctl stop a-b-c2.service done for dropin in service.d a-.service.d a-b-.service.d a-b-c.service.d; do - rm -rf /usr/lib/systemd/system/$dropin + rm -rf "/run/systemd/system/$dropin" done clear_units a-b-c.service @@ -235,11 +237,11 @@ testcase_hierarchical_slice_dropins() { # Test drop-ins for dropin in slice.d a-.slice.d a-b-.slice.d a-b-c.slice.d; do - mkdir -p /usr/lib/systemd/system/$dropin - echo " + mkdir -p "/run/systemd/system/$dropin" + cat >"/run/systemd/system/$dropin/override.conf" </usr/lib/systemd/system/$dropin/override.conf +EOF systemctl daemon-reload check_ok a-b-c.slice MemoryMax "1000000000" @@ -271,14 +273,14 @@ MemoryMax=1000000000 StopUnit 'ss' \ 'a-b-c.slice' 'replace' - rm /usr/lib/systemd/system/$dropin/override.conf + rm -f "/run/systemd/system/$dropin/override.conf" done # Test unit with a fragment - echo " + cat >/run/systemd/system/a-b-c.slice </usr/lib/systemd/system/a-b-c.slice +EOF systemctl daemon-reload check_ok a-b-c.slice MemoryMax "1000000001" @@ -614,7 +616,7 @@ EOF echo "*** test a wants b both ways" create_services test15-a test15-b ln -sf /dev/null /etc/systemd/system/test15-a.service.wants/test15-b.service - cat >/usr/lib/systemd/system/test15-a.service.d/wants-b.conf</usr/lib/systemd/system/test15-a.service.d/wants-b.conf <