From 47f6baccfe9e375e8d96d3368b44fa13b317c08f Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 29 Sep 2023 22:07:12 +0200 Subject: [PATCH 1/3] test: shutdown the machine on fail after soft-reboot Since the soft-reboot drops the enqueued end.service, we won't shutdown the test VM if the test fails and have to wait for the watchdog to kill us (which may take quite a long time). Let's just forcibly kill the machine instead to save CI resources. --- test/units/testsuite-82.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/units/testsuite-82.sh b/test/units/testsuite-82.sh index b6b6615997..71ea7d5b5e 100755 --- a/test/units/testsuite-82.sh +++ b/test/units/testsuite-82.sh @@ -3,6 +3,19 @@ set -ex set -o pipefail +at_exit() { + # Since the soft-reboot drops the enqueued end.service, we won't shutdown + # the test VM if the test fails and have to wait for the watchdog to kill + # us (which may take quite a long time). Let's just forcibly kill the machine + # instead to save CI resources. + if [[ $? -ne 0 ]]; then + echo >&2 "Test failed, shutting down the machine..." + systemctl poweroff -ff + fi +} + +trap at_exit EXIT + systemd-analyze log-level debug export SYSTEMD_LOG_LEVEL=debug From 82abce7a89b792959ed82213786235bfa4aeacbe Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 29 Sep 2023 22:10:42 +0200 Subject: [PATCH 2/3] test: use Type=exec for the auxiliary services To make sure the respective binaries are exec()ed before moving further with the test. --- test/units/testsuite-82.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/units/testsuite-82.sh b/test/units/testsuite-82.sh index 71ea7d5b5e..fec29eef12 100755 --- a/test/units/testsuite-82.sh +++ b/test/units/testsuite-82.sh @@ -97,7 +97,8 @@ elif [ -f /run/testsuite82.touch ]; then test "$x" = "wuffwuff" # Check that we got a PrepareForShutdownWithMetadata signal with the right type - test "$(jq .payload.data[1].type.data Date: Fri, 29 Sep 2023 23:26:15 +0200 Subject: [PATCH 3/3] test: don't pipe the whole journal through jq Doing that in VMs without acceleration is prohibitively expensive (i.e. 20+ seconds in the C8S job). Thankfully, the recent [0] --lines=+n syntax makes this all quite easy to fix. [0] 8d6791d2aa9 --- test/units/testsuite-09.journal.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/units/testsuite-09.journal.sh b/test/units/testsuite-09.journal.sh index c6c1f6eccb..2ef192c7a8 100755 --- a/test/units/testsuite-09.journal.sh +++ b/test/units/testsuite-09.journal.sh @@ -7,7 +7,7 @@ set -o pipefail . "$(dirname "$0")"/util.sh get_first_boot_id() { - journalctl -b "${1:?}" -o json | jq -sr '.[0]._BOOT_ID' + journalctl -b "${1:?}" -o json -n +1 | jq -r '._BOOT_ID' } get_last_boot_id() { @@ -15,7 +15,7 @@ get_last_boot_id() { } get_first_timestamp() { - journalctl -b "${1:?}" -o json | jq -sr '.[0].__REALTIME_TIMESTAMP' + journalctl -b "${1:?}" -o json -n +1 | jq -r '.__REALTIME_TIMESTAMP' } get_last_timestamp() {