test/qos: get rid of check_qos_works_well()

check_qos_works_well() has been split into two separate
functions: run_fio() and verify_qos_limits().

Change-Id: I8c112ab93aed9f16d80c9a0a3f61280c44bf6539
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451888
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Darek Stojaczyk 2019-04-24 14:59:33 +02:00 committed by Jim Harris
parent 22364ca8f7
commit a1e4e7279e

View File

@ -9,46 +9,30 @@ source $rootdir/test/iscsi_tgt/common.sh
# $2 = test type posix or vpp. defaults to posix.
iscsitestinit $1 $2
function check_qos_works_well() {
local enable_limit=$1
local qos_limit=$2
local check_qos=$4
local retval=0
local iostats
function run_fio() {
local bdev_name=$1
local iostats=$($rpc_py get_bdevs_iostat -b $bdev_name)
local run_time=5
iostats=$($rpc_py get_bdevs_iostat -b $3)
start_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats")
start_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats")
local start_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats")
local start_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats")
$fio_py iscsi 1024 128 randread 5 1
$fio_py iscsi 1024 128 randread $run_time 1
iostats=$($rpc_py get_bdevs_iostat -b $3)
end_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats")
end_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats")
iostats=$($rpc_py get_bdevs_iostat -b $bdev_name)
local end_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats")
local end_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats")
IOPS_RESULT=$(((end_io_count-start_io_count)/5))
BANDWIDTH_RESULT=$(((end_bytes_read-start_bytes_read)/5))
IOPS_RESULT=$(((end_io_count-start_io_count)/$run_time))
BANDWIDTH_RESULT=$(((end_bytes_read-start_bytes_read)/$run_time))
}
if [ $LIMIT_TYPE = IOPS ]; then
read_result=$IOPS_RESULT
else
read_result=$BANDWIDTH_RESULT
fi
function verify_qos_limits() {
local result=$1
local limit=$2
if [ $enable_limit = true ]; then
#qos realization is related with bytes transfered.It currently have like 5% variation.
retval=$(echo "$qos_limit*0.85 < $read_result && $read_result < $qos_limit*1.05" | bc)
if [ $retval -eq 0 ]; then
echo "Failed to limit the io read rate of malloc bdev by qos"
exit 1
fi
else
retval=$(echo "$read_result > $qos_limit" | bc)
if [ $retval -eq 0 ]; then
echo "$read_result less than $qos_limit - expected greater than"
exit 1
fi
fi
[ "$(bc <<< "$result > $limit*0.85")" -eq 1 ] && \
[ "$(bc <<< "$result < $limit*1.05")" -eq 1 ]
}
if [ -z "$TARGET_IP" ]; then
@ -67,7 +51,6 @@ MALLOC_BDEV_SIZE=64
MALLOC_BLOCK_SIZE=512
IOPS_RESULT=
BANDWIDTH_RESULT=
LIMIT_TYPE=IOPS
rpc_py="$rootdir/scripts/rpc.py"
fio_py="$rootdir/scripts/fio.py"
@ -98,7 +81,7 @@ iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
trap "iscsicleanup; killprocess $pid; iscsitestfini $1 $2; exit 1" SIGINT SIGTERM EXIT
# Run FIO without any QOS limits to determine the raw performance
check_qos_works_well false 0 Malloc0
run_fio Malloc0
# Set IOPS/bandwidth limit to 50% of the actual unrestrained performance.
IOPS_LIMIT=$(($IOPS_RESULT/2))
@ -117,29 +100,36 @@ READ_BANDWIDTH_LIMIT=$(($READ_BANDWIDTH_LIMIT_MB*1024*1024))
# Limit the I/O rate by RPC, then confirm the observed rate matches.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT
check_qos_works_well true $IOPS_LIMIT Malloc0
run_fio Malloc0
verify_qos_limits $IOPS_RESULT $IOPS_LIMIT
# Now disable the rate limiting, and confirm the observed rate is not limited anymore.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec 0
check_qos_works_well false $IOPS_LIMIT Malloc0
run_fio Malloc0
[ "$IOPS_RESULT" -gt "$IOPS_LIMIT" ]
# Limit the I/O rate again.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT
check_qos_works_well true $IOPS_LIMIT Malloc0
run_fio Malloc0
verify_qos_limits $IOPS_RESULT $IOPS_LIMIT
echo "I/O rate limiting tests successful"
# Limit the I/O bandwidth rate by RPC, then confirm the observed rate matches.
LIMIT_TYPE=BANDWIDTH
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec 0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB
check_qos_works_well true $BANDWIDTH_LIMIT Malloc0
run_fio Malloc0
verify_qos_limits $BANDWIDTH_RESULT $BANDWIDTH_LIMIT
# Now disable the bandwidth rate limiting, and confirm the observed rate is not limited anymore.
$rpc_py set_bdev_qos_limit Malloc0 --rw_mbytes_per_sec 0
check_qos_works_well false $BANDWIDTH_LIMIT Malloc0
run_fio Malloc0
[ "$BANDWIDTH_RESULT" -gt "$BANDWIDTH_LIMIT" ]
# Limit the I/O bandwidth rate again with both read/write and read/only.
$rpc_py set_bdev_qos_limit Malloc0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB --r_mbytes_per_sec $READ_BANDWIDTH_LIMIT_MB
check_qos_works_well true $READ_BANDWIDTH_LIMIT Malloc0
run_fio Malloc0
verify_qos_limits $BANDWIDTH_RESULT $READ_BANDWIDTH_LIMIT
echo "I/O bandwidth limiting tests successful"
iscsicleanup