test/common: Introduce timeout in discover_bdevs()

In case something goes awfully wrong with the test which calls this
particular function, e.g:

  https://ci.spdk.io/results/autotest-per-patch/builds/4787

the CI's autotest runs may be blocked for max of 15 minutes before
failing the build. Instead, introduce internal timeout for the
routine itself (default of 30s) and fail the test sooner when it
expires.

Change-Id: I2c792c1781987e80e34c1fa19ec3eef43c25e38a
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1026
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Michal Berger 2020-02-26 17:03:50 +01:00 committed by Tomasz Zawadzki
parent ba5329d3e4
commit 692fce3222

View File

@ -762,6 +762,7 @@ function discover_bdevs()
local rootdir=$1
local config_file=$2
local cfg_type=$3
local wait_for_spdk_bdev=${4:-30}
local rpc_server=/var/tmp/spdk-discover-bdevs.sock
if [ ! -e $config_file ]; then
@ -779,6 +780,8 @@ function discover_bdevs()
$cfg_type $config_file &>/dev/null &
stubpid=$!
while ! [ -e /var/run/spdk_bdev0 ]; do
# If this counter drops to zero, errexit will be caught to abort the test
(( wait_for_spdk_bdev-- ))
sleep 1
done