]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / test / iscsi_tgt / nvme_remote / fio_remote_nvme.sh
CommitLineData
7c673cae
FG
1#!/usr/bin/env bash
2
3set -e
4
5testdir=$(readlink -f $(dirname $0))
6rootdir=$(readlink -f $testdir/../../..)
11fdf7f2 7source $rootdir/test/common/autotest_common.sh
7c673cae 8source $rootdir/test/nvmf/common.sh
11fdf7f2 9source $rootdir/test/iscsi_tgt/common.sh
7c673cae 10
11fdf7f2
TL
11RDMA_IP_LIST=$(get_available_rdma_ips)
12NVMF_FIRST_TARGET_IP=$(echo "$RDMA_IP_LIST" | head -n 1)
13if [ -z $NVMF_FIRST_TARGET_IP ]; then
7c673cae
FG
14 echo "no NIC for nvmf test"
15 exit 0
16fi
17
11fdf7f2
TL
18rpc_py="$rootdir/scripts/rpc.py"
19fio_py="$rootdir/scripts/fio.py"
7c673cae 20
7c673cae
FG
21NVMF_PORT=4420
22
11fdf7f2
TL
23# Namespaces are NOT used here on purpose. Rxe_cfg utilility used for NVMf tests do not support namespaces.
24TARGET_IP=127.0.0.1
25INITIATOR_IP=127.0.0.1
26NETMASK=$INITIATOR_IP/32
27
28function run_nvme_remote() {
29 echo "now use $1 method to run iscsi tgt."
30
31 # Start the iSCSI target without using stub
32 iscsi_rpc_addr="/var/tmp/spdk-iscsi.sock"
33 ISCSI_APP="$rootdir/app/iscsi_tgt/iscsi_tgt"
34 $ISCSI_APP -r "$iscsi_rpc_addr" -m 0x1 -p 0 -s 512 --wait-for-rpc &
35 iscsipid=$!
36 echo "iSCSI target launched. pid: $iscsipid"
37 trap "killprocess $iscsipid; killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
38 waitforlisten $iscsipid "$iscsi_rpc_addr"
39 $rpc_py -s "$iscsi_rpc_addr" set_iscsi_options -o 30 -a 16
40 $rpc_py -s "$iscsi_rpc_addr" start_subsystem_init
41 if [ "$1" = "remote" ]; then
42 $rpc_py -s $iscsi_rpc_addr construct_nvme_bdev -b "Nvme0" -t "rdma" -f "ipv4" -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode1
43 fi
44
45 echo "iSCSI target has started."
46
47 timing_exit start_iscsi_tgt
48
49 echo "Creating an iSCSI target node."
50 $rpc_py -s "$iscsi_rpc_addr" add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
51 $rpc_py -s "$iscsi_rpc_addr" add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
52 if [ "$1" = "local" ]; then
53 $rpc_py -s "$iscsi_rpc_addr" construct_nvme_bdev -b "Nvme0" -t "rdma" -f "ipv4" -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode1
54 fi
55 $rpc_py -s "$iscsi_rpc_addr" construct_target_node Target1 Target1_alias 'Nvme0n1:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d
56 sleep 1
57
58 echo "Logging in to iSCSI target."
59 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
60 iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
61}
62
7c673cae
FG
63timing_enter nvme_remote
64
65# Start the NVMf target
11fdf7f2
TL
66NVMF_APP="$rootdir/app/nvmf_tgt/nvmf_tgt"
67$NVMF_APP -m 0x2 -p 1 -s 512 --wait-for-rpc &
7c673cae
FG
68nvmfpid=$!
69echo "NVMf target launched. pid: $nvmfpid"
70trap "killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
11fdf7f2
TL
71waitforlisten $nvmfpid
72$rpc_py start_subsystem_init
73$rpc_py nvmf_create_transport -t RDMA -u 8192 -p 4
7c673cae
FG
74echo "NVMf target has started."
75bdevs=$($rpc_py construct_malloc_bdev 64 512)
11fdf7f2
TL
76$rpc_py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
77$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t rdma -a $NVMF_FIRST_TARGET_IP -s 4420
78for bdev in $bdevs; do
79 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 $bdev
80done
7c673cae
FG
81echo "NVMf subsystem created."
82
11fdf7f2 83timing_enter start_iscsi_tgt
7c673cae 84
11fdf7f2
TL
85run_nvme_remote "local"
86
87trap "iscsicleanup; killprocess $iscsipid; killprocess $nvmfpid; \
88 rm -f ./local-job0-0-verify.state; exit 1" SIGINT SIGTERM EXIT
7c673cae
FG
89sleep 1
90
91echo "Running FIO"
92$fio_py 4096 1 randrw 1 verify
93
11fdf7f2
TL
94rm -f ./local-job0-0-verify.state
95iscsicleanup
96killprocess $iscsipid
97
98run_nvme_remote "remote"
99
100echo "Running FIO"
101$fio_py 4096 1 randrw 1 verify
102
7c673cae
FG
103rm -f ./local-job0-0-verify.state
104trap - SIGINT SIGTERM EXIT
105
106iscsicleanup
107killprocess $iscsipid
108$rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
109killprocess $nvmfpid
110
11fdf7f2 111report_test_completion "iscsi_nvme_remote"
7c673cae 112timing_exit nvme_remote