]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/env bash |
2 | ||
3 | testdir=$(readlink -f $(dirname $0)) | |
4 | rootdir=$(readlink -f $testdir/../../..) | |
11fdf7f2 | 5 | source $rootdir/test/common/autotest_common.sh |
7c673cae FG |
6 | source $rootdir/test/nvmf/common.sh |
7 | ||
11fdf7f2 TL |
8 | NULL_BDEV_SIZE=102400 |
9 | NULL_BLOCK_SIZE=512 | |
7c673cae | 10 | |
11fdf7f2 | 11 | rpc_py="$rootdir/scripts/rpc.py" |
7c673cae FG |
12 | |
13 | set -e | |
14 | ||
11fdf7f2 TL |
15 | # pass the parameter 'iso' to this script when running it in isolation to trigger rdma device initialization. |
16 | # e.g. sudo ./discovery.sh iso | |
17 | nvmftestinit $1 | |
18 | ||
7c673cae FG |
19 | if ! hash nvme; then |
20 | echo "nvme command not found; skipping discovery test" | |
21 | exit 0 | |
22 | fi | |
23 | ||
11fdf7f2 TL |
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 | |
7c673cae FG |
27 | echo "no NIC for nvmf test" |
28 | exit 0 | |
29 | fi | |
30 | ||
31 | timing_enter discovery | |
11fdf7f2 | 32 | timing_enter start_nvmf_tgt |
7c673cae | 33 | # Start up the NVMf target in another process |
11fdf7f2 | 34 | $NVMF_APP -m 0xF & |
7c673cae FG |
35 | nvmfpid=$! |
36 | ||
11fdf7f2 | 37 | trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $nvmfpid; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT |
7c673cae | 38 | |
11fdf7f2 TL |
39 | waitforlisten $nvmfpid |
40 | $rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4 | |
41 | timing_exit start_nvmf_tgt | |
7c673cae | 42 | |
11fdf7f2 TL |
43 | null_bdevs="$($rpc_py construct_null_bdev Null0 $NULL_BDEV_SIZE $NULL_BLOCK_SIZE) " |
44 | null_bdevs+="$($rpc_py construct_null_bdev Null1 $NULL_BDEV_SIZE $NULL_BLOCK_SIZE)" | |
7c673cae FG |
45 | |
46 | modprobe -v nvme-rdma | |
47 | ||
11fdf7f2 TL |
48 | $rpc_py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 |
49 | for null_bdev in $null_bdevs; do | |
50 | $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 $null_bdev | |
51 | done | |
52 | $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t rdma -a $NVMF_FIRST_TARGET_IP -s 4420 | |
7c673cae FG |
53 | |
54 | nvme discover -t rdma -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT | |
55 | ||
56 | echo "Perform nvmf subsystem discovery via RPC" | |
57 | $rpc_py get_nvmf_subsystems | |
58 | ||
59 | $rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1 | |
11fdf7f2 TL |
60 | |
61 | for null_bdev in $null_bdevs; do | |
62 | $rpc_py delete_null_bdev $null_bdev | |
63 | done | |
64 | ||
65 | check_bdevs=$($rpc_py get_bdevs | jq -r '.[].name') | |
66 | if [ -n "$check_bdevs" ]; then | |
67 | echo $check_bdevs | |
68 | exit 1 | |
69 | fi | |
7c673cae FG |
70 | |
71 | trap - SIGINT SIGTERM EXIT | |
72 | ||
73 | nvmfcleanup | |
74 | killprocess $nvmfpid | |
11fdf7f2 | 75 | nvmftestfini $1 |
7c673cae | 76 | timing_exit discovery |