summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-07-08 07:00:42 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-07-08 07:02:13 +0900
commit74af762551bae6ca679aa2cb2cdc47252cf77912 (patch)
treece1d37a8f195ac8235dda5df2ac0e855addc7b13
parentd64c7623aba7fcff2286bc0a8c500f040d837ca2 (diff)
downloadsystemd-74af762551bae6ca679aa2cb2cdc47252cf77912.tar.gz
test: use timeout command to improve performance
c.f. #23723.
-rwxr-xr-xtest/units/testsuite-60.sh49
1 files changed, 9 insertions, 40 deletions
diff --git a/test/units/testsuite-60.sh b/test/units/testsuite-60.sh
index 31e1f46af9..3c391c8efa 100755
--- a/test/units/testsuite-60.sh
+++ b/test/units/testsuite-60.sh
@@ -85,6 +85,8 @@ for ((i = 0; i < NUM_DIRS; i++)); do
mkdir "/tmp/meow${i}"
done
+TS="$(date '+%H:%M:%S')"
+
for ((i = 0; i < NUM_DIRS; i++)); do
mount -t tmpfs tmpfs "/tmp/meow${i}"
done
@@ -96,48 +98,15 @@ for ((i = 0; i < NUM_DIRS; i++)); do
umount "/tmp/meow${i}"
done
-# figure out if we have entered the rate limit state
-
-entered_rl=0
-exited_rl=0
-timeout="$(date -ud "2 minutes" +%s)"
-while [[ $(date -u +%s) -le ${timeout} ]]; do
- if journalctl -u init.scope | grep -q "(mount-monitor-dispatch) entered rate limit"; then
- entered_rl=1
- break
- fi
- sleep 5
-done
-
-# if the infra is slow we might not enter the rate limit state; in that case skip the exit check
-
-if [ "${entered_rl}" = "1" ]; then
- exited_rl=0
- timeout="$(date -ud "2 minutes" +%s)"
- while [[ $(date -u +%s) -le ${timeout} ]]; do
- if journalctl -u init.scope | grep -q "(mount-monitor-dispatch) left rate limit"; then
- exited_rl=1
- break
- fi
- sleep 5
- done
-
- if [ "${exited_rl}" = "0" ]; then
- exit 24
- fi
+# 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.
+if timeout 2m bash -c "while ! journalctl -u init.scope --since=$TS | grep -q '(mount-monitor-dispatch) entered rate limit'; do sleep 1; done"; then
+ timeout 2m bash -c "while ! journalctl -u init.scope --since=$TS | grep -q '(mount-monitor-dispatch) left rate limit'; do sleep 1; done"
fi
-# give some time for units to settle so we don't race between exiting the rate limit state and cleaning up the units
-
-sleep 60
-systemctl daemon-reload
-sleep 60
-
-# verify that the mount units are always cleaned up at the end
-
-if systemctl list-units -t mount tmp-meow* | grep -q tmp-meow; then
- exit 42
-fi
+# 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.
+timeout 2m bash -c 'while systemctl list-units -t mount tmp-meow* | grep -q tmp-meow; do systemctl daemon-reload; sleep 10; done'
# test that handling of mount start jobs is delayed when /proc/self/mouninfo monitor is rate limited
test_issue_20329