Commit e259d2bb authored by Jim Harris's avatar Jim Harris Committed by Darek Stojaczyk
Browse files

test/nvmf: shorten shutdown test



Currently it blindly waits 5 seconds to make sure bdevperf
has started I/O - and it does this for two different tests.
Improve that by using the get_bdevs_iostat RPC to check when
I/O start occurring.

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

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452753


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 36d1cf3a
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -23,6 +23,30 @@ if [ -z $NVMF_FIRST_TARGET_IP ]; then
	exit 0
fi

function waitforio() {
	# $1 = RPC socket
	if [ -z "$1" ]; then
		exit 1
	fi
	# $2 = bdev name
	if [ -z "$2" ]; then
		exit 1
	fi
	local ret=1
	local i
	for (( i = 10; i != 0; i-- )); do
		read_io_count=$($rpc_py -s $1 get_bdevs_iostat -b $2 | jq -r '.[1].num_read_ops')
		# A few I/O will happen during initial examine.  So wait until at least 100 I/O
		#  have completed to know that bdevperf is really generating the I/O.
		if [ $read_io_count -ge 100 ]; then
			ret=0
			break
		fi
		sleep 0.25
	done
	return $ret
}

timing_enter shutdown
timing_enter start_nvmf_tgt
# Start up the NVMf target in another process
@@ -91,8 +115,7 @@ perfpid=$!
waitforlisten $perfpid /var/tmp/bdevperf.sock
$rpc_py -s /var/tmp/bdevperf.sock wait_subsystem_init

# Sleep for a few seconds to allow I/O to begin
sleep 5
waitforio /var/tmp/bdevperf.sock Nvme1n1

# Kill bdevperf half way through
killprocess $perfpid
@@ -114,8 +137,7 @@ $rpc_py -s /var/tmp/bdevperf.sock wait_subsystem_init
# Expand the trap to clean up bdevperf if something goes wrong
trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $pid; kill -9 $perfpid; nvmfcleanup; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT

# Sleep for a few seconds to allow I/O to begin
sleep 5
waitforio /var/tmp/bdevperf.sock Nvme1n1

# Kill the target half way through
killprocess $pid