2016-08-03 21:37:16 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2017-04-04 23:20:16 +00:00
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
2018-02-27 22:14:08 +00:00
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2017-05-24 23:29:24 +00:00
|
|
|
source $rootdir/test/iscsi_tgt/common.sh
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2020-08-11 10:36:11 +00:00
|
|
|
iscsitestinit
|
2019-05-06 22:46:30 +00:00
|
|
|
|
2016-10-17 08:30:26 +00:00
|
|
|
MALLOC_BDEV_SIZE=64
|
2016-08-03 21:37:16 +00:00
|
|
|
MALLOC_BLOCK_SIZE=512
|
|
|
|
|
2018-09-11 13:26:14 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py"
|
|
|
|
fio_py="$rootdir/scripts/fio.py"
|
2016-08-03 21:37:16 +00:00
|
|
|
|
|
|
|
if ! hash sg_reset; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
2020-02-20 10:24:53 +00:00
|
|
|
"${ISCSI_APP[@]}" --wait-for-rpc &
|
2016-08-03 21:37:16 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
|
|
|
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'killprocess $pid; exit 1' SIGINT SIGTERM EXIT
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2017-11-09 23:33:29 +00:00
|
|
|
waitforlisten $pid
|
2019-09-11 11:15:34 +00:00
|
|
|
$rpc_py iscsi_set_options -o 30 -a 16
|
2019-09-11 13:30:14 +00:00
|
|
|
$rpc_py framework_start_init
|
2016-08-03 21:37:16 +00:00
|
|
|
echo "iscsi_tgt is listening. Running tests..."
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_exit start_iscsi_tgt
|
|
|
|
|
2019-09-09 10:35:30 +00:00
|
|
|
$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
|
2019-09-03 08:53:37 +00:00
|
|
|
$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
|
2019-08-09 11:15:35 +00:00
|
|
|
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE
|
2016-08-03 21:37:16 +00:00
|
|
|
# "Malloc0:0" ==> use Malloc0 blockdev for LUN0
|
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
|
|
|
# "64" ==> iSCSI queue depth 64
|
2018-03-12 04:41:21 +00:00
|
|
|
# "-d" ==> disable CHAP authentication
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py iscsi_create_target_node Target3 Target3_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d
|
2016-08-03 21:37:16 +00:00
|
|
|
sleep 1
|
|
|
|
|
2018-03-27 13:39:38 +00:00
|
|
|
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
|
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 1
|
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
|
|
|
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 512 -d 1 -t read -r 60 &
|
2016-08-03 21:37:16 +00:00
|
|
|
fiopid=$!
|
|
|
|
echo "FIO pid: $fiopid"
|
|
|
|
|
2020-08-11 10:36:11 +00:00
|
|
|
trap 'iscsicleanup; killprocess $pid; killprocess $fiopid; iscsitestfini; exit 1' SIGINT SIGTERM EXIT
|
2016-08-03 21:37:16 +00:00
|
|
|
|
|
|
|
# Do 3 resets while making sure iscsi_tgt and fio are still running
|
|
|
|
for i in 1 2 3; do
|
2017-03-29 21:15:47 +00:00
|
|
|
sleep 1
|
2016-08-03 21:37:16 +00:00
|
|
|
kill -s 0 $pid
|
|
|
|
kill -s 0 $fiopid
|
|
|
|
sg_reset -d /dev/$dev
|
2017-03-29 21:15:47 +00:00
|
|
|
sleep 1
|
2016-08-03 21:37:16 +00:00
|
|
|
kill -s 0 $pid
|
|
|
|
kill -s 0 $fiopid
|
|
|
|
done
|
|
|
|
|
|
|
|
kill $fiopid
|
|
|
|
wait $fiopid || true
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
iscsicleanup
|
|
|
|
killprocess $pid
|
2020-08-11 10:36:11 +00:00
|
|
|
iscsitestfini
|