]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/nvmf/nvme_cli/nvme_cli.sh
update download target update for octopus release
[ceph.git] / ceph / src / spdk / test / nvmf / nvme_cli / nvme_cli.sh
CommitLineData
7c673cae
FG
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../../..)
11fdf7f2 5source $rootdir/test/common/autotest_common.sh
7c673cae
FG
6source $rootdir/test/nvmf/common.sh
7
11fdf7f2
TL
8if [ -z "${DEPENDENCY_DIR}" ]; then
9 echo DEPENDENCY_DIR not defined!
10 exit 1
11fi
12
13spdk_nvme_cli="${DEPENDENCY_DIR}/nvme-cli"
14
7c673cae
FG
15MALLOC_BDEV_SIZE=64
16MALLOC_BLOCK_SIZE=512
17
11fdf7f2 18rpc_py="$rootdir/scripts/rpc.py"
7c673cae
FG
19
20set -e
21
11fdf7f2
TL
22# pass the parameter 'iso' to this script when running it in isolation to trigger rdma device initialization.
23# e.g. sudo ./nvme_cli.sh iso
24nvmftestinit $1
25
26RDMA_IP_LIST=$(get_available_rdma_ips)
27NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1)
28if [ -z $NVMF_FIRST_TARGET_IP ]; then
7c673cae
FG
29 echo "no NIC for nvmf test"
30 exit 0
31fi
32
33timing_enter nvme_cli
11fdf7f2
TL
34timing_enter start_nvmf_tgt
35$NVMF_APP -m 0xF &
7c673cae
FG
36nvmfpid=$!
37
11fdf7f2 38trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $nvmfpid; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT
7c673cae 39
11fdf7f2
TL
40waitforlisten $nvmfpid
41$rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
42timing_exit start_nvmf_tgt
7c673cae 43
11fdf7f2
TL
44bdevs="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) "
45bdevs+="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
7c673cae
FG
46
47modprobe -v nvme-rdma
48
11fdf7f2
TL
49$rpc_py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
50for bdev in $bdevs; do
51 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 $bdev
52done
53$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t rdma -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
7c673cae
FG
54
55nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
11fdf7f2
TL
56
57waitforblk "nvme0n1"
58waitforblk "nvme0n2"
7c673cae
FG
59
60nvme list
61
62for ctrl in /dev/nvme?; do
63 nvme id-ctrl $ctrl
64 nvme smart-log $ctrl
65done
66
67for ns in /dev/nvme?n*; do
68 nvme id-ns $ns
69done
70
71nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" || true
72nvme disconnect -n "nqn.2016-06.io.spdk:cnode2" || true
73
11fdf7f2
TL
74if [ -d $spdk_nvme_cli ]; then
75 # Test spdk/nvme-cli NVMe-oF commands: discover, connect and disconnect
76 cd $spdk_nvme_cli
77 ./nvme discover -t rdma -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT"
78 nvme_num_before_connection=$(nvme list |grep "/dev/nvme*"|awk '{print $1}'|wc -l)
79 ./nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
80 sleep 1
81 nvme_num=$(nvme list |grep "/dev/nvme*"|awk '{print $1}'|wc -l)
82 ./nvme disconnect -n "nqn.2016-06.io.spdk:cnode1"
83 if [ $nvme_num -le $nvme_num_before_connection ]; then
84 echo "spdk/nvme-cli connect target devices failed"
85 exit 1
86 fi
87fi
7c673cae 88
11fdf7f2 89$rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
7c673cae
FG
90trap - SIGINT SIGTERM EXIT
91
92nvmfcleanup
93killprocess $nvmfpid
11fdf7f2
TL
94nvmftestfini $1
95report_test_completion "nvmf_spdk_nvme_cli"
7c673cae 96timing_exit nvme_cli