Skip to content

Commit 1bfa83e

Browse files
authored
Merge pull request #32942 from yuwata/test-journal-sync-more
test: sync journal before read
2 parents f8ef1df + 702fdd3 commit 1bfa83e

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

test/units/TEST-17-UDEV.02.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ EOF
145145
# make sure that 'udevadm monitor' actually monitor uevents
146146
sleep 1
147147

148+
journalctl --sync
148149
since="$(date '+%H:%M:%S')"
149150

150151
# add another interface which will conflict with an existing interface
@@ -172,7 +173,8 @@ EOF
172173
done
173174
test -n "$found"
174175

175-
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; done"
176+
journalctl --sync
177+
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"
176178
# check if the invalid SYSTEMD_ALIAS property for the interface foobar is ignored by PID1
177179
assert_eq "$(systemctl show --property=SysFSPath --value /sys/subsystem/net/devices/hoge)" "/sys/devices/virtual/net/hoge"
178180
}

test/units/TEST-35-LOGIN.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ testcase_lock_idle_action() {
507507

508508
create_session
509509

510+
journalctl --sync
510511
ts="$(date '+%H:%M:%S')"
511512

512513
mkdir -p /run/systemd/logind.conf.d
@@ -522,7 +523,8 @@ EOF
522523
# session active again and next we slept for another 35s so sessions have
523524
# become idle again. 'Lock' signal is sent out for each session, we have at
524525
# least one session, so minimum of 2 "Lock" signals must have been sent.
525-
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; done"
526+
journalctl --sync
527+
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"
526528

527529
# We need to know that a new message was sent after waking up,
528530
# so we must track how many happened before sleeping to check we have extra.
@@ -532,7 +534,8 @@ EOF
532534
touch /dev/tty2
533535

534536
# Wait again
535-
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; done"
537+
journalctl --sync
538+
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"
536539

537540
if [[ "$(journalctl -b -u systemd-logind.service --since="$ts" | grep -c 'System idle. Will be locked now.')" -lt 2 ]]; then
538541
echo >&2 "System haven't entered idle state at least 2 times."
@@ -620,6 +623,8 @@ testcase_stop_idle_session() {
620623
trap teardown_stop_idle_session RETURN
621624

622625
id="$(loginctl --no-legend | grep tty | awk '$3 == "logind-test-user" { print $1; }')"
626+
627+
journalctl --sync
623628
ts="$(date '+%H:%M:%S')"
624629

625630
mkdir -p /run/systemd/logind.conf.d
@@ -630,6 +635,7 @@ EOF
630635
systemctl restart systemd-logind.service
631636
sleep 5
632637

638+
journalctl --sync
633639
assert_eq "$(journalctl -b -u systemd-logind.service --since="$ts" --grep "Session \"$id\" of user \"logind-test-user\" is idle, stopping." | wc -l)" 1
634640
assert_eq "$(loginctl --no-legend | grep -v manager | grep -c "logind-test-user")" 0
635641
}

test/units/TEST-50-DISSECT.dissect.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,9 @@ systemd-sysext merge --no-reload
722722
(! systemctl --quiet is-active foo.service)
723723
systemd-sysext unmerge --no-reload
724724
systemd-sysext merge
725+
journalctl --sync
725726
# shellcheck disable=SC2016
726-
timeout 30s bash -xec 'until [[ $(journalctl -b -u foo.service _TRANSPORT=stdout -o cat) == foo ]]; do sleep .5; done'
727+
timeout 30s bash -xec 'until [[ $(journalctl -b -u foo.service _TRANSPORT=stdout -o cat) == foo ]]; do sleep 1; journalctl --sync; done'
727728
systemd-sysext unmerge --no-reload
728729
# Grep on the Warning to find the warning helper mentioning the daemon reload.
729730
systemctl status foo.service 2>&1 | grep -q -F "Warning"

test/units/TEST-60-MOUNT-RATELIMIT.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ done
295295
# Figure out if we have entered the rate limit state.
296296
# If the infra is slow we might not enter the rate limit state; in that case skip the exit check.
297297
journalctl --sync
298-
if timeout 2m bash -c "until journalctl -u init.scope --since=$TS | grep -q '(mount-monitor-dispatch) entered rate limit'; do journalctl --sync; sleep 1; done"; then
298+
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
299299
journalctl --sync
300-
timeout 2m bash -c "until journalctl -u init.scope --since=$TS | grep -q '(mount-monitor-dispatch) left rate limit'; do journalctl --sync; sleep 1; done"
300+
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"
301301
fi
302302

303303
# Verify that the mount units are always cleaned up at the end.

0 commit comments

Comments
 (0)