xref: /spdk/test/nvmf/target/delete_subsystem.sh (revision 18c8b52afa69f39481ebb75711b2f30b11693f9d)
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../../..)
5source $rootdir/test/common/autotest_common.sh
6source $rootdir/test/nvmf/common.sh
7
8nvmftestinit
9nvmfappstart -m 0x3
10
11$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192
12$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 -m 10
13$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
14$rpc_py bdev_null_create NULL1 1000 512
15# Subsystem destruction process waits for all controllers to be destroyed which in turn wait
16# for all qpairs to be deleted. A qpair can only be deleted when all outstanding requests are completed
17# bdev_delay is used in this test to make a situation when qpair has outstanding requests when disconnect
18# starts. It allows to trigger async qpair/controller/subsystem destruction path
19$rpc_py bdev_delay_create -b NULL1 -d Delay0 -r 1000000 -t 1000000 -w 1000000 -n 1000000
20$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Delay0
21
22$SPDK_EXAMPLE_DIR/perf -c 0xC -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" \
23	-t 5 -q 128 -w randrw -M 70 -o 512 -P 4 &
24perf_pid=$!
25
26sleep 2
27
28$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1
29
30delay=0
31while kill -0 $perf_pid; do
32	sleep 0.5
33	#wait 15 seconds max
34	if ((delay++ > 30)); then
35		echo "perf is still running, failing the test"
36		false
37	fi
38done
39
40#check that traffic goes when a new subsystem is created
41$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 -m 10
42$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
43$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Delay0
44
45$SPDK_EXAMPLE_DIR/perf -c 0xC -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" \
46	-t 3 -q 128 -w randrw -M 70 -o 512 -P 4 &
47perf_pid=$!
48
49delay=0
50while kill -0 $perf_pid; do
51	sleep 0.5
52	#wait 10 seconds max
53	if ((delay++ > 20)); then
54		echo "perf didn't finish on time"
55		false
56	fi
57done
58
59trap - SIGINT SIGTERM EXIT
60
61nvmftestfini
62