]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/nvmf/create_transport/create_transport.sh
update download target update for octopus release
[ceph.git] / ceph / src / spdk / test / nvmf / create_transport / create_transport.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 NULL_BDEV_SIZE=102400
9 NULL_BLOCK_SIZE=512
10
11 rpc_py="python $rootdir/scripts/rpc.py"
12
13 set -e
14
15 # pass the parameter 'iso' to this script when running it in isolation to trigger rdma device initialization.
16 # e.g. sudo ./crt_trprt.sh iso
17 nvmftestinit $1
18
19 if ! hash nvme; then
20 echo "nvme command not found; skipping create transport test"
21 exit 0
22 fi
23
24 RDMA_IP_LIST=$(get_available_rdma_ips)
25 NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1)
26 if [ -z $NVMF_FIRST_TARGET_IP ]; then
27 echo "no NIC for nvmf test"
28 exit 0
29 fi
30
31 timing_enter cr_trprt
32 timing_enter start_nvmf_tgt
33 # Start up the NVMf target in another process
34 $NVMF_APP -m 0xF &
35 nvmfpid=$!
36
37 trap "killprocess $nvmfpid; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT
38
39 waitforlisten $nvmfpid
40 # Use nvmf_create_transport call to create transport
41 $rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
42 timing_exit start_nvmf_tgt
43
44 null_bdevs="$($rpc_py construct_null_bdev Null0 $NULL_BDEV_SIZE $NULL_BLOCK_SIZE) "
45 null_bdevs+="$($rpc_py construct_null_bdev Null1 $NULL_BDEV_SIZE $NULL_BLOCK_SIZE)"
46
47 modprobe -v nvme-rdma
48
49 $rpc_py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
50 for null_bdev in $null_bdevs; do
51 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 $null_bdev
52 done
53 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t rdma -a $NVMF_FIRST_TARGET_IP -s 4420
54
55 nvme discover -t rdma -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
56
57 echo "Perform nvmf subsystem discovery via RPC"
58 $rpc_py get_nvmf_subsystems
59
60 $rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
61
62 for null_bdev in $null_bdevs; do
63 $rpc_py delete_null_bdev $null_bdev
64 done
65
66 check_bdevs=$($rpc_py get_bdevs | jq -r '.[].name')
67 if [ -n "$check_bdevs" ]; then
68 echo $check_bdevs
69 exit 1
70 fi
71
72 trap - SIGINT SIGTERM EXIT
73
74 nvmfcleanup
75 killprocess $nvmfpid
76 nvmftestfini $1
77 timing_exit crt_trprt