Commit f470cf3d authored by Seth Howell's avatar Seth Howell Committed by Tomasz Zawadzki
Browse files

nvmf/shutdown.sh: convert to run_test framework



This cleanns up the logs for this test and makes it easier to follow.

Change-Id: Ifc6fcea8672d4d186e3e622eddfc200fdfd076ce
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476822


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 968d4dfd
Loading
Loading
Loading
Loading
+64 −65
Original line number Diff line number Diff line
@@ -34,42 +34,8 @@ function waitforio() {
	return $ret
}

nvmftestinit
nvmfappstart "-m 0x1E"

$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192

num_subsystems=10
# SoftRoce does not have enough queues available for
# this test. Detect if we're using software RDMA.
# If so, only use two subsystem.
if check_ip_is_soft_roce "$NVMF_FIRST_TARGET_IP"; then
	num_subsystems=2
fi

touch $testdir/bdevperf.conf
echo "[Nvme]" > $testdir/bdevperf.conf

timing_enter create_subsystems
# Create subsystems
rm -rf $testdir/rpcs.txt
for i in $(seq 1 $num_subsystems)
do
	cat <<- EOL >> $testdir/rpcs.txt
	bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc$i
	nvmf_create_subsystem nqn.2016-06.io.spdk:cnode$i -a -s SPDK$i
	nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$i Malloc$i
	nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode$i -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
	EOL

	echo "  TransportID \"trtype:$TEST_TRANSPORT adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode$i traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT hostaddr:$NVMF_FIRST_TARGET_IP\" Nvme$i" >> $testdir/bdevperf.conf
done
$rpc_py < $testdir/rpcs.txt
timing_exit create_subsystems

# Test 1: Kill the initiator unexpectedly with no I/O outstanding

timing_enter test1
function nvmf_shutdown_tc1 {
	# Run bdev_svc, which connects but does not issue I/O
	$rootdir/test/app/bdev_svc/bdev_svc -m 0x1 -i 1 -r /var/tmp/bdevperf.sock -c $testdir/bdevperf.conf &
	perfpid=$!
@@ -86,11 +52,10 @@ kill -0 $nvmfpid

	# Connect with bdevperf and confirm it works
	$rootdir/test/bdev/bdevperf/bdevperf -r /var/tmp/bdevperf.sock -c $testdir/bdevperf.conf -q 64 -o 65536 -w verify -t 1
timing_exit test1
}

# Test 2: Kill initiator unexpectedly with I/O outstanding

timing_enter test2
function nvmf_shutdown_tc2 {
	# Run bdevperf
	$rootdir/test/bdev/bdevperf/bdevperf -r /var/tmp/bdevperf.sock -c $testdir/bdevperf.conf -q 64 -o 65536 -w verify -t 10 &
	perfpid=$!
@@ -105,11 +70,10 @@ killprocess $perfpid
	# Verify the target stays up
	sleep 1
	kill -0 $nvmfpid
timing_exit test2
}

# Test 3: Kill the target unexpectedly with I/O outstanding

timing_enter test3
function nvmf_shutdown_tc3 {
	# Run bdevperf
	$rootdir/test/bdev/bdevperf/bdevperf -r /var/tmp/bdevperf.sock -c $testdir/bdevperf.conf -q 64 -o 65536 -w verify -t 10 &
	perfpid=$!
@@ -129,13 +93,48 @@ sleep 1
	# TODO: Right now the NVMe-oF initiator will not correctly detect broken connections
	# and so it will never shut down. Just kill it.
	kill -9 $perfpid || true
timing_exit test3
}

nvmftestinit
nvmfappstart "-m 0x1E"

$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192

num_subsystems=10
# SoftRoce does not have enough queues available for
# this test. Detect if we're using software RDMA.
# If so, only use two subsystem.
if check_ip_is_soft_roce "$NVMF_FIRST_TARGET_IP"; then
	num_subsystems=2
fi

touch $testdir/bdevperf.conf
echo "[Nvme]" > $testdir/bdevperf.conf

timing_enter create_subsystems
# Create subsystems
rm -rf $testdir/rpcs.txt
for i in $(seq 1 $num_subsystems)
do
	cat <<- EOL >> $testdir/rpcs.txt
	bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc$i
	nvmf_create_subsystem nqn.2016-06.io.spdk:cnode$i -a -s SPDK$i
	nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$i Malloc$i
	nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode$i -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
	EOL

	echo "  TransportID \"trtype:$TEST_TRANSPORT adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode$i traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT hostaddr:$NVMF_FIRST_TARGET_IP\" Nvme$i" >> $testdir/bdevperf.conf
done
$rpc_py < $testdir/rpcs.txt
timing_exit create_subsystems

run_test "case" "nvmf_shutdown_tc1" nvmf_shutdown_tc1
run_test "case" "nvmf_shutdown_tc2" nvmf_shutdown_tc2
run_test "case" "nvmf_shutdown_tc3" nvmf_shutdown_tc3

rm -f ./local-job0-0-verify.state
rm -rf $testdir/bdevperf.conf
rm -rf $testdir/rpcs.txt
trap - SIGINT SIGTERM EXIT

timing_enter testfini
nvmftestfini
timing_exit testfini