From 53147e0dc8cc23208f226c813d137bab7d11896a Mon Sep 17 00:00:00 2001 From: Maciej Wawryk Date: Thu, 19 Dec 2019 15:17:49 +0100 Subject: [PATCH] test: fix issue with changing device names in waitforblk function During test before upgrading our vm's to Fedora31 there were issue with failing nvmf test on function waitforblk. In some cases hardcoded nvme0n1 name was not found in system. Here is fix that change searching by name to searching by nvme serial. Signed-off-by: Maciej Wawryk Change-Id: Ic5ee70804652a057fa26b8cc004b5227262d2122 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478471 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Reviewed-by: Seth Howell Community-CI: SPDK CI Jenkins --- test/common/autotest_common.sh | 39 ++++++++++++++++++++++++++ test/nvmf/common.sh | 1 + test/nvmf/target/connect_disconnect.sh | 6 ++-- test/nvmf/target/filesystem.sh | 29 +++++++++---------- test/nvmf/target/fio.sh | 6 ++-- test/nvmf/target/initiator_timeout.sh | 4 +-- test/nvmf/target/nmic.sh | 4 +-- test/nvmf/target/nvme_cli.sh | 6 ++-- test/nvmf/target/rpc.sh | 12 ++++---- 9 files changed, 71 insertions(+), 36 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index c6c453970..864a58965 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -717,6 +717,45 @@ function discover_bdevs() rm -f /var/run/spdk_bdev0 } +function waitforserial() +{ + local i=0 + local nvme_device_counter=1 + if [[ -n "$2" ]]; then + nvme_device_counter=$2 + fi + + while [ $(lsblk -l -o NAME,SERIAL | grep -c $1) -lt $nvme_device_counter ]; do + [ $i -lt 15 ] || break + i=$((i+1)) + echo "Waiting for devices" + sleep 1 + done + + if [[ $(lsblk -l -o NAME,SERIAL | grep -c $1) -lt $nvme_device_counter ]]; then + return 1 + fi + + return 0 +} + +function waitforserial_disconnect() +{ + local i=0 + while lsblk -o NAME,SERIAL | grep -q -w $1; do + [ $i -lt 15 ] || break + i=$((i+1)) + echo "Waiting for disconnect devices" + sleep 1 + done + + if lsblk -l -o NAME | grep -q -w $1; then + return 1 + fi + + return 0 +} + function waitforblk() { local i=0 diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index cfdb12010..d3736828e 100644 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -3,6 +3,7 @@ NVMF_IP_PREFIX="192.168.100" NVMF_IP_LEAST_ADDR=8 NVMF_TCP_IP_ADDRESS="127.0.0.1" NVMF_TRANSPORT_OPTS="" +NVMF_SERIAL=SPDK00000000000001 function build_nvmf_app_args() { diff --git a/test/nvmf/target/connect_disconnect.sh b/test/nvmf/target/connect_disconnect.sh index 67b67e853..caba36688 100755 --- a/test/nvmf/target/connect_disconnect.sh +++ b/test/nvmf/target/connect_disconnect.sh @@ -18,7 +18,7 @@ $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 -c 0 bdev="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" -$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 +$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 $bdev $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT @@ -32,9 +32,9 @@ fi set +x for i in $(seq 1 $num_iterations); do nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" $IO_QUEUES - waitforblk "nvme0n1" + waitforserial "$NVMF_SERIAL" nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" - waitforblk_disconnect "nvme0n1" + waitforserial_disconnect "$NVMF_SERIAL" done set -x diff --git a/test/nvmf/target/filesystem.sh b/test/nvmf/target/filesystem.sh index c22fee268..cf86c3407 100755 --- a/test/nvmf/target/filesystem.sh +++ b/test/nvmf/target/filesystem.sh @@ -14,6 +14,7 @@ nvmftestinit function nvmf_filesystem_create { fstype=$1 + nvme_name=$2 if [ $fstype = ext4 ]; then force=-F @@ -21,9 +22,9 @@ function nvmf_filesystem_create { force=-f fi - mkfs.${fstype} $force /dev/nvme0n1p1 + mkfs.${fstype} $force /dev/${nvme_name}p1 - mount /dev/nvme0n1p1 /mnt/device + mount /dev/${nvme_name}p1 /mnt/device touch /mnt/device/aaa sync rm /mnt/device/aaa @@ -38,34 +39,32 @@ function nvmf_filesystem_part { $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 -c $incapsule $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc1 - $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 + $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" - # TODO: fix this to wait for the proper NVMe device. - # if we are hosting the local filesystem on an NVMe drive, this test will fail - # because it relies on the no other NVMe drives being present in the system. - waitforblk "nvme0n1" + waitforserial "$NVMF_SERIAL" + nvme_name=$(lsblk -l -o NAME,SERIAL | grep -oP "([\w]*)(?=\s+${NVMF_SERIAL})") mkdir -p /mnt/device - parted -s /dev/nvme0n1 mklabel msdos mkpart primary '0%' '100%' + parted -s /dev/${nvme_name} mklabel msdos mkpart primary '0%' '100%' partprobe sleep 1 if [ $incapsule -eq 0 ]; then - run_test "filesystem_ext4" nvmf_filesystem_create "ext4" - run_test "filesystem_btrfs" nvmf_filesystem_create "btrfs" - run_test "filesystem_xfs" nvmf_filesystem_create "xfs" + run_test "filesystem_ext4" nvmf_filesystem_create "ext4" ${nvme_name} + run_test "filesystem_btrfs" nvmf_filesystem_create "btrfs" ${nvme_name} + run_test "filesystem_xfs" nvmf_filesystem_create "xfs" ${nvme_name} else - run_test "filesystem_incapsule_ext4" nvmf_filesystem_create "ext4" - run_test "filesystem_incapsule_btrfs" nvmf_filesystem_create "btrfs" - run_test "filesystem_incapsule_xfs" nvmf_filesystem_create "xfs" + run_test "filesystem_incapsule_ext4" nvmf_filesystem_create "ext4" ${nvme_name} + run_test "filesystem_incapsule_btrfs" nvmf_filesystem_create "btrfs" ${nvme_name} + run_test "filesystem_incapsule_xfs" nvmf_filesystem_create "xfs" ${nvme_name} fi - parted -s /dev/nvme0n1 rm 1 + parted -s /dev/${nvme_name} rm 1 sync nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" || true diff --git a/test/nvmf/target/fio.sh b/test/nvmf/target/fio.sh index 901bfb099..e53321a80 100755 --- a/test/nvmf/target/fio.sh +++ b/test/nvmf/target/fio.sh @@ -22,7 +22,7 @@ raid_malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_ raid_malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" $rpc_py bdev_raid_create -n raid0 -z 64 -r 0 -b "$raid_malloc_bdevs" -$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 +$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL for malloc_bdev in $malloc_bdevs; do $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 "$malloc_bdev" done @@ -33,9 +33,7 @@ $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 raid0 nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" -waitforblk "nvme0n1" -waitforblk "nvme0n2" -waitforblk "nvme0n3" +waitforserial $NVMF_SERIAL 3 $rootdir/scripts/fio.py -p nvmf -i 4096 -d 1 -t write -r 1 -v $rootdir/scripts/fio.py -p nvmf -i 4096 -d 1 -t randwrite -r 1 -v diff --git a/test/nvmf/target/initiator_timeout.sh b/test/nvmf/target/initiator_timeout.sh index d302e6350..e2e483c89 100755 --- a/test/nvmf/target/initiator_timeout.sh +++ b/test/nvmf/target/initiator_timeout.sh @@ -21,13 +21,13 @@ $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 $rpc_py bdev_delay_create -b Malloc0 -d Delay0 -r 30 -t 30 -w 30 -n 30 $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 -$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 +$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Delay0 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" -waitforblk "nvme0n1" +waitforserial "$NVMF_SERIAL" # Once our timed out I/O complete, we will still have 10 sec of I/O. $rootdir/scripts/fio.py -p nvmf -i 4096 -d 1 -t write -r 60 -v & diff --git a/test/nvmf/target/nmic.sh b/test/nvmf/target/nmic.sh index 6ecb13dc5..65bbddd37 100755 --- a/test/nvmf/target/nmic.sh +++ b/test/nvmf/target/nmic.sh @@ -19,7 +19,7 @@ $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 # Create subsystems $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 -$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK1 +$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT" @@ -44,7 +44,7 @@ if [ -n "$NVMF_SECOND_TARGET_IP" ]; then nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_SECOND_TARGET_IP" -s "$NVMF_PORT" - waitforblk "nvme0n1" + waitforserial "$NVMF_SERIAL" $rootdir/scripts/fio.py -p nvmf -i 4096 -d 1 -t write -r 1 -v fi diff --git a/test/nvmf/target/nvme_cli.sh b/test/nvmf/target/nvme_cli.sh index 6e7614451..e214c9dc1 100755 --- a/test/nvmf/target/nvme_cli.sh +++ b/test/nvmf/target/nvme_cli.sh @@ -25,16 +25,14 @@ $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc1 -$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 -d SPDK_Controller1 +$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL -d SPDK_Controller1 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" -waitforblk "nvme0n1" -waitforblk "nvme0n2" - +waitforserial $NVMF_SERIAL 2 nvme list for ctrl in /dev/nvme?; do diff --git a/test/nvmf/target/rpc.sh b/test/nvmf/target/rpc.sh index 1b4badf2c..ef7313059 100755 --- a/test/nvmf/target/rpc.sh +++ b/test/nvmf/target/rpc.sh @@ -55,7 +55,7 @@ MALLOC_BLOCK_SIZE=512 $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc1 # Disallow host NQN and make sure connect fails -$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 +$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 $rpc_py nvmf_subsystem_allow_any_host -d nqn.2016-06.io.spdk:cnode1 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT @@ -66,7 +66,7 @@ $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPOR # Add the host NQN and verify that the connect succeeds $rpc_py nvmf_subsystem_add_host nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spdk:host1 nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" -waitforblk "nvme0n1" +waitforserial "$NVMF_SERIAL" nvme disconnect -n nqn.2016-06.io.spdk:cnode1 # Remove the host and verify that the connect fails @@ -76,7 +76,7 @@ $rpc_py nvmf_subsystem_remove_host nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spd # Allow any host and verify that the connect succeeds $rpc_py nvmf_subsystem_allow_any_host -e nqn.2016-06.io.spdk:cnode1 nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" -waitforblk "nvme0n1" +waitforserial "$NVMF_SERIAL" nvme disconnect -n nqn.2016-06.io.spdk:cnode1 $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 @@ -84,13 +84,13 @@ $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 # do frequent add delete of namespaces with different nsid. for i in $(seq 1 $times) do - $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s SPDK00000000000001 + $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 -n 5 $rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode1 nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" - waitforblk "nvme0n1" + waitforserial "$NVMF_SERIAL" nvme disconnect -n nqn.2016-06.io.spdk:cnode1 @@ -102,7 +102,7 @@ done # do frequent add delete. for i in $(seq 1 $times) do - $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s SPDK00000000000001 + $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 $rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode1