Skip to content

Commit

Permalink
test: also flush and rotate journal before read
Browse files Browse the repository at this point in the history
Follow-up for a610ba0.

Fixes #32890.
  • Loading branch information
yuwata authored and bluca committed May 22, 2024
1 parent 505b20e commit 87ed87e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/units/TEST-09-REBOOT.journal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ get_last_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.
# result may be provided. To mitigate such, flush (if not yet) and sync before reading journals.
# Workaround for #32890.
journalctl --flush
journalctl --sync
# Sometimes, loading partially written .journal file, and journalctl handled that as 'truncated':
# ===
# May 21 02:25:55 TEST-09-REBOOT.sh[433]: + journalctl --list-boots -o json
# May 21 02:25:55 journalctl[433]: Journal file /var/log/journal/173da2fad3064e3e9211a7ed7d59360b/system.journal is truncated, ignoring file.
# ===
# If that happens, the entries stored in the journal file are ignored, and the results of --list-boots
# and subsequent call of journalctl may become inconsistent. To prevent such issue, let's also rotate
# the journal. Then, all journal entries we are interested in are stored in the archived journal files.
journalctl --rotate

# Issue: #29275, second part
# Now let's check if the boot entries are in the correct/expected order
Expand Down

0 comments on commit 87ed87e

Please sign in to comment.