From 77c5b4750695f9e23ee939ebc201cffe8191fa05 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Sun, 19 May 2024 07:12:48 +0900
Subject: [PATCH 0650/1160] test: sync journal before read
Workaround for #32834 and #32890.
(cherry picked from commit a610ba00d923f148702e68b1661166e887759509)
test/units/testsuite-09.journal.sh | 5 +++++
test/units/testsuite-82.sh | 4 ++++
2 files changed, 9 insertions(+)
@@ -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
@@ -42,6 +42,10 @@ if [ -f /run/testsuite82.touch3 ]; then
test "$(systemctl show -P ActiveState testsuite-82-nosurvive-sigterm.service)" != "active"
test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active"
+ # 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.33.0