]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/nvmf/target/nmic.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / test / nvmf / target / nmic.sh
1 #!/usr/bin/env bash
2
3 testdir=$(readlink -f $(dirname $0))
4 rootdir=$(readlink -f $testdir/../../..)
5 source $rootdir/test/common/autotest_common.sh
6 source $rootdir/test/nvmf/common.sh
7
8 MALLOC_BDEV_SIZE=64
9 MALLOC_BLOCK_SIZE=512
10
11 rpc_py="$rootdir/scripts/rpc.py"
12
13 set -e
14
15 timing_enter nmic
16 nvmftestinit
17 nvmfappstart "-m 0xF"
18
19 NVMF_SECOND_TARGET_IP=$(echo "$RDMA_IP_LIST" | sed -n 2p)
20
21 $rpc_py nvmf_create_transport -t $TEST_TRANSPORT -u 8192
22
23 # Create subsystems
24 $rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0
25 $rpc_py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode1 -a -s SPDK1
26 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0
27 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT"
28
29 echo "test case1: single bdev can't be used in multiple subsystems"
30 set +e
31 $rpc_py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode2 -a -s SPDK2
32 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode2 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT"
33 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode2 Malloc0
34 nmic_status=$?
35
36 if [ $nmic_status -eq 0 ]; then
37 echo " Adding namespace passed - failure expected."
38 nvmfcleanup
39 nvmftestfini
40 exit 1
41 else
42 echo " Adding namespace failed - expected result."
43 fi
44 set -e
45
46 echo "test case2: host connect to nvmf target in multiple paths"
47 if [ ! -z $NVMF_SECOND_TARGET_IP ]; then
48 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_SECOND_TARGET_IP -s $NVMF_PORT
49
50 nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
51 nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_SECOND_TARGET_IP" -s "$NVMF_PORT"
52
53 waitforblk "nvme0n1"
54
55 $rootdir/scripts/fio.py -p nvmf -i 4096 -d 1 -t write -r 1 -v
56 fi
57
58 nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" || true
59
60 trap - SIGINT SIGTERM EXIT
61
62 nvmfcleanup
63 nvmftestfini
64 timing_exit nmic