]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/iscsi_tgt/lvol/iscsi_lvol.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / test / iscsi_tgt / lvol / iscsi_lvol.sh
1 #!/usr/bin/env bash
2
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 # $1 = "iso" - triggers isolation mode (setting up required environment).
9 # $2 = test type posix or vpp. defaults to posix.
10 iscsitestinit $1 $2
11
12 timing_enter iscsi_lvol
13
14 MALLOC_BDEV_SIZE=128
15 MALLOC_BLOCK_SIZE=512
16 if [ $RUN_NIGHTLY -eq 1 ]; then
17 NUM_LVS=10
18 NUM_LVOL=10
19 else
20 NUM_LVS=2
21 NUM_LVOL=2
22 fi
23
24 rpc_py="$rootdir/scripts/rpc.py"
25 fio_py="$rootdir/scripts/fio.py"
26
27 timing_enter start_iscsi_tgt
28
29 $ISCSI_APP -m $ISCSI_TEST_CORE_MASK --wait-for-rpc &
30 pid=$!
31 echo "Process pid: $pid"
32
33 trap "iscsicleanup; killprocess $pid; iscsitestfini $1 $2; exit 1" SIGINT SIGTERM EXIT
34
35 waitforlisten $pid
36 $rpc_py set_iscsi_options -o 30 -a 16
37 $rpc_py start_subsystem_init
38 echo "iscsi_tgt is listening. Running tests..."
39
40 timing_exit start_iscsi_tgt
41
42 timing_enter setup
43 $rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
44 # Create the first LVS from a Raid-0 bdev, which is created from two malloc bdevs
45 # Create remaining LVSs from a malloc bdev, respectively
46 for i in $(seq 1 $NUM_LVS); do
47 INITIATOR_TAG=$((i + 2))
48 $rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
49 if [ $i -eq 1 ]; then
50 # construct RAID bdev and put its name in $bdev
51 malloc_bdevs="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) "
52 malloc_bdevs+="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
53 $rpc_py construct_raid_bdev -n raid0 -s 64 -r 0 -b "$malloc_bdevs"
54 bdev="raid0"
55 else
56 # construct malloc bdev and put its name in $bdev
57 bdev=$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)
58 fi
59 ls_guid=$($rpc_py construct_lvol_store $bdev lvs_$i -c 1048576)
60 LUNs=""
61 for j in $(seq 1 $NUM_LVOL); do
62 lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_$j 10)
63 LUNs+="$lb_name:$((j - 1)) "
64 done
65 $rpc_py construct_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 -d
66 done
67 timing_exit setup
68
69 sleep 1
70
71 timing_enter discovery
72 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
73 iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
74 timing_exit discovery
75
76 timing_enter fio
77 $fio_py -p iscsi -i 131072 -d 8 -t randwrite -r 10 -v
78 timing_exit fio
79
80 rm -f ./local-job0-0-verify.state
81 trap - SIGINT SIGTERM EXIT
82
83 rm -f ./local-job*
84 iscsicleanup
85 killprocess $pid
86 iscsitestfini $1 $2
87 timing_exit iscsi_lvol