From 5dd160bde6a58b7730d34298bc7521d7d265784c Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Mon, 12 Jun 2017 13:28:52 +0200 Subject: [PATCH] test/vhost: Modify wait time for vhost start in fiotest Look for open RPC port instead of issuing "sleep" for a number of seconds. Change-Id: Id75476ae3d6c39de7f7da2c0878d251384c2bb65 Signed-off-by: Karol Latecki Reviewed-on: https://review.gerrithub.io/364974 Tested-by: SPDK Automated Test System Reviewed-by: Tomasz Zawadzki Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- test/vhost/fiotest/common.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/vhost/fiotest/common.sh b/test/vhost/fiotest/common.sh index 9b809ca610..6008d77072 100644 --- a/test/vhost/fiotest/common.sh +++ b/test/vhost/fiotest/common.sh @@ -40,6 +40,17 @@ mkdir -p $TEST_DIR . $BASE_DIR/autotest.config +RPC_PORT=5260 + +# Trace flag is optional, if it wasn't set earlier - disable it after sourcing +# autotest_common.sh +if [[ $- =~ x ]]; then + source $SPDK_BUILD_DIR/scripts/autotest_common.sh +else + source $SPDK_BUILD_DIR/scripts/autotest_common.sh + set +x +fi + function error() { echo "===========" @@ -146,10 +157,10 @@ function spdk_vhost_run() ( cd $SPDK_VHOST_SCSI_TEST_DIR; $cmd & echo $! >&3) 3>$vhost_pid_file 2>&1 | tee -a $vhost_log_file & - echo "INFO: waiting 25s to allow app to run..." - sleep 25 - kill -0 $(cat $vhost_pid_file) - echo "INFO: vhost started - pid=$(cat $vhost_pid_file)" + echo "INFO: waiting for app to run..." + local vhost_pid="$(cat $vhost_pid_file)" + waitforlisten "$vhost_pid" ${RPC_PORT} + echo "INFO: vhost started - pid=$vhost_pid" rm $vhost_conf_file } @@ -332,7 +343,7 @@ function vm_shutdown() # "fail" due to shutdown echo "Shutting down virtual machine $vm_dir" set +e - vm_ssh $1 "nohup sh -c 'shutdown -h -P now'" + vm_ssh $1 "nohup sh -c 'shutdown -h -P now'" || true echo "INFO: VM$1 is shutting down - wait a while to complete" set -e }