mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
test: replace journal checkers with journalctl --follow + grep -m
Recently, for slow test environments, journalctl --sync was added to the loop in the timeout. However, journalctl --sync may be slow in such systems, and timeout easily triggered during syncing. Hopefully, reading journal with --follow and grep the output with an expected line should be efficient. Hopefully fixes #32712.
This commit is contained in:
committed by
Luca Boccassi
parent
ce2aade08c
commit
505b20ecdd
@@ -174,7 +174,9 @@ EOF
|
||||
test -n "$found"
|
||||
|
||||
journalctl --sync
|
||||
timeout 30 bash -c "until journalctl _PID=1 _COMM=systemd --since $since | grep -q 'foobar: systemd-udevd failed to process the device, ignoring: File exists'; do sleep 1; journalctl --sync; done"
|
||||
set +o pipefail
|
||||
timeout -v 30 journalctl _PID=1 _COMM=systemd --since "$since" -n all --follow | grep -m 1 -q -F 'foobar: systemd-udevd failed to process the device, ignoring: File exists'
|
||||
set -o pipefail
|
||||
# check if the invalid SYSTEMD_ALIAS property for the interface foobar is ignored by PID1
|
||||
assert_eq "$(systemctl show --property=SysFSPath --value /sys/subsystem/net/devices/hoge)" "/sys/devices/virtual/net/hoge"
|
||||
}
|
||||
|
||||
@@ -524,7 +524,9 @@ EOF
|
||||
# become idle again. 'Lock' signal is sent out for each session, we have at
|
||||
# least one session, so minimum of 2 "Lock" signals must have been sent.
|
||||
journalctl --sync
|
||||
timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt 1 ]]; do sleep 1; journalctl --sync; done"
|
||||
set +o pipefail
|
||||
timeout -v 35 journalctl -b -u systemd-logind.service --since="$ts" -n all --follow | grep -m 1 -q 'Sent message type=signal .* member=Lock'
|
||||
set -o pipefail
|
||||
|
||||
# We need to know that a new message was sent after waking up,
|
||||
# so we must track how many happened before sleeping to check we have extra.
|
||||
@@ -535,12 +537,10 @@ EOF
|
||||
|
||||
# Wait again
|
||||
journalctl --sync
|
||||
timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt $((locks + 1)) ]]; do sleep 1; journalctl --sync; done"
|
||||
|
||||
if [[ "$(journalctl -b -u systemd-logind.service --since="$ts" | grep -c 'System idle. Will be locked now.')" -lt 2 ]]; then
|
||||
echo >&2 "System haven't entered idle state at least 2 times."
|
||||
exit 1
|
||||
fi
|
||||
set +o pipefail
|
||||
timeout -v 35 journalctl -b -u systemd-logind.service --since="$ts" -n all --follow | grep -m "$((locks + 1))" -q 'Sent message type=signal .* member=Lock'
|
||||
timeout -v 35 journalctl -b -u systemd-logind.service --since="$ts" -n all --follow | grep -m 2 -q -F 'System idle. Will be locked now.'
|
||||
set -o pipefail
|
||||
}
|
||||
|
||||
testcase_session_properties() {
|
||||
|
||||
@@ -723,8 +723,9 @@ systemd-sysext merge --no-reload
|
||||
systemd-sysext unmerge --no-reload
|
||||
systemd-sysext merge
|
||||
journalctl --sync
|
||||
# shellcheck disable=SC2016
|
||||
timeout 30s bash -xec 'until [[ $(journalctl -b -u foo.service _TRANSPORT=stdout -o cat) == foo ]]; do sleep 1; journalctl --sync; done'
|
||||
set +o pipefail
|
||||
timeout -v 30s journalctl -b -u foo.service _TRANSPORT=stdout -o cat -n all --follow | grep -m 1 -q '^foo$'
|
||||
set -o pipefail
|
||||
systemd-sysext unmerge --no-reload
|
||||
# Grep on the Warning to find the warning helper mentioning the daemon reload.
|
||||
systemctl status foo.service 2>&1 | grep -q -F "Warning"
|
||||
|
||||
@@ -294,11 +294,13 @@ done
|
||||
|
||||
# Figure out if we have entered the rate limit state.
|
||||
# If the infra is slow we might not enter the rate limit state; in that case skip the exit check.
|
||||
set +o pipefail
|
||||
journalctl --sync
|
||||
if timeout 2m bash -c "until journalctl -u init.scope --since=$TS | grep -q '(mount-monitor-dispatch) entered rate limit'; do sleep 1; journalctl --sync; done"; then
|
||||
if timeout 2m journalctl -u init.scope --since="$TS" -n all --follow | grep -m 1 -q -F '(mount-monitor-dispatch) entered rate limit'; then
|
||||
journalctl --sync
|
||||
timeout 2m bash -c "until journalctl -u init.scope --since=$TS | grep -q '(mount-monitor-dispatch) left rate limit'; do sleep 1; journalctl --sync; done"
|
||||
timeout 2m journalctl -u init.scope --since="$TS" -n all --follow | grep -m 1 -q -F '(mount-monitor-dispatch) left rate limit'
|
||||
fi
|
||||
set -o pipefail
|
||||
|
||||
# Verify that the mount units are always cleaned up at the end.
|
||||
# Give some time for units to settle so we don't race between exiting the rate limit state and cleaning up the units.
|
||||
|
||||
Reference in New Issue
Block a user