From a610ba00d923f148702e68b1661166e887759509 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 19 May 2024 07:12:48 +0900 Subject: [PATCH] test: sync journal before read Workaround for #32834 and #32890. --- test/units/TEST-09-REBOOT.journal.sh | 5 +++++ test/units/TEST-82-SOFTREBOOT.sh | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/test/units/TEST-09-REBOOT.journal.sh b/test/units/TEST-09-REBOOT.journal.sh index 5248d70d844..320390cea5c 100755 --- a/test/units/TEST-09-REBOOT.journal.sh +++ b/test/units/TEST-09-REBOOT.journal.sh @@ -22,6 +22,11 @@ get_last_timestamp() { journalctl -b "${1:?}" -o json -n 1 | jq -r '.__REALTIME_TIMESTAMP' } +# There may be huge amount of pending messages in sockets. Processing them may cause journal rotation. +# If the journal is rotated in the loop below, some journal file may not be loaded and an unexpected +# result may be provided. To mitigate such, sync before reading journals. Workaround for #32890. +journalctl --sync + # Issue: #29275, second part # Now let's check if the boot entries are in the correct/expected order index=0 diff --git a/test/units/TEST-82-SOFTREBOOT.sh b/test/units/TEST-82-SOFTREBOOT.sh index b76ca9af323..0dc4f87a60b 100755 --- a/test/units/TEST-82-SOFTREBOOT.sh +++ b/test/units/TEST-82-SOFTREBOOT.sh @@ -47,6 +47,10 @@ if [ -f /run/TEST-82-SOFTREBOOT.touch3 ]; then [[ ! -e /run/credentials/TEST-82-SOFTREBOOT-nosurvive.service ]] assert_eq "$(cat /run/credentials/TEST-82-SOFTREBOOT-survive-argv.service/preserve)" "yay" + # There may be huge amount of pending messages in sockets. Processing them may cause journal rotation and + # removal of old archived journal files. If a journal file is removed during journalctl reading it, + # the command may fail. To mitigate such, sync before reading journals. Workaround for #32834. + journalctl --sync # Check journals journalctl -o short-monotonic --no-hostname --grep '(will soft-reboot|KILL|corrupt)' assert_eq "$(journalctl -q -o short-monotonic -u systemd-journald.service --grep 'corrupt')" "" -- 2.47.3