test: sync journal before read

Workaround for #32834 and #32890.
This commit is contained in:
Yu Watanabe 2024-05-19 07:12:48 +09:00 committed by Luca Boccassi
parent 68ca50d3ae
commit a610ba00d9
2 changed files with 9 additions and 0 deletions

View file

@ -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

View file

@ -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')" ""