]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: rotate journal before invocation test
authorLuca Boccassi <luca.boccassi@gmail.com>
Fri, 7 Nov 2025 20:12:47 +0000 (20:12 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 7 Nov 2025 21:35:45 +0000 (21:35 +0000)
Occasionally there are truncated journals failing this test:

[  884.181701] H TEST-04-JOURNAL.sh[12104]: ++ journalctl --no-hostname -n 1 -t bash --invocation=fe8122a7d8eb42c7bf357ac5fafa95e1
[  884.181749] H TEST-04-JOURNAL.sh[12091]: + assert_in 'invocation 1 fe8122a7d8eb42c7bf357ac5fafa95e1' 'Nov 06 17:27:10 bash[11985]: invocation 1 fe8122a7d8eb42c7bf357ac5fafa95e1'
[  884.181773] H TEST-04-JOURNAL.sh[12105]: + set +ex
[  884.181819] H TEST-04-JOURNAL.sh[12091]: + read -r idx invocation _
[  884.181819] H TEST-04-JOURNAL.sh[12091]: + i=2
[  884.181865] H TEST-04-JOURNAL.sh[12106]: ++ journalctl --no-hostname -n 1 -t bash --invocation=2 -u invocation-id-test-20992
[  884.181865] H TEST-04-JOURNAL.sh[12106]: Journal file /var/log/journal/936183a66e7c47939693ae37a967e4fd/system.journal is truncated, ignoring file.
[  884.181865] H TEST-04-JOURNAL.sh[12106]: No journal entry found for the invocation (+2).
[  884.181952] H TEST-04-JOURNAL.sh[12091]: + assert_in 'invocation 2 07d0bd6b5c654b148541d798abccaa96' ''
[  884.181972] H TEST-04-JOURNAL.sh[12107]: + set +ex
[  884.181972] H TEST-04-JOURNAL.sh[12107]: FAIL: 'invocation 2 07d0bd6b5c654b148541d798abccaa96' not found in:

Rotate it at the beginning of the test case to try and avoid this.

Fixes https://github.com/systemd/systemd/issues/39601

test/units/TEST-04-JOURNAL.invocation.sh

index 74db1040fdf627c9a8419ef5307882c381219d63..39ac26131c09888effb37c0332a87a20ddb56676 100755 (executable)
@@ -18,6 +18,7 @@ TMP_DIR=$(mktemp -d)
 # service stdout will not contain _SYSTEMD_INVOCATION_ID field.
 SAVED_LOG_LEVEL=$(systemctl log-level)
 systemctl log-level info
+journalctl --rotate
 
 # Note, if the service exits extremely fast, journald cannot find the source of the
 # stream. Hence, we need to call 'journalctl --sync' before service exits.