Autotest: revise coding-style of all script under the test/iscsi_tgt directory.

These changes were modified by the shfmt tool that supports Google's Style guide.

Change-Id: I27dd8ba91afc0043b3ce5f0eb6121a3c11789fab
Signed-off-by: chenlo2x <longx.o.chen@intel.com>
Reviewed-on: https://review.gerrithub.io/408147
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
chenlo2x 2018-04-18 16:36:46 +08:00 committed by Jim Harris
parent cf90380720
commit 62209642ce
10 changed files with 47 additions and 56 deletions

View File

@ -5,10 +5,8 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh source $rootdir/test/common/autotest_common.sh
source $rootdir/test/iscsi_tgt/common.sh source $rootdir/test/iscsi_tgt/common.sh
function node_login_fio_logout() function node_login_fio_logout() {
{ for arg in "$@"; do
for arg in "$@"
do
iscsiadm -m node -p $TARGET_IP:$ISCSI_PORT -o update -n node.conn[0].iscsi.$arg iscsiadm -m node -p $TARGET_IP:$ISCSI_PORT -o update -n node.conn[0].iscsi.$arg
done done
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
@ -19,8 +17,7 @@ function node_login_fio_logout()
sleep 1 sleep 1
} }
function iscsi_header_digest_test() function iscsi_header_digest_test() {
{
# Enable HeaderDigest to CRC32C # Enable HeaderDigest to CRC32C
timing_enter HeaderDigest_enabled timing_enter HeaderDigest_enabled
node_login_fio_logout "HeaderDigest -v CRC32C" node_login_fio_logout "HeaderDigest -v CRC32C"
@ -33,8 +30,7 @@ function iscsi_header_digest_test()
timing_exit preferred timing_exit preferred
} }
function iscsi_header_data_digest_test() function iscsi_header_data_digest_test() {
{
# Only enable HeaderDigest to CRC32C # Only enable HeaderDigest to CRC32C
timing_enter HeaderDigest_enabled timing_enter HeaderDigest_enabled
node_login_fio_logout "HeaderDigest -v CRC32C" "DataDigest -v None" node_login_fio_logout "HeaderDigest -v CRC32C" "DataDigest -v None"
@ -94,7 +90,7 @@ iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
# iscsiadm installed by some Fedora releases loses DataDigest parameter. # iscsiadm installed by some Fedora releases loses DataDigest parameter.
# Check and avoid setting DataDigest. # Check and avoid setting DataDigest.
DataDigestAbility=`iscsiadm -m node -p $TARGET_IP:$ISCSI_PORT | grep DataDigest || true` DataDigestAbility=$(iscsiadm -m node -p $TARGET_IP:$ISCSI_PORT | grep DataDigest || true)
if [ "$DataDigestAbility"x = x ]; then if [ "$DataDigestAbility"x = x ]; then
iscsi_header_digest_test iscsi_header_digest_test
else else

View File

@ -48,7 +48,7 @@ trap 'for new_dir in `dir -d /mnt/*dir`; do umount $new_dir; rm -rf $new_dir; do
sleep 1 sleep 1
echo "Test error injection" echo "Test error injection"
$rpc_py bdev_inject_error EE_Malloc0 'all' 'failure' -n 1000 $rpc_py bdev_inject_error EE_Malloc0 'all' 'failure' -n 1000
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}') dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
@ -101,15 +101,15 @@ for dev in $devs; do
umount /mnt/${dev}dir umount /mnt/${dev}dir
rm -rf /mnt/${dev}dir rm -rf /mnt/${dev}dir
stats=( $(cat /sys/block/$dev/stat) ) stats=($(cat /sys/block/$dev/stat))
echo "" echo ""
echo "$dev stats" echo "$dev stats"
printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]} ${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]}
printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]} ${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]}
printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \ printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \
${stats[8]} ${stats[9]} ${stats[10]} ${stats[8]} ${stats[9]} ${stats[10]}
echo "" echo ""
done done

View File

@ -10,8 +10,7 @@ timing_enter filesystem
rpc_py="python $rootdir/scripts/rpc.py" rpc_py="python $rootdir/scripts/rpc.py"
# Remove lvol bdevs and stores. # Remove lvol bdevs and stores.
function remove_backends() function remove_backends() {
{
echo "INFO: Removing lvol bdev" echo "INFO: Removing lvol bdev"
$rpc_py destroy_lvol_bdev "lvs_0/lbd_0" $rpc_py destroy_lvol_bdev "lvs_0/lbd_0"
@ -39,7 +38,7 @@ echo "iscsi_tgt is listening. Running tests..."
timing_exit start_iscsi_tgt timing_exit start_iscsi_tgt
bdf=`iter_pci_class_code 01 08 02 | head -1` bdf=$(iter_pci_class_code 01 08 02 | head -1)
$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT $rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK $rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
$rpc_py construct_nvme_bdev -b "Nvme0" -t "pcie" -a $bdf $rpc_py construct_nvme_bdev -b "Nvme0" -t "pcie" -a $bdf
@ -66,7 +65,7 @@ trap "remove_backends; umount /mnt/device; rm -rf /mnt/device; iscsicleanup; kil
sleep 1 sleep 1
mkdir -p /mnt/device mkdir -p /mnt/device
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}') dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
@ -84,7 +83,7 @@ for fstype in "ext4" "btrfs" "xfs"; do
mount /dev/${dev}1 /mnt/device mount /dev/${dev}1 /mnt/device
if [ $RUN_NIGHTLY -eq 1 ]; then 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 \ fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randwrite -ioengine=libaio -bs=4k \
-size=1024M -name=job0 -size=1024M -name=job0
umount /mnt/device umount /mnt/device
iscsiadm -m node --logout iscsiadm -m node --logout
@ -96,7 +95,7 @@ for fstype in "ext4" "btrfs" "xfs"; do
if [ -f "/mnt/device/test" ]; then if [ -f "/mnt/device/test" ]; then
echo "File existed." echo "File existed."
fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randread \ fio -filename=/mnt/device/test -direct=1 -iodepth 64 -thread=1 -invalidate=1 -rw=randread \
-ioengine=libaio -bs=4k -runtime=20 -time_based=1 -name=job0 -ioengine=libaio -bs=4k -runtime=20 -time_based=1 -name=job0
else else
echo "File doesn't exist." echo "File doesn't exist."
exit 1 exit 1

View File

@ -14,9 +14,9 @@ rm -f /tmp/iscsi.conf*
kill -USR1 "$pid" kill -USR1 "$pid"
if [ ! -f `ls /tmp/iscsi.conf.*` ]; then if [ ! -f $(ls /tmp/iscsi.conf.*) ]; then
echo "iscsi_tgt did not generate config file" echo "iscsi_tgt did not generate config file"
exit 1 exit 1
fi fi
mv `ls /tmp/iscsi.conf.*` /tmp/iscsi.conf mv $(ls /tmp/iscsi.conf.*) /tmp/iscsi.conf

View File

@ -15,8 +15,7 @@ NETMASK=127.0.0.0/24
MIGRATION_ADDRESS=127.0.0.2 MIGRATION_ADDRESS=127.0.0.2
function kill_all_iscsi_target() { function kill_all_iscsi_target() {
for ((i=0; i<2; i++)) for ((i = 0; i < 2; i++)); do
do
rpc_addr="/var/tmp/spdk${i}.sock" rpc_addr="/var/tmp/spdk${i}.sock"
$rpc_py -s $rpc_addr kill_instance SIGTERM $rpc_py -s $rpc_addr kill_instance SIGTERM
done done
@ -30,17 +29,15 @@ function rpc_config() {
} }
function rpc_add_target_node() { function rpc_add_target_node() {
$rpc_py -s $1 add_ip_address 1 $MIGRATION_ADDRESS $rpc_py -s $1 add_ip_address 1 $MIGRATION_ADDRESS
$rpc_py -s $1 add_portal_group $PORTAL_TAG $MIGRATION_ADDRESS:$ISCSI_PORT $rpc_py -s $1 add_portal_group $PORTAL_TAG $MIGRATION_ADDRESS:$ISCSI_PORT
$rpc_py -s $1 construct_target_node target1 target1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d $rpc_py -s $1 construct_target_node target1 target1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d
} }
timing_enter ip_migration timing_enter ip_migration
echo "Running ip migration tests" echo "Running ip migration tests"
for ((i=0; i<2; i++)) for ((i = 0; i < 2; i++)); do
do
timing_enter start_iscsi_tgt_$i timing_enter start_iscsi_tgt_$i
rpc_addr="/var/tmp/spdk${i}.sock" rpc_addr="/var/tmp/spdk${i}.sock"

View File

@ -37,17 +37,17 @@ timing_exit start_iscsi_tgt
timing_enter setup timing_enter setup
$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT $rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
for i in `seq 1 $NUM_MALLOC`; do for i in $(seq 1 $NUM_MALLOC); do
INITIATOR_TAG=$((i+2)) INITIATOR_TAG=$((i + 2))
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK $rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
bdev=$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) bdev=$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)
ls_guid=$($rpc_py construct_lvol_store $bdev lvs_$i -c 1048576) ls_guid=$($rpc_py construct_lvol_store $bdev lvs_$i -c 1048576)
LUNs="" LUNs=""
for j in `seq 1 $NUM_LVOL`; do for j in $(seq 1 $NUM_LVOL); do
lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_$j 10) lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_$j 10)
LUNs+="$lb_name:$((j-1)) " LUNs+="$lb_name:$((j - 1)) "
done done
$rpc_py construct_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 -d $rpc_py construct_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 -d
done done
timing_exit setup timing_exit setup

View File

@ -11,10 +11,9 @@ fio_py="python $rootdir/scripts/fio.py"
CONNECTION_NUMBER=30 CONNECTION_NUMBER=30
# Remove lvol bdevs and stores. # Remove lvol bdevs and stores.
function remove_backends() function remove_backends() {
{
echo "INFO: Removing lvol bdevs" echo "INFO: Removing lvol bdevs"
for i in `seq 1 $CONNECTION_NUMBER`; do for i in $(seq 1 $CONNECTION_NUMBER); do
lun="lvs0/lbd_$i" lun="lvs0/lbd_$i"
$rpc_py destroy_lvol_bdev $lun $rpc_py destroy_lvol_bdev $lun
echo -e "\tINFO: lvol bdev $lun removed" echo -e "\tINFO: lvol bdev $lun removed"
@ -55,12 +54,12 @@ ls_guid=$($rpc_py construct_lvol_store "Nvme0n1" "lvs0" -c 1048576)
# Assign even size for each lvol_bdev. # Assign even size for each lvol_bdev.
get_lvs_free_mb $ls_guid get_lvs_free_mb $ls_guid
lvol_bdev_size=$(($free_mb/$CONNECTION_NUMBER)) lvol_bdev_size=$(($free_mb / $CONNECTION_NUMBER))
for i in `seq 1 $CONNECTION_NUMBER`; do for i in $(seq 1 $CONNECTION_NUMBER); do
$rpc_py construct_lvol_bdev -u $ls_guid lbd_$i $lvol_bdev_size $rpc_py construct_lvol_bdev -u $ls_guid lbd_$i $lvol_bdev_size
done done
for i in `seq 1 $CONNECTION_NUMBER`; do for i in $(seq 1 $CONNECTION_NUMBER); do
lun="lvs0/lbd_$i:0" lun="lvs0/lbd_$i:0"
$rpc_py construct_target_node Target$i Target${i}_alias "$lun" $PORTAL_TAG:$INITIATOR_TAG 256 -d $rpc_py construct_target_node Target$i Target${i}_alias "$lun" $PORTAL_TAG:$INITIATOR_TAG 256 -d
done done

View File

@ -32,16 +32,16 @@ timing_exit start_iscsi_target
timing_enter setup timing_enter setup
$rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT $rpc_py add_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
for i in `seq 1 $TGT_NR`; do for i in $(seq 1 $TGT_NR); do
INITIATOR_TAG=$((i+1)) INITIATOR_TAG=$((i + 1))
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK $rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
luns="" luns=""
for j in `seq 1 $PMEM_PER_TGT`; do for j in $(seq 1 $PMEM_PER_TGT); do
$rpc_py create_pmem_pool /tmp/pool_file${i}_${j} $PMEM_SIZE $PMEM_BLOCK_SIZE $rpc_py create_pmem_pool /tmp/pool_file${i}_${j} $PMEM_SIZE $PMEM_BLOCK_SIZE
bdevs_name="$($rpc_py construct_pmem_bdev -n pmem${i}_${j} /tmp/pool_file${i}_${j})" bdevs_name="$($rpc_py construct_pmem_bdev -n pmem${i}_${j} /tmp/pool_file${i}_${j})"
PMEM_BDEVS+="$bdevs_name " PMEM_BDEVS+="$bdevs_name "
luns+="$bdevs_name:$((j-1)) " luns+="$bdevs_name:$((j - 1)) "
done done
$rpc_py construct_target_node Target$i Target${i}_alias "$luns" "1:$INITIATOR_TAG " 256 -d $rpc_py construct_target_node Target$i Target${i}_alias "$luns" "1:$INITIATOR_TAG " 256 -d
done done
@ -63,8 +63,8 @@ for pmem in $PMEM_BDEVS; do
$rpc_py delete_pmem_bdev $pmem $rpc_py delete_pmem_bdev $pmem
done done
for i in `seq 1 $TGT_NR`; do for i in $(seq 1 $TGT_NR); do
for c in `seq 1 $PMEM_PER_TGT`; do for c in $(seq 1 $PMEM_PER_TGT); do
$rpc_py delete_pmem_pool /tmp/pool_file${i}_${c} $rpc_py delete_pmem_pool /tmp/pool_file${i}_${c}
done done
done done

View File

@ -9,8 +9,8 @@ function check_qos_works_well() {
local enable_limit=$1 local enable_limit=$1
local iops_limit=$2/1000 local iops_limit=$2/1000
local retval=0 local retval=0
local read_iops=$($fio_py 8192 64 randread 5 | grep "\(read: IOPS=\|write: IOPS=\)" \ local read_iops=$($fio_py 8192 64 randread 5 | grep "\(read: IOPS=\|write: IOPS=\)" |
| awk -F, '{print $1}' | awk -F= '{print $2}' | tr -d [k]) awk -F, '{print $1}' | awk -F= '{print $2}' | tr -d [k])
if [ $enable_limit = true ]; then if [ $enable_limit = true ]; then
retval=$(echo "$iops_limit*0.9 < $read_iops && $read_iops < $iops_limit*1.01" | bc) retval=$(echo "$iops_limit*0.9 < $read_iops && $read_iops < $iops_limit*1.01" | bc)
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then

View File

@ -9,10 +9,10 @@ timing_enter rpc_config
# $1 = test type (posix/vpp) # $1 = test type (posix/vpp)
if [ "$1" == "posix" ] || [ "$1" == "vpp" ]; then if [ "$1" == "posix" ] || [ "$1" == "vpp" ]; then
TEST_TYPE=$1 TEST_TYPE=$1
else else
echo "No iSCSI test type specified" echo "No iSCSI test type specified"
exit 1 exit 1
fi fi
MALLOC_BDEV_SIZE=64 MALLOC_BDEV_SIZE=64