diff --git a/autotest.sh b/autotest.sh index a8b51da21..4c0ced335 100755 --- a/autotest.sh +++ b/autotest.sh @@ -98,6 +98,7 @@ if [ $(uname -s) = Linux ]; then time ./test/iscsi_tgt/reset/reset.sh time ./test/iscsi_tgt/rpc_config/rpc_config.sh time ./test/iscsi_tgt/idle_migration/idle_migration.sh + time ./test/iscsi_tgt/ext4test/ext4test.sh timing_exit iscsi_tgt fi diff --git a/test/iscsi_tgt/ext4test/ext4test.sh b/test/iscsi_tgt/ext4test/ext4test.sh new file mode 100755 index 000000000..abfcb8ed4 --- /dev/null +++ b/test/iscsi_tgt/ext4test/ext4test.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$testdir/../../.. +source $rootdir/scripts/autotest_common.sh + +if [ ! -z $1 ]; then + DPDK_DIR=$(readlink -f $1) +fi + +if [ -z "$TARGET_IP" ]; then + TARGET_IP=127.0.0.1 + echo "TARGET_IP not defined - using 127.0.0.1" +fi + +if [ -z "$INITIATOR_IP" ]; then + INITIATOR_IP=127.0.0.1 + echo "INITIATOR_IP not defined - using 127.0.0.1" +fi + +timing_enter ext4test + +# iSCSI target configuration +PORT=3260 +RPC_PORT=5260 +INITIATOR_TAG=2 +INITIATOR_NAME=ALL +NETMASK=$INITIATOR_IP/32 + +rpc_py="python $rootdir/scripts/rpc.py" + +./app/iscsi_tgt/iscsi_tgt -c $testdir/iscsi.conf & +pid=$! +echo "Process pid: $pid" + +trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT + +waitforlisten $pid ${RPC_PORT} +echo "iscsi_tgt is listening. Running tests..." + +$rpc_py add_portal_group 1 $TARGET_IP:$PORT +$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK +# "1:2" ==> map PortalGroup1 to InitiatorGroup2 +# "64" ==> iSCSI queue depth 64 +# "1 0 0 0" ==> disable CHAP authentication +$rpc_py construct_target_node Target0 Target0_alias Nvme0n1p0:0 1:2 64 1 0 0 0 +$rpc_py construct_target_node Target1 Target1_alias Malloc0:0 1:2 64 1 0 0 0 + +sleep 1 + +iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT +iscsiadm -m node --login -p $TARGET_IP:$PORT + +trap 'for new_dir in `dir -d /mnt/*dir`; do umount $new_dir; rm -rf $new_dir; done; \ + iscsicleanup; killprocess $pid; exit 1' SIGINT SIGTERM EXIT + +sleep 1 + + +devs=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}') + +for dev in $devs; do + mkfs.ext4 -F /dev/$dev + mkdir -p /mnt/${dev}dir + mount /dev/$dev /mnt/${dev}dir + + rsync -qav --exclude=".git" $rootdir/ /mnt/${dev}dir/spdk + cd /mnt/${dev}dir/spdk + + make DPDK_DIR=$DPDK_DIR clean + make DPDK_DIR=$DPDK_DIR -j16 + + # Print out space consumed on target device to help decide + # if/when we need to increase the size of the malloc LUN + df -h /dev/$dev + + rm -rf /mnt/${dev}dir/spdk + cd - +done + +for dev in $devs; do + umount /mnt/${dev}dir + rm -rf /mnt/${dev}dir +done + +trap - SIGINT SIGTERM EXIT + +iscsicleanup +killprocess $pid +timing_exit ext4test diff --git a/test/iscsi_tgt/ext4test/iscsi.conf b/test/iscsi_tgt/ext4test/iscsi.conf new file mode 100644 index 000000000..027a8d2c5 --- /dev/null +++ b/test/iscsi_tgt/ext4test/iscsi.conf @@ -0,0 +1,53 @@ +# iSCSI target configuration file +# +# Please write all parameters using ASCII. +# The parameter must be quoted if it includes whitespace. +# +# Configuration syntax: +# Spaces at head of line are deleted, other spaces are as separator +# Lines starting with '#' are comments and not evaluated. +# Lines ending with '\' are concatenated with the next line. +# Bracketed keys are section keys grouping the following value keys. +# Number of section key is used as a tag number. +# Ex. [TargetNode1] = TargetNode section key with tag number 1 +[Global] + Comment "Global section" + + # syslog facility + LogFacility "local7" + +[iSCSI] + # node name (not include optional part) + # Users can optionally change this to fit their environment. + NodeBase "iqn.2013-06.com.intel.ch.spdk" + + AuthFile /usr/local/etc/spdk/auth.conf + + # socket I/O timeout sec. (polling is infinity) + Timeout 30 + + # authentication information for discovery session + DiscoveryAuthMethod Auto + #DiscoveryAuthGroup AuthGroup9999 + + MaxSessions 4 + #MaxConnectionsPerSession 2 + + + ImmediateData Yes + ErrorRecoveryLevel 0 + +[Rpc] + Enable Yes + +# Do not specify InitiatorGroup, PortalGroup, Malloc, +# or TargetNode entries here - the autotest.sh script +# will use RPC to set up this part of the configuration. +[Nvme] + NumControllers 1 + NvmeLunsPerNs 1 + LunSizeInMB 4096 + +[Malloc] + NumberOfLuns 1 + LunSizeInMB 512