|
|
984f77 |
From e6cd875a767ba23b218cdca395307ac6fb7fd882 Mon Sep 17 00:00:00 2001
|
|
|
984f77 |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
984f77 |
Date: Mon, 30 May 2022 14:50:05 +0200
|
|
|
984f77 |
Subject: [PATCH] tests: make sure we delay running mount start jobs when
|
|
|
984f77 |
/p/s/mountinfo is rate limited
|
|
|
984f77 |
|
|
|
984f77 |
(cherry picked from commit 9e15be6c8d55abd800bf33f9776dd0e307ed37bc)
|
|
|
984f77 |
|
|
|
984f77 |
Related: #2095744
|
|
|
984f77 |
---
|
|
|
984f77 |
test/TEST-60-MOUNT-RATELIMIT/testsuite.sh | 53 +++++++++++++++++++++++
|
|
|
984f77 |
test/test-functions | 2 +-
|
|
|
984f77 |
2 files changed, 54 insertions(+), 1 deletion(-)
|
|
|
984f77 |
|
|
|
984f77 |
diff --git a/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh b/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh
|
|
|
984f77 |
index 6211050faf..84fe9640e1 100755
|
|
|
984f77 |
--- a/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh
|
|
|
984f77 |
+++ b/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh
|
|
|
984f77 |
@@ -2,6 +2,56 @@
|
|
|
984f77 |
set -eux
|
|
|
984f77 |
set -o pipefail
|
|
|
984f77 |
|
|
|
984f77 |
+test_issue_20329() {
|
|
|
984f77 |
+ local tmpdir unit
|
|
|
984f77 |
+ tmpdir="$(mktemp -d)"
|
|
|
984f77 |
+ unit=$(systemd-escape --suffix mount --path "$tmpdir")
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # Set up test mount unit
|
|
|
984f77 |
+ cat > /run/systemd/system/"$unit" <
|
|
|
984f77 |
+[Mount]
|
|
|
984f77 |
+What=tmpfs
|
|
|
984f77 |
+Where=$tmpdir
|
|
|
984f77 |
+Type=tmpfs
|
|
|
984f77 |
+Options=defaults,nofail
|
|
|
984f77 |
+EOF
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # Start the unit
|
|
|
984f77 |
+ systemctl daemon-reload
|
|
|
984f77 |
+ systemctl start "$unit"
|
|
|
984f77 |
+
|
|
|
984f77 |
+ [[ "$(systemctl show --property SubState --value "$unit")" = "mounted" ]] || {
|
|
|
984f77 |
+ echo >&2 "Test mount \"$unit\" unit isn't mounted"
|
|
|
984f77 |
+ return 1
|
|
|
984f77 |
+ }
|
|
|
984f77 |
+ mountpoint -q "$tmpdir"
|
|
|
984f77 |
+
|
|
|
984f77 |
+ trap 'systemctl stop $unit' RETURN
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # Trigger the mount ratelimiting
|
|
|
984f77 |
+ cd "$(mktemp -d)"
|
|
|
984f77 |
+ mkdir foo
|
|
|
984f77 |
+ for ((i=0;i<50;++i)); do
|
|
|
984f77 |
+ mount --bind foo foo
|
|
|
984f77 |
+ umount foo
|
|
|
984f77 |
+ done
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # Unmount the test mount and start it immediately again via systemd
|
|
|
984f77 |
+ umount "$tmpdir"
|
|
|
984f77 |
+ systemctl start "$unit"
|
|
|
984f77 |
+
|
|
|
984f77 |
+ # Make sure it is seen as mounted by systemd and it actually is mounted
|
|
|
984f77 |
+ [[ "$(systemctl show --property SubState --value "$unit")" = "mounted" ]] || {
|
|
|
984f77 |
+ echo >&2 "Test mount \"$unit\" unit isn't in \"mounted\" state"
|
|
|
984f77 |
+ return 1
|
|
|
984f77 |
+ }
|
|
|
984f77 |
+
|
|
|
984f77 |
+ mountpoint -q "$tmpdir" || {
|
|
|
984f77 |
+ echo >&2 "Test mount \"$unit\" is in \"mounted\" state, actually is not mounted"
|
|
|
984f77 |
+ return 1
|
|
|
984f77 |
+ }
|
|
|
984f77 |
+}
|
|
|
984f77 |
+
|
|
|
984f77 |
systemd-analyze log-level debug
|
|
|
984f77 |
systemd-analyze log-target journal
|
|
|
984f77 |
|
|
|
984f77 |
@@ -85,6 +135,9 @@ if systemctl list-units -t mount tmp-meow* | grep -q tmp-meow; then
|
|
|
984f77 |
exit 42
|
|
|
984f77 |
fi
|
|
|
984f77 |
|
|
|
984f77 |
+# test that handling of mount start jobs is delayed when /proc/self/mouninfo monitor is rate limited
|
|
|
984f77 |
+test_issue_20329
|
|
|
984f77 |
+
|
|
|
984f77 |
systemd-analyze log-level info
|
|
|
984f77 |
|
|
|
984f77 |
echo OK >/testok
|
|
|
984f77 |
diff --git a/test/test-functions b/test/test-functions
|
|
|
984f77 |
index 4d7832b1fb..ed8ab98173 100644
|
|
|
984f77 |
--- a/test/test-functions
|
|
|
984f77 |
+++ b/test/test-functions
|
|
|
984f77 |
@@ -23,7 +23,7 @@ fi
|
|
|
984f77 |
|
|
|
984f77 |
PATH_TO_INIT=$ROOTLIBDIR/systemd
|
|
|
984f77 |
|
|
|
984f77 |
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env"
|
|
|
984f77 |
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint"
|
|
|
984f77 |
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
|
|
|
984f77 |
|
|
|
984f77 |
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
|