Commit b30a59d6 authored by Jim Harris's avatar Jim Harris Committed by Ben Walker
Browse files

test/qos: use get_bdevs_iostat RPC to get IO count



This eliminates some messy fio output parsing, and has the
side benefit of testing the bdev_iostat RPC code.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ia538cd81730704177b137c0c203d557fd640c955

Reviewed-on: https://review.gerrithub.io/423589


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarChen, LongX O <longx.o.chen@intel.com>
parent 8a703ca6
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -7,13 +7,15 @@ source $rootdir/test/iscsi_tgt/common.sh

function check_qos_works_well() {
	local enable_limit=$1
	local iops_limit=$2/1000
	local iops_limit=$2
	local retval=0

	$fio_py 8192 64 randread 5 > fio.txt
	start_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.[1].num_read_ops')
	$fio_py 8192 64 randread 5
	end_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.[1].num_read_ops')

	read_iops=$(((end_io_count-start_io_count)/5))

	local read_iops=$(cat fio.txt | grep "\(read: IOPS=\|write: IOPS=\)" |
		awk -F, '{print $1}' | awk -F= '{print $2}' | tr -d [k])
	if [ $enable_limit = true ]; then
		retval=$(echo "$iops_limit*0.9 < $read_iops && $read_iops < $iops_limit*1.01" | bc)
		if [ $retval -eq 0 ]; then
@@ -71,23 +73,22 @@ sleep 1
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT

trap "iscsicleanup; rm -f fio.txt; killprocess $pid; exit 1" SIGINT SIGTERM EXIT
trap "iscsicleanup; killprocess $pid; exit 1" SIGINT SIGTERM EXIT

# Limit the I/O rate by RPC, then confirm the observed rate matches.
$rpc_py set_bdev_qos_limit_iops Malloc0 $IOPS_LIMIT
check_qos_works_well true $IOPS_LIMIT
check_qos_works_well true $IOPS_LIMIT Malloc0

# Now disable the rate limiting, and confirm the observed rate is not limited anymore.
$rpc_py set_bdev_qos_limit_iops Malloc0 0
check_qos_works_well false $IOPS_LIMIT
check_qos_works_well false $IOPS_LIMIT Malloc0

# Limit the I/O rate again.
$rpc_py set_bdev_qos_limit_iops Malloc0 $IOPS_LIMIT
check_qos_works_well true $IOPS_LIMIT
check_qos_works_well true $IOPS_LIMIT Malloc0
echo "I/O rate limiting tests successful"

iscsicleanup
rm -f fio.txt
$rpc_py delete_target_node 'iqn.2016-06.io.spdk:Target1'

rm -f ./local-job0-0-verify.state