]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | #!/usr/bin/env bash |
2 | ||
f67539c2 TL |
3 | testdir=$(readlink -f $(dirname $0)) |
4 | rootdir=$(readlink -f $testdir/../../..) | |
5 | source $rootdir/test/common/autotest_common.sh | |
6 | source $rootdir/test/iscsi_tgt/common.sh | |
7 | ||
8 | rpc_py="$rootdir/scripts/rpc.py -s $testdir/rpc_iscsi.sock" | |
9f95a23c TL |
9 | |
10 | BLK_SIZE=4096 | |
11 | RW=randrw | |
12 | MIX=100 | |
13 | IODEPTH=128 | |
14 | RUNTIME=60 | |
15 | RAMP_TIME=10 | |
f67539c2 | 16 | FIO_PATH=$CONFIG_FIO_SOURCE_DIR |
9f95a23c TL |
17 | DISKNO="ALL" |
18 | CPUMASK=0x02 | |
19 | NUM_JOBS=1 | |
20 | ISCSI_TGT_CM=0x02 | |
9f95a23c TL |
21 | |
22 | # Performance test for iscsi_tgt, run on devices with proper hardware support (target and inititator) | |
f67539c2 TL |
23 | function 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 | ||
38 | while 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 |
67 | done | |
68 | ||
9f95a23c TL |
69 | if [ -z "$TARGET_IP" ]; then |
70 | error "No IP address of iscsi target is given" | |
71 | fi | |
72 | ||
73 | if [ -z "$INITIATOR_IP" ]; then | |
74 | error "No IP address of iscsi initiator is given" | |
75 | fi | |
76 | ||
77 | if [ -z "$IP_I_SSH" ]; then | |
78 | error "No IP address of initiator is given" | |
79 | fi | |
80 | ||
81 | if [ $EUID -ne 0 ]; then | |
82 | error "INFO: This script must be run with root privileges" | |
83 | fi | |
84 | ||
f67539c2 TL |
85 | function 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 | ||
91 | NETMASK=$INITIATOR_IP/32 | |
9f95a23c TL |
92 | iscsi_fio_results="$testdir/perf_output/iscsi_fio.json" |
93 | rm -rf $iscsi_fio_results | |
94 | mkdir -p $testdir/perf_output | |
95 | touch $iscsi_fio_results | |
96 | ||
97 | timing_enter run_iscsi_app | |
f67539c2 | 98 | $SPDK_BIN_DIR/iscsi_tgt -m $ISCSI_TGT_CM -r $testdir/rpc_iscsi.sock --wait-for-rpc & |
9f95a23c | 99 | pid=$! |
f67539c2 | 100 | trap 'rm -f $testdir/perf.job; killprocess $pid; print_backtrace; exit 1' ERR SIGTERM SIGABRT |
9f95a23c | 101 | waitforlisten "$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 |
105 | sleep 1 | |
106 | timing_exit run_iscsi_app | |
107 | ||
108 | timing_enter iscsi_config | |
f67539c2 TL |
109 | bdevs=($($rpc_py bdev_get_bdevs | jq -r '.[].name')) |
110 | if [[ $DISKNO == "ALL" ]] || [[ $DISKNO == "all" ]]; then | |
9f95a23c | 111 | DISKNO=${#bdevs[@]} |
f67539c2 | 112 | elif [[ $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[@]})" |
114 | fi | |
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 |
119 | for ((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 |
121 | done |
122 | ||
f67539c2 | 123 | ssh_initiator "cat > perf.job" < $testdir/perf.job |
9f95a23c TL |
124 | rm -f $testdir/perf.job |
125 | timing_exit iscsi_config | |
126 | ||
127 | timing_enter iscsi_initiator | |
f67539c2 | 128 | ssh_initiator bash -s - $FIO_PATH $TARGET_IP < $testdir/iscsi_initiator.sh |
9f95a23c TL |
129 | timing_exit iscsi_initiator |
130 | ||
131 | ssh_initiator "cat perf_output/iscsi_fio.json" > $iscsi_fio_results | |
132 | ssh_initiator "rm -rf perf_output perf.job" | |
133 | ||
134 | killprocess $pid |