mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
test: rotate journal before invocation test
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user