]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/iscsi_tgt/perf/iscsi_target.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / test / iscsi_tgt / perf / iscsi_target.sh
CommitLineData
9f95a23c
TL
1#!/usr/bin/env bash
2
f67539c2
TL
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../../..)
5source $rootdir/test/common/autotest_common.sh
6source $rootdir/test/iscsi_tgt/common.sh
7
8rpc_py="$rootdir/scripts/rpc.py -s $testdir/rpc_iscsi.sock"
9f95a23c
TL
9
10BLK_SIZE=4096
11RW=randrw
12MIX=100
13IODEPTH=128
14RUNTIME=60
15RAMP_TIME=10
f67539c2 16FIO_PATH=$CONFIG_FIO_SOURCE_DIR
9f95a23c
TL
17DISKNO="ALL"
18CPUMASK=0x02
19NUM_JOBS=1
20ISCSI_TGT_CM=0x02
9f95a23c
TL
21
22# Performance test for iscsi_tgt, run on devices with proper hardware support (target and inititator)
f67539c2
TL
23function usage() {
24 [[ -n $2 ]] && (
25 echo "$2"
26 echo ""
27 )
9f95a23c
TL
28 echo "Usage: $(basename $1) [options]"
29 echo "-h, --help Print help and exit"
30 echo " --fiopath=PATH Path to fio directory on initiator. [default=$FIO_PATH]"
31 echo " --disk_no=INT,ALL Number of disks to test on, if =ALL then test on all found disks. [default=$DISKNO]"
32 echo " --target_ip=IP The IP address of target used for test."
33 echo " --initiator_ip=IP The IP address of initiator used for test."
34 echo " --init_mgmnt_ip=IP The IP address of initiator used for communication."
35 echo " --iscsi_tgt_mask=HEX iscsi_tgt core mask. [default=$ISCSI_TGT_CM]"
36}
37
38while getopts 'h-:' optchar; do
39 case "$optchar" in
40 -)
f67539c2
TL
41 case "$OPTARG" in
42 help)
43 usage $0
44 exit 0
45 ;;
46 fiopath=*) FIO_BIN="${OPTARG#*=}" ;;
47 disk_no=*) DISKNO="${OPTARG#*=}" ;;
48 target_ip=*) TARGET_IP="${OPTARG#*=}" ;;
49 initiator_ip=*) INITIATOR_IP="${OPTARG#*=}" ;;
50 init_mgmnt_ip=*) IP_I_SSH="${OPTARG#*=}" ;;
51 iscsi_tgt_mask=*) ISCSI_TGT_CM="${OPTARG#*=}" ;;
52 *)
53 usage $0 echo "Invalid argument '$OPTARG'"
54 exit 1
55 ;;
56 esac
57 ;;
58 h)
59 usage $0
60 exit 0
61 ;;
62 *)
63 usage $0 "Invalid argument '$optchar'"
64 exit 1
65 ;;
9f95a23c
TL
66 esac
67done
68
9f95a23c
TL
69if [ -z "$TARGET_IP" ]; then
70 error "No IP address of iscsi target is given"
71fi
72
73if [ -z "$INITIATOR_IP" ]; then
74 error "No IP address of iscsi initiator is given"
75fi
76
77if [ -z "$IP_I_SSH" ]; then
78 error "No IP address of initiator is given"
79fi
80
81if [ $EUID -ne 0 ]; then
82 error "INFO: This script must be run with root privileges"
83fi
84
f67539c2
TL
85function ssh_initiator() {
86 # shellcheck disable=SC2029
87 # (we want to expand $@ immediately, not on the VM)
9f95a23c
TL
88 ssh -i $HOME/.ssh/spdk_vhost_id_rsa root@$IP_I_SSH "$@"
89}
90
91NETMASK=$INITIATOR_IP/32
9f95a23c
TL
92iscsi_fio_results="$testdir/perf_output/iscsi_fio.json"
93rm -rf $iscsi_fio_results
94mkdir -p $testdir/perf_output
95touch $iscsi_fio_results
96
97timing_enter run_iscsi_app
f67539c2 98$SPDK_BIN_DIR/iscsi_tgt -m $ISCSI_TGT_CM -r $testdir/rpc_iscsi.sock --wait-for-rpc &
9f95a23c 99pid=$!
f67539c2 100trap 'rm -f $testdir/perf.job; killprocess $pid; print_backtrace; exit 1' ERR SIGTERM SIGABRT
9f95a23c 101waitforlisten "$pid" "$testdir/rpc_iscsi.sock"
f67539c2
TL
102$rpc_py iscsi_set_options -b "iqn.2016-06.io.spdk" -f "/usr/local/etc/spdk/auth.conf" -o 30 -i -l 0 -a 16
103$rpc_py framework_start_init
9f95a23c
TL
104$rootdir/scripts/gen_nvme.sh --json | $rpc_py load_subsystem_config
105sleep 1
106timing_exit run_iscsi_app
107
108timing_enter iscsi_config
f67539c2
TL
109bdevs=($($rpc_py bdev_get_bdevs | jq -r '.[].name'))
110if [[ $DISKNO == "ALL" ]] || [[ $DISKNO == "all" ]]; then
9f95a23c 111 DISKNO=${#bdevs[@]}
f67539c2 112elif [[ $DISKNO -gt ${#bdevs[@]} ]] || [[ ! $DISKNO =~ ^[0-9]+$ ]]; then
9f95a23c
TL
113 error "Required device number ($DISKNO) is not a valid number or it's larger than the number of devices found (${#bdevs[@]})"
114fi
115
f67539c2
TL
116$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
117$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
9f95a23c 118
f67539c2
TL
119for ((i = 0; i < DISKNO; i++)); do
120 $rpc_py iscsi_create_target_node Target${i} Target${i}_alias "${bdevs[i]}:0" "$PORTAL_TAG:$INITIATOR_TAG" 64 -d
9f95a23c
TL
121done
122
f67539c2 123ssh_initiator "cat > perf.job" < $testdir/perf.job
9f95a23c
TL
124rm -f $testdir/perf.job
125timing_exit iscsi_config
126
127timing_enter iscsi_initiator
f67539c2 128ssh_initiator bash -s - $FIO_PATH $TARGET_IP < $testdir/iscsi_initiator.sh
9f95a23c
TL
129timing_exit iscsi_initiator
130
131ssh_initiator "cat perf_output/iscsi_fio.json" > $iscsi_fio_results
132ssh_initiator "rm -rf perf_output perf.job"
133
134killprocess $pid