]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:selftest: test vfs_aio_ratelimit module
authorShachar Sharon <ssharon@redhat.com>
Thu, 4 Sep 2025 07:45:18 +0000 (10:45 +0300)
committerAnoop C S <anoopcs@samba.org>
Sun, 18 Jan 2026 06:20:30 +0000 (06:20 +0000)
Test VFS aio_ratelimit module: ensure that a (read) delay is indeed
injected.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Avan Thakkar <athakkar@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Gunther Deschner <gd@samba.org>
selftest/target/Samba3.pm
source3/script/tests/test_aio_ratelimit.sh [new file with mode: 0755]
source3/selftest/tests.py

index dc6f7314a5d9f5252867f96de1536c2267aea6ee..9a059b86f38ef3ede7490c025e0cd37e3160610a 100755 (executable)
@@ -3756,6 +3756,17 @@ sub provision($$)
        comment = smb username is [%U]
        guest ok = yes
 
+[aio_ratelimit]
+       comment = Testing aio_ratelimit
+       path = $shrdir
+       vfs objects = aio_ratelimit
+       aio_ratelimit: read_iops_limit = 10
+       aio_ratelimit: read_bw_limit = 100000
+       aio_ratelimit: read_delay_max = 10
+       aio_ratelimit: write_iops_limit = 100
+       aio_ratelimit: write_bw_limit = 100000
+       aio_ratelimit: write_delay_max = 10
+
 include = $aliceconfdir/%U.conf
        ";
 
diff --git a/source3/script/tests/test_aio_ratelimit.sh b/source3/script/tests/test_aio_ratelimit.sh
new file mode 100755 (executable)
index 0000000..21c76e5
--- /dev/null
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+#
+# Test VFS module aio_ratelimit
+
+SELF=$(basename "$0")
+if [ $# -lt 5 ]; then
+       echo Usage: "${SELF}" SERVERCONFFILE SMBCLIENT \
+               SERVER LOCAL_PATH SHARENAME
+       exit 1
+fi
+
+CONF="$1"
+SMBCLIENT="$2"
+SERVER="$3"
+LOCAL_PATH="$4"
+SHARE="$5"
+
+# Do not let deprecated option warnings muck this up
+SAMBA_DEPRECATED_SUPPRESS=1
+export SAMBA_DEPRECATED_SUPPRESS
+
+incdir="$(dirname "$0")/../../../testprogs/blackbox"
+. $incdir/subunit.sh
+
+failed=0
+
+# Prepare
+cd $SELFTEST_TMPDIR || exit 1
+
+# Sub tests
+test_aio_ratelimit()
+{
+       local testfile="${FUNCNAME[0]}"
+       local src="${LOCAL_PATH}/${testfile}-src"
+       local dst="${testfile}-dst"
+       local tgt="${testfile}-tgt"
+
+       # Create source file
+       dd if=/dev/urandom of="${src}" bs=1M count=1
+       stat "$src"
+
+       SECONDS=0
+
+       # Write
+       CLI_FORCE_INTERACTIVE=1 ${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} \
+               -U${USER}%${PASSWORD} -c "put ${src} ${dst}"
+       ret=$?
+       if [ $ret != 0 ]; then
+               printf "failed to write file: %s\n" "${ret}"
+               return 1
+       fi
+
+       # Read multiple times
+       count=1
+       while [ $count -le 10 ]; do
+               CLI_FORCE_INTERACTIVE=1 \
+                       ${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} \
+                       -U${USER}%${PASSWORD} -c "get ${dst} ${tgt}"
+               ret=$?
+               if [ $ret != 0 ]; then
+                       printf "failed to read file: %s\n" "${ret}"
+                       return 1
+               fi
+               (( count++ ))
+       done
+
+       # Expect a forced-delay
+       if [ ${SECONDS} -lt 10 ]; then
+               printf "no read delay: elapsed-secs=%d\n" "${SECONDS}"
+               return 1
+       fi
+
+       # Delete
+       CLI_FORCE_INTERACTIVE=1 ${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} \
+           -U${USER}%${PASSWORD} -c "del ${dst}"
+       ret=$?
+       if [ $ret != 0 ]; then
+               printf "failed to delete file: %s\n" "${ret}"
+               return 1
+       fi
+
+       # Cleanups
+       rm -f "${src}" "${tgt}"
+}
+
+# Actual tests
+testit "test_aio_ratelimit" \
+       test_aio_ratelimit ||
+       failed=$(expr $failed + 1)
+
+testok $0 $failed
index 7cad85fc4cbccc31ba9f913854a15b0fab18b806..b16ca2e0a37911302a603162cba99f921339814c 100755 (executable)
@@ -1682,6 +1682,15 @@ plantestsuite("samba3.blackbox.aio-outstanding", "simpleserver:local",
                '$SERVER_IP',
                "aio_delay_inject"])
 
+plantestsuite("samba3.blackbox.aio_ratelimit", "simpleserver:local",
+              [os.path.join(samba3srcdir,
+                            "script/tests/test_aio_ratelimit.sh"),
+               configuration,
+               os.path.join(bindir(), "smbclient"),
+               '$SERVER_IP',
+               '$LOCAL_PATH',
+               "aio_ratelimit"])
+
 plantestsuite("samba3.blackbox.deadtime", "simpleserver:local",
               [os.path.join(samba3srcdir, "script/tests/test_deadtime.sh"),
                '$SERVER_IP'])