Skip to content

Commit 87ed87e

Browse files
yuwatabluca
authored andcommitted
test: also flush and rotate journal before read
Follow-up for a610ba0. Fixes #32890.
1 parent 505b20e commit 87ed87e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/units/TEST-09-REBOOT.journal.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ get_last_timestamp() {
2424

2525
# There may be huge amount of pending messages in sockets. Processing them may cause journal rotation.
2626
# If the journal is rotated in the loop below, some journal file may not be loaded and an unexpected
27-
# result may be provided. To mitigate such, sync before reading journals. Workaround for #32890.
27+
# result may be provided. To mitigate such, flush (if not yet) and sync before reading journals.
28+
# Workaround for #32890.
29+
journalctl --flush
2830
journalctl --sync
31+
# Sometimes, loading partially written .journal file, and journalctl handled that as 'truncated':
32+
# ===
33+
# May 21 02:25:55 TEST-09-REBOOT.sh[433]: + journalctl --list-boots -o json
34+
# May 21 02:25:55 journalctl[433]: Journal file /var/log/journal/173da2fad3064e3e9211a7ed7d59360b/system.journal is truncated, ignoring file.
35+
# ===
36+
# If that happens, the entries stored in the journal file are ignored, and the results of --list-boots
37+
# and subsequent call of journalctl may become inconsistent. To prevent such issue, let's also rotate
38+
# the journal. Then, all journal entries we are interested in are stored in the archived journal files.
39+
journalctl --rotate
2940

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

0 commit comments

Comments
 (0)