From 8cbbdf2ddf06f0efcd435ab57bf5d3eb61db1e01 Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Sat, 20 Oct 2018 18:20:43 +0200 Subject: [PATCH] test: fix nvmf connect/disconnect Add missing wait in test/nvme/shutdown/shutdown.sh Not waiting after connecting nvme device resulted in undefined behavior. This patch uses new helper function - nvme_connect Change-Id: Idb29c7f6b40ae4b3fa0eb68f7b8d5f86d9a4149f Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.gerrithub.io/428336 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Seth Howell Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- test/nvmf/common.sh | 17 +++++++++++++++++ test/nvmf/shutdown/shutdown.sh | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index af79e3f7d..12be90463 100755 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -198,3 +198,20 @@ function check_ip_is_soft_roce() return 1 fi } + +function nvme_connect() +{ + local init_count=$(nvme list | wc -l) + + nvme connect $@ + if [ $? != 0 ]; then return $?; fi + + for i in $(seq 1 10); do + if [ $(nvme list | wc -l) -gt $init_count ]; then + return 0 + else + sleep 1s + fi + done + return 1 +} diff --git a/test/nvmf/shutdown/shutdown.sh b/test/nvmf/shutdown/shutdown.sh index aeae8e1a1..7a262cb07 100755 --- a/test/nvmf/shutdown/shutdown.sh +++ b/test/nvmf/shutdown/shutdown.sh @@ -61,7 +61,7 @@ modprobe -v nvme-fabrics for ((x=0; x<2;x++)); do # Connect kernel host to subsystems for i in `seq 1 $num_subsystems`; do - nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode${i}" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" + nvme_connect -t rdma -n "nqn.2016-06.io.spdk:cnode${i}" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" done # Disconnect the subsystems in reverse order for i in `seq $num_subsystems -1 1`; do