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
|
|
|
|
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
|
2019-05-09 18:05:58 +00:00
|
|
|
rm -f ./local-job1-1-verify.state
|
2018-07-15 03:33:08 +00:00
|
|
|
}
|
|
|
|
|
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
|
2019-08-09 08:46:01 +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
|
|
|
|
|
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 '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
|
|
|
|
|
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
|
|
|
|
|
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
|
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
|
|
|
|
|
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
|
2018-08-22 05:44:46 +00:00
|
|
|
# Create a RAID-0 bdev from two malloc bdevs
|
2019-08-09 11:15:35 +00:00
|
|
|
malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) "
|
|
|
|
malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
|
2019-09-10 08:41:05 +00:00
|
|
|
$rpc_py bdev_raid_create -n raid0 -z 64 -r 0 -b "$malloc_bdevs"
|
2020-05-07 11:27:06 +00:00
|
|
|
bdev=$($rpc_py bdev_malloc_create 1024 512)
|
2018-08-22 05:44:46 +00:00
|
|
|
# "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
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py iscsi_create_target_node Target3 Target3_alias "raid0:0 ${bdev}:1" $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-05-09 18:05:58 +00:00
|
|
|
waitforiscsidevices 2
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2020-08-11 10:36:11 +00:00
|
|
|
trap 'iscsicleanup; killprocess $pid; iscsitestfini; 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
|
2019-05-09 18:05:58 +00:00
|
|
|
$fio_py -p iscsi -i 1048576 -d 1024 -t read -r 1 -n 4
|
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
|
2019-09-10 09:08:35 +00:00
|
|
|
$rpc_py bdev_raid_delete 'raid0'
|
2019-06-14 15:41:40 +00:00
|
|
|
|
|
|
|
# Delete all allocated malloc blockdevs
|
|
|
|
for malloc_bdev in $malloc_bdevs; do
|
2019-08-19 08:19:29 +00:00
|
|
|
$rpc_py bdev_malloc_delete $malloc_bdev
|
2019-06-14 15:41:40 +00:00
|
|
|
done
|
2018-07-04 05:30:01 +00:00
|
|
|
|
2019-07-15 17:36:57 +00:00
|
|
|
# Delete malloc device
|
2019-08-19 08:19:29 +00:00
|
|
|
$rpc_py bdev_malloc_delete ${bdev}
|
2019-05-09 18:05:58 +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
|
2019-09-05 10:52:14 +00:00
|
|
|
$rpc_py iscsi_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
|
|
|
|
2020-08-11 10:36:11 +00:00
|
|
|
iscsitestfini
|