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
|
|
|
|
2019-05-06 22:46:30 +00:00
|
|
|
# $1 = "iso" - triggers isolation mode (setting up required environment).
|
|
|
|
# $2 = test type posix or vpp. defaults to posix.
|
|
|
|
iscsitestinit $1 $2
|
|
|
|
|
2018-07-15 03:33:08 +00:00
|
|
|
delete_tmp_files() {
|
2018-11-15 10:23:13 +00:00
|
|
|
rm -f $testdir/iscsi2.json
|
2018-07-15 03:33:08 +00:00
|
|
|
rm -f ./local-job0-0-verify.state
|
|
|
|
}
|
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
function running_config() {
|
2018-11-15 10:23:13 +00:00
|
|
|
# dump a config file from the running iscsi_tgt
|
|
|
|
$rpc_py save_config > $testdir/iscsi2.json
|
2016-08-03 21:37:16 +00:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# now start iscsi_tgt again using the generated config file
|
|
|
|
# keep the same iscsiadm configuration to confirm that the
|
|
|
|
# config file matched the running configuration
|
|
|
|
killprocess $pid
|
2018-07-15 03:33:08 +00:00
|
|
|
trap "iscsicleanup; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT
|
2017-05-25 20:06:51 +00:00
|
|
|
|
|
|
|
timing_enter start_iscsi_tgt2
|
|
|
|
|
2018-11-15 10:23:13 +00:00
|
|
|
$ISCSI_APP --wait-for-rpc &
|
2016-08-03 21:37:16 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
2018-07-15 03:33:08 +00:00
|
|
|
trap "iscsicleanup; killprocess $pid; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT
|
2017-11-09 23:33:29 +00:00
|
|
|
waitforlisten $pid
|
2018-11-15 10:23:13 +00:00
|
|
|
|
|
|
|
$rpc_py load_config < $testdir/iscsi2.json
|
|
|
|
|
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_tgt2
|
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
sleep 1
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 4096 -d 1 -t randrw -r 5
|
2016-08-03 21:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$TARGET_IP" ]; then
|
|
|
|
echo "TARGET_IP not defined in environment"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$INITIATOR_IP" ]; then
|
|
|
|
echo "INITIATOR_IP not defined in environment"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
timing_enter fio
|
|
|
|
|
2016-10-17 08:30:26 +00:00
|
|
|
MALLOC_BDEV_SIZE=64
|
2016-08-03 21:37:16 +00:00
|
|
|
MALLOC_BLOCK_SIZE=4096
|
|
|
|
|
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
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
2018-11-15 01:25:43 +00:00
|
|
|
$ISCSI_APP --wait-for-rpc &
|
2016-08-03 21:37:16 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
|
|
|
|
2018-11-15 01:25:43 +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
|
2018-11-15 01:25:43 +00:00
|
|
|
|
|
|
|
$rpc_py load_config < $testdir/iscsi.json
|
|
|
|
|
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
|
|
|
|
|
2018-03-27 13:56:16 +00:00
|
|
|
$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
|
2016-08-03 21:37:16 +00:00
|
|
|
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
|
2018-08-22 05:44:46 +00:00
|
|
|
# Create a RAID-0 bdev from two malloc bdevs
|
|
|
|
malloc_bdevs="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) "
|
|
|
|
malloc_bdevs+="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
|
|
|
|
$rpc_py construct_raid_bdev -n raid0 -s 64 -r 0 -b "$malloc_bdevs"
|
|
|
|
# "raid0:0" ==> use raid0 blockdev for LUN0
|
2016-08-03 21:37:16 +00:00
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
|
|
|
# "64" ==> iSCSI queue depth 64
|
2018-03-12 04:41:21 +00:00
|
|
|
# "-d" ==> disable CHAP authentication
|
2018-08-22 05:44:46 +00:00
|
|
|
$rpc_py construct_target_node Target3 Target3_alias 'raid0: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
|
|
|
|
2019-05-06 22:46:30 +00:00
|
|
|
trap "iscsicleanup; killprocess $pid; iscsitestfini $1 $2; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 4096 -d 1 -t randrw -r 1 -v
|
|
|
|
$fio_py -p iscsi -i 131072 -d 32 -t randrw -r 1 -v
|
|
|
|
$fio_py -p iscsi -i 524288 -d 128 -t randrw -r 1 -v
|
2016-08-03 21:37:16 +00:00
|
|
|
|
|
|
|
if [ $RUN_NIGHTLY -eq 1 ]; then
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 4096 -d 1 -t write -r 300 -v
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2016-08-04 22:06:00 +00:00
|
|
|
# Run the running_config test which will generate a config file from the
|
|
|
|
# running iSCSI target, then kill and restart the iSCSI target using the
|
|
|
|
# generated config file
|
2018-09-20 09:44:33 +00:00
|
|
|
# Temporarily disabled
|
|
|
|
# running_config
|
2016-08-03 21:37:16 +00:00
|
|
|
fi
|
|
|
|
|
2018-07-04 05:30:01 +00:00
|
|
|
# Start hotplug test case.
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 1048576 -d 128 -t rw -r 10 &
|
2018-07-04 05:30:01 +00:00
|
|
|
fio_pid=$!
|
|
|
|
|
|
|
|
sleep 3
|
2019-06-10 09:52:24 +00:00
|
|
|
|
2019-06-14 15:41:40 +00:00
|
|
|
# Delete raid0 blockdev
|
2018-08-22 05:44:46 +00:00
|
|
|
$rpc_py destroy_raid_bdev 'raid0'
|
2019-06-14 15:41:40 +00:00
|
|
|
|
|
|
|
# Delete all allocated malloc blockdevs
|
|
|
|
for malloc_bdev in $malloc_bdevs; do
|
|
|
|
$rpc_py delete_malloc_bdev $malloc_bdev
|
|
|
|
done
|
2018-07-04 05:30:01 +00:00
|
|
|
|
2019-06-10 09:52:24 +00:00
|
|
|
fio_status=0
|
|
|
|
wait $fio_pid || fio_status=$?
|
|
|
|
|
2018-07-04 05:30:01 +00:00
|
|
|
|
|
|
|
if [ $fio_status -eq 0 ]; then
|
|
|
|
echo "iscsi hotplug test: fio successful - expected failure"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "iscsi hotplug test: fio failed as expected"
|
|
|
|
fi
|
|
|
|
|
2017-07-30 13:27:02 +00:00
|
|
|
iscsicleanup
|
|
|
|
$rpc_py delete_target_node 'iqn.2016-06.io.spdk:Target3'
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2018-07-15 03:33:08 +00:00
|
|
|
delete_tmp_files
|
|
|
|
|
2017-07-30 13:27:02 +00:00
|
|
|
trap - SIGINT SIGTERM EXIT
|
2018-07-15 03:33:08 +00:00
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
killprocess $pid
|
2017-07-30 13:27:02 +00:00
|
|
|
|
2019-05-06 22:46:30 +00:00
|
|
|
iscsitestfini $1 $2
|
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
timing_exit fio
|