1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../../..) 5source $rootdir/test/common/autotest_common.sh 6source $rootdir/test/iscsi_tgt/common.sh 7 8iscsitestinit 9 10delete_tmp_files() { 11 rm -f $testdir/iscsi2.json 12 rm -f ./local-job0-0-verify.state 13 rm -f ./local-job1-1-verify.state 14} 15 16function running_config() { 17 # dump a config file from the running iscsi_tgt 18 $rpc_py save_config > $testdir/iscsi2.json 19 sleep 1 20 21 # now start iscsi_tgt again using the generated config file 22 # keep the same iscsiadm configuration to confirm that the 23 # config file matched the running configuration 24 killprocess $pid 25 trap 'iscsicleanup; delete_tmp_files; exit 1' SIGINT SIGTERM EXIT 26 27 timing_enter start_iscsi_tgt2 28 29 "${ISCSI_APP[@]}" --wait-for-rpc & 30 pid=$! 31 echo "Process pid: $pid" 32 trap 'iscsicleanup; killprocess $pid; delete_tmp_files; exit 1' SIGINT SIGTERM EXIT 33 waitforlisten $pid 34 35 $rpc_py load_config < $testdir/iscsi2.json 36 37 echo "iscsi_tgt is listening. Running tests..." 38 39 timing_exit start_iscsi_tgt2 40 41 sleep 1 42 $fio_py -p iscsi -i 4096 -d 1 -t randrw -r 5 43} 44 45if [ -z "$TARGET_IP" ]; then 46 echo "TARGET_IP not defined in environment" 47 exit 1 48fi 49 50if [ -z "$INITIATOR_IP" ]; then 51 echo "INITIATOR_IP not defined in environment" 52 exit 1 53fi 54 55MALLOC_BDEV_SIZE=64 56MALLOC_BLOCK_SIZE=4096 57 58rpc_py="$rootdir/scripts/rpc.py" 59fio_py="$rootdir/scripts/fio.py" 60 61timing_enter start_iscsi_tgt 62 63"${ISCSI_APP[@]}" --wait-for-rpc & 64pid=$! 65echo "Process pid: $pid" 66 67trap 'killprocess $pid; exit 1' SIGINT SIGTERM EXIT 68 69waitforlisten $pid 70 71$rpc_py load_config < $testdir/iscsi.json 72 73echo "iscsi_tgt is listening. Running tests..." 74 75timing_exit start_iscsi_tgt 76 77$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT 78$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK 79# Create a RAID-0 bdev from two malloc bdevs 80malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) " 81malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" 82$rpc_py bdev_raid_create -n raid0 -z 64 -r 0 -b "$malloc_bdevs" 83bdev=$($rpc_py bdev_malloc_create 1024 512) 84# "raid0:0" ==> use raid0 blockdev for LUN0 85# "1:2" ==> map PortalGroup1 to InitiatorGroup2 86# "64" ==> iSCSI queue depth 64 87# "-d" ==> disable CHAP authentication 88$rpc_py iscsi_create_target_node Target3 Target3_alias "raid0:0 ${bdev}:1" $PORTAL_TAG:$INITIATOR_TAG 64 -d 89sleep 1 90 91iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT 92iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT 93waitforiscsidevices 2 94 95trap 'iscsicleanup; killprocess $pid; iscsitestfini; delete_tmp_files; exit 1' SIGINT SIGTERM EXIT 96 97$fio_py -p iscsi -i 4096 -d 1 -t randrw -r 1 -v 98$fio_py -p iscsi -i 131072 -d 32 -t randrw -r 1 -v 99$fio_py -p iscsi -i 524288 -d 128 -t randrw -r 1 -v 100$fio_py -p iscsi -i 1048576 -d 1024 -t read -r 1 -n 4 101 102if [ $RUN_NIGHTLY -eq 1 ]; then 103 $fio_py -p iscsi -i 4096 -d 1 -t write -r 300 -v 104 105 # Run the running_config test which will generate a config file from the 106 # running iSCSI target, then kill and restart the iSCSI target using the 107 # generated config file 108 # Temporarily disabled 109 # running_config 110fi 111 112# Start hotplug test case. 113$fio_py -p iscsi -i 1048576 -d 128 -t rw -r 10 & 114fio_pid=$! 115 116sleep 3 117 118# Delete raid0 blockdev 119$rpc_py bdev_raid_delete 'raid0' 120 121# Delete all allocated malloc blockdevs 122for malloc_bdev in $malloc_bdevs; do 123 $rpc_py bdev_malloc_delete $malloc_bdev 124done 125 126# Delete malloc device 127$rpc_py bdev_malloc_delete ${bdev} 128 129fio_status=0 130wait $fio_pid || fio_status=$? 131 132if [ $fio_status -eq 0 ]; then 133 echo "iscsi hotplug test: fio successful - expected failure" 134 exit 1 135else 136 echo "iscsi hotplug test: fio failed as expected" 137fi 138 139iscsicleanup 140$rpc_py iscsi_delete_target_node 'iqn.2016-06.io.spdk:Target3' 141 142delete_tmp_files 143 144trap - SIGINT SIGTERM EXIT 145 146killprocess $pid 147 148iscsitestfini 149