Commit a02b1481 authored by Jim Harris's avatar Jim Harris
Browse files

test/nvmf: reduce duplication between target scripts



All of the checking for NVMF_FIRST_TARGET_IP, starting
the target, waiting on the target and modprobing
nvme-rdma is duplicated in every script.  So move
a lot of this either to nvmftestinit() or a new
nvmfappstart() function in common.sh.

Also just kill the nvmf target in nvmftestfini, rather
than the script to explicitly kill it.

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

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


Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 913f5858
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -8,18 +8,11 @@ source $rootdir/test/common/autotest_common.sh
source $rootdir/test/nvmf/common.sh
source $rootdir/test/iscsi_tgt/common.sh

nvmftestinit
# $1 = "iso" - triggers isolation mode (setting up required environment).
# $2 = test type posix or vpp. defaults to posix.
nvmftestinit $1
iscsitestinit $1 $2

RDMA_IP_LIST=$(get_available_rdma_ips)
NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1)
if [ -z $NVMF_FIRST_TARGET_IP ]; then
	echo "no NIC for nvmf test"
	exit 0
fi

rpc_py="$rootdir/scripts/rpc.py"
fio_py="$rootdir/scripts/fio.py"

@@ -38,7 +31,7 @@ function run_nvme_remote() {
	$ISCSI_APP -r "$iscsi_rpc_addr" -m 0x1 -p 0 -s 512 --wait-for-rpc &
	iscsipid=$!
	echo "iSCSI target launched. pid: $iscsipid"
	trap "killprocess $iscsipid; killprocess $nvmfpid; iscsitestfini $1 $2; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT
	trap "killprocess $iscsipid; iscsitestfini $1 $2; nvmftestfini; exit 1" SIGINT SIGTERM EXIT
	waitforlisten $iscsipid "$iscsi_rpc_addr"
	$rpc_py -s "$iscsi_rpc_addr" set_iscsi_options -o 30 -a 16
	$rpc_py -s "$iscsi_rpc_addr" start_subsystem_init
@@ -71,7 +64,7 @@ NVMF_APP="$rootdir/app/nvmf_tgt/nvmf_tgt"
$NVMF_APP -m 0x2 -p 1 -s 512 --wait-for-rpc &
nvmfpid=$!
echo "NVMf target launched. pid: $nvmfpid"
trap "killprocess $nvmfpid; iscsitestfini $1 $2; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT
trap "iscsitestfini $1 $2; nvmftestfini; exit 1" SIGINT SIGTERM EXIT
waitforlisten $nvmfpid
$rpc_py start_subsystem_init
$rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
@@ -88,8 +81,8 @@ timing_enter start_iscsi_tgt

run_nvme_remote "local"

trap "iscsicleanup; killprocess $iscsipid; killprocess $nvmfpid; \
	rm -f ./local-job0-0-verify.state; iscsitestfini $1 $2; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT
trap "iscsicleanup; killprocess $iscsipid; \
	rm -f ./local-job0-0-verify.state; iscsitestfini $1 $2; nvmftestfini; exit 1" SIGINT SIGTERM EXIT
sleep 1

echo "Running FIO"
@@ -110,9 +103,8 @@ trap - SIGINT SIGTERM EXIT
iscsicleanup
killprocess $iscsipid
$rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
killprocess $nvmfpid

report_test_completion "iscsi_nvme_remote"
iscsitestfini $1 $2
nvmftestfini $1
nvmftestfini
timing_exit nvme_remote
+18 −0
Original line number Diff line number Diff line
@@ -163,10 +163,28 @@ function nvmftestinit()
		$rootdir/scripts/setup.sh
		rdma_device_init
	fi
	RDMA_IP_LIST=$(get_available_rdma_ips)
	NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1)
	if [ -z $NVMF_FIRST_TARGET_IP ]; then
		echo "no NIC for nvmf test"
		exit 0
	fi
}

function nvmfappstart()
{
	timing_enter start_nvmf_tgt
	$NVMF_APP $1 &
	nvmfpid=$!
	trap "process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1" SIGINT SIGTERM EXIT
	waitforlisten $nvmfpid
	modprobe nvme-rdma
	timing_exit start_nvmf_tgt
}

function nvmftestfini()
{
	killprocess $nvmfpid
	if [ "$NVMF_TEST_MODE" == "iso" ]; then
		$rootdir/scripts/setup.sh reset
		rdma_device_init
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ timing_enter start_nvmf_tgt
$NVMF_APP -m 0xF &
nvmfpid=$!

trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $nvmfpid; nvmftestfini; exit 1" SIGINT SIGTERM EXIT
trap "process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1" SIGINT SIGTERM EXIT

waitforlisten $nvmfpid
$rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
@@ -82,6 +82,5 @@ trap - SIGINT SIGTERM EXIT


nvmfcleanup
killprocess $nvmfpid
nvmftestfini
timing_exit aer
+1 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ timing_enter start_nvmf_tgt
$NVMF_APP -m 0xF &
nvmfpid=$!

trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $nvmfpid;  nvmftestfini; exit 1" SIGINT SIGTERM EXIT
trap "process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1" SIGINT SIGTERM EXIT

waitforlisten $nvmfpid
$rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
@@ -49,6 +49,5 @@ $rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1

trap - SIGINT SIGTERM EXIT

killprocess $nvmfpid
nvmftestfini
timing_exit bdevperf
+1 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ timing_enter start_nvmf_tgt
$NVMF_APP -m 0xF &
nvmfpid=$!

trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $nvmfpid;  nvmftestfini; exit 1" SIGINT SIGTERM EXIT
trap "process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1" SIGINT SIGTERM EXIT

waitforlisten $nvmfpid
$rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
@@ -91,6 +91,5 @@ fi
trap - SIGINT SIGTERM EXIT

rm -f ./local-test-0-verify.state
killprocess $nvmfpid
nvmftestfini
timing_exit fio
Loading