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
|
2018-03-08 09:39:05 +00:00
|
|
|
source $rootdir/scripts/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-09-11 13:26:14 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py"
|
2018-03-08 09:39:05 +00:00
|
|
|
# Remove lvol bdevs and stores.
|
2018-04-18 08:36:46 +00:00
|
|
|
function remove_backends() {
|
2018-03-08 09:39:05 +00:00
|
|
|
echo "INFO: Removing lvol bdev"
|
2019-08-29 10:33:16 +00:00
|
|
|
$rpc_py bdev_lvol_delete "lvs_0/lbd_0"
|
2018-03-08 09:39:05 +00:00
|
|
|
|
|
|
|
echo "INFO: Removing lvol stores"
|
2019-08-29 12:07:56 +00:00
|
|
|
$rpc_py bdev_lvol_delete_lvstore -l lvs_0
|
2018-07-26 12:54:20 +00:00
|
|
|
|
|
|
|
echo "INFO: Removing NVMe"
|
2019-08-23 15:12:13 +00:00
|
|
|
$rpc_py bdev_nvme_detach_controller Nvme0
|
2018-07-26 12:54:20 +00:00
|
|
|
|
2018-03-08 09:39:05 +00:00
|
|
|
return 0
|
|
|
|
}
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
2018-08-10 10:20:25 +00:00
|
|
|
$ISCSI_APP -m $ISCSI_TEST_CORE_MASK --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; iscsitestfini $1 $2; 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
|
|
|
|
|
2018-04-18 08:36:46 +00:00
|
|
|
bdf=$(iter_pci_class_code 01 08 02 | head -1)
|
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-23 13:50:51 +00:00
|
|
|
$rpc_py bdev_nvme_attach_controller -b "Nvme0" -t "pcie" -a $bdf
|
2018-03-08 09:39:05 +00:00
|
|
|
|
2019-08-29 13:31:19 +00:00
|
|
|
ls_guid=$($rpc_py bdev_lvol_create_lvstore Nvme0n1 lvs_0)
|
2018-03-08 09:39:05 +00:00
|
|
|
free_mb=$(get_lvs_free_mb "$ls_guid")
|
|
|
|
# Using maximum 2048MiB to reduce the test time
|
|
|
|
if [ $free_mb -gt 2048 ]; then
|
2019-08-29 11:01:30 +00:00
|
|
|
$rpc_py bdev_lvol_create -u $ls_guid lbd_0 2048
|
2018-03-08 09:39:05 +00:00
|
|
|
else
|
2019-08-29 11:01:30 +00:00
|
|
|
$rpc_py bdev_lvol_create -u $ls_guid lbd_0 $free_mb
|
2018-03-08 09:39:05 +00:00
|
|
|
fi
|
|
|
|
# "lvs_0/lbd_0:0" ==> use lvs_0/lbd_0 blockdev for LUN0
|
2016-08-03 21:37:16 +00:00
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
2018-03-08 09:39:05 +00:00
|
|
|
# "256" ==> iSCSI queue depth 256
|
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 Target1 Target1_alias 'lvs_0/lbd_0:0' $PORTAL_TAG:$INITIATOR_TAG 256 -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-11-04 01:06:28 +00:00
|
|
|
trap 'iscsicleanup; remove_backends; umount /mnt/device; rm -rf /mnt/device; killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
|
2016-08-03 21:37:16 +00:00
|
|
|
|
2018-04-18 08:36:46 +00:00
|
|
|
mkdir -p /mnt/device
|
2016-08-03 21:37:16 +00:00
|
|
|
|
|
|
|
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
|
|
|
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforfile /dev/$dev
|
2016-08-03 21:37:16 +00:00
|
|
|
parted -s /dev/$dev mklabel msdos
|
|
|
|
parted -s /dev/$dev mkpart primary '0%' '100%'
|
|
|
|
sleep 1
|
|
|
|
|
2019-12-05 19:53:59 +00:00
|
|
|
function filesystem_test {
|
|
|
|
fstype=$1
|
2016-08-03 21:37:16 +00:00
|
|
|
|
|
|
|
if [ "$fstype" == "ext4" ]; then
|
|
|
|
mkfs.${fstype} -F /dev/${dev}1
|
|
|
|
else
|
|
|
|
mkfs.${fstype} -f /dev/${dev}1
|
|
|
|
fi
|
|
|
|
mount /dev/${dev}1 /mnt/device
|
2018-03-28 02:21:48 +00:00
|
|
|
if [ $RUN_NIGHTLY -eq 1 ]; then
|
|
|
|
fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randwrite -ioengine=libaio -bs=4k \
|
2018-04-18 08:36:46 +00:00
|
|
|
-size=1024M -name=job0
|
2018-03-28 02:21:48 +00:00
|
|
|
umount /mnt/device
|
|
|
|
|
|
|
|
iscsiadm -m node --logout
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 0
|
2018-03-28 02:21:48 +00:00
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 1
|
|
|
|
|
2018-03-28 02:21:48 +00:00
|
|
|
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
2019-06-17 07:23:20 +00:00
|
|
|
|
|
|
|
waitforfile /dev/${dev}1
|
2018-03-28 02:21:48 +00:00
|
|
|
mount -o rw /dev/${dev}1 /mnt/device
|
|
|
|
if [ -f "/mnt/device/test" ]; then
|
|
|
|
echo "File existed."
|
|
|
|
fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randread \
|
2018-04-18 08:36:46 +00:00
|
|
|
-ioengine=libaio -bs=4k -runtime=20 -time_based=1 -name=job0
|
2018-03-28 02:21:48 +00:00
|
|
|
else
|
|
|
|
echo "File doesn't exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf /mnt/device/test
|
|
|
|
umount /mnt/device
|
2016-08-03 21:37:16 +00:00
|
|
|
else
|
2018-03-28 02:21:48 +00:00
|
|
|
touch /mnt/device/aaa
|
|
|
|
umount /mnt/device
|
|
|
|
|
|
|
|
iscsiadm -m node --logout
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 0
|
2018-03-28 02:21:48 +00:00
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 1
|
|
|
|
|
2018-03-28 02:21:48 +00:00
|
|
|
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
2019-06-17 07:23:20 +00:00
|
|
|
|
|
|
|
waitforfile /dev/${dev}1
|
2018-03-28 02:21:48 +00:00
|
|
|
mount -o rw /dev/${dev}1 /mnt/device
|
|
|
|
|
|
|
|
if [ -f "/mnt/device/aaa" ]; then
|
|
|
|
echo "File existed."
|
|
|
|
else
|
|
|
|
echo "File doesn't exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf /mnt/device/aaa
|
|
|
|
umount /mnt/device
|
2016-08-03 21:37:16 +00:00
|
|
|
fi
|
2019-12-05 19:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run_test "iscsi_tgt_filesystem_ext4" filesystem_test "ext4"
|
|
|
|
run_test "iscsi_tgt_filesystem_btrfs" filesystem_test "btrfs"
|
|
|
|
run_test "iscsi_tgt_filesystem_xfs" filesystem_test "xfs"
|
2016-08-03 21:37:16 +00:00
|
|
|
|
|
|
|
rm -rf /mnt/device
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
iscsicleanup
|
2018-06-21 07:31:51 +00:00
|
|
|
remove_backends
|
2016-08-03 21:37:16 +00:00
|
|
|
killprocess $pid
|
2019-05-06 22:46:30 +00:00
|
|
|
iscsitestfini $1 $2
|