From: Shachar Sharon Date: Thu, 4 Sep 2025 07:45:18 +0000 (+0300) Subject: s3:selftest: test vfs_aio_ratelimit module X-Git-Tag: tdb-1.4.15~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73f01f826abd294f454053c5b8f604a168e5fb37;p=thirdparty%2Fsamba.git s3:selftest: test vfs_aio_ratelimit module Test VFS aio_ratelimit module: ensure that a (read) delay is indeed injected. Signed-off-by: Shachar Sharon Reviewed-by: Avan Thakkar Reviewed-by: Anoop C S Reviewed-by: Gunther Deschner --- diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index dc6f7314a5d..9a059b86f38 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -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 index 00000000000..21c76e5c7f0 --- /dev/null +++ b/source3/script/tests/test_aio_ratelimit.sh @@ -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 diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 7cad85fc4cb..b16ca2e0a37 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -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'])