xref: /spdk/test/iscsi_tgt/lvol/iscsi_lvol.sh (revision c680e3a05b1a903c18bf3f75b732765607126f45)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2017 Intel Corporation
4#  All rights reserved.
5#
6testdir=$(readlink -f $(dirname $0))
7rootdir=$(readlink -f $testdir/../../..)
8source $rootdir/test/common/autotest_common.sh
9source $rootdir/test/iscsi_tgt/common.sh
10
11iscsitestinit
12
13MALLOC_BDEV_SIZE=128
14MALLOC_BLOCK_SIZE=512
15if [ $RUN_NIGHTLY -eq 1 ]; then
16	NUM_LVS=10
17	NUM_LVOL=10
18else
19	NUM_LVS=2
20	NUM_LVOL=2
21fi
22
23rpc_py="$rootdir/scripts/rpc.py"
24fio_py="$rootdir/scripts/fio-wrapper"
25
26timing_enter start_iscsi_tgt
27
28"${ISCSI_APP[@]}" -m $ISCSI_TEST_CORE_MASK --wait-for-rpc &
29pid=$!
30echo "Process pid: $pid"
31
32trap 'iscsicleanup; killprocess $pid; iscsitestfini; exit 1' SIGINT SIGTERM EXIT
33
34waitforlisten $pid
35$rpc_py iscsi_set_options -o 30 -a 16
36$rpc_py framework_start_init
37echo "iscsi_tgt is listening. Running tests..."
38
39timing_exit start_iscsi_tgt
40
41timing_enter setup
42$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
43# Create the first LVS from a Raid-0 bdev, which is created from two malloc bdevs
44# Create remaining LVSs from a malloc bdev, respectively
45for i in $(seq 1 $NUM_LVS); do
46	INITIATOR_TAG=$((i + 2))
47	$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
48	if [ $i -eq 1 ]; then
49		# construct RAID bdev and put its name in $bdev
50		malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) "
51		malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
52		$rpc_py bdev_raid_create -n raid0 -z 64 -r 0 -b "$malloc_bdevs"
53		bdev="raid0"
54	else
55		# construct malloc bdev and put its name in $bdev
56		bdev=$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)
57	fi
58	ls_guid=$($rpc_py bdev_lvol_create_lvstore $bdev lvs_$i -c 1048576)
59	LUNs=""
60	for j in $(seq 1 $NUM_LVOL); do
61		lb_name=$($rpc_py bdev_lvol_create -u $ls_guid lbd_$j 10)
62		LUNs+="$lb_name:$((j - 1)) "
63	done
64	$rpc_py iscsi_create_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 -d
65done
66timing_exit setup
67
68sleep 1
69
70timing_enter discovery
71iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
72iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
73waitforiscsidevices $((NUM_LVS * NUM_LVOL))
74timing_exit discovery
75
76timing_enter fio
77$fio_py -p iscsi -i 131072 -d 8 -t randwrite -r 10 -v
78timing_exit fio
79
80rm -f ./local-job0-0-verify.state
81trap - SIGINT SIGTERM EXIT
82
83rm -f ./local-job*
84iscsicleanup
85killprocess $pid
86iscsitestfini
87