test/bdev: Refactor nbd_function_test()
This function was a bit cluttered so simplify it. Also, it was assuming nbd module was loaded into the kernel prior running it - this could silently fail the nbd_all[@] setup in case it wasn't. Always attempt to load nbd driver before the setup and fail hard if the driver is not in place. Signed-off-by: Michal Berger <michal.berger@intel.com> Change-Id: I5884973944eae3e827eaafec16ba72e2cb4f70e7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14994 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
f17fe62924
commit
367fc7a9cf
@ -5,6 +5,8 @@ rootdir=$(readlink -f $testdir/../..)
|
|||||||
source $rootdir/test/common/autotest_common.sh
|
source $rootdir/test/common/autotest_common.sh
|
||||||
source $testdir/nbd_common.sh
|
source $testdir/nbd_common.sh
|
||||||
|
|
||||||
|
shopt -s nullglob extglob
|
||||||
|
|
||||||
rpc_py=rpc_cmd
|
rpc_py=rpc_cmd
|
||||||
conf_file="$testdir/bdev.json"
|
conf_file="$testdir/bdev.json"
|
||||||
nonenclosed_conf_file="$testdir/nonenclosed.json"
|
nonenclosed_conf_file="$testdir/nonenclosed.json"
|
||||||
@ -208,42 +210,34 @@ function bdev_bounds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nbd_function_test() {
|
function nbd_function_test() {
|
||||||
if [ $(uname -s) = Linux ] && modprobe -n nbd; then
|
[[ $(uname -s) == Linux ]] || return 0
|
||||||
local rpc_server=/var/tmp/spdk-nbd.sock
|
|
||||||
local conf=$1
|
|
||||||
local nbd_all=($(ls /dev/nbd* | grep -v p))
|
|
||||||
local bdev_all=($bdevs_name)
|
|
||||||
local nbd_num=${#bdev_all[@]}
|
|
||||||
if ((nbd_num < 1)); then
|
|
||||||
# There should be at least one bdev and one valid nbd device
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ${#nbd_all[@]} -le $nbd_num ]; then
|
|
||||||
nbd_num=${#nbd_all[@]}
|
|
||||||
fi
|
|
||||||
local nbd_list=(${nbd_all[@]:0:$nbd_num})
|
|
||||||
local bdev_list=(${bdev_all[@]:0:$nbd_num})
|
|
||||||
|
|
||||||
if [ ! -e $conf ]; then
|
local rpc_server=/var/tmp/spdk-nbd.sock
|
||||||
return 1
|
local conf=$1
|
||||||
fi
|
local bdev_all=($2)
|
||||||
|
local bdev_num=${#bdev_all[@]}
|
||||||
|
|
||||||
modprobe nbd
|
# FIXME: Centos7 in the CI is not shipped with a kernel supporting BLK_DEV_NBD
|
||||||
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 --json "$conf" "$env_ctx" &
|
# so don't fail here for now.
|
||||||
nbd_pid=$!
|
[[ -e /sys/module/nbd ]] || modprobe -q nbd nbds_max=$bdev_num || return 0
|
||||||
trap 'cleanup; killprocess $nbd_pid; exit 1' SIGINT SIGTERM EXIT
|
|
||||||
echo "Process nbd pid: $nbd_pid"
|
|
||||||
waitforlisten $nbd_pid $rpc_server
|
|
||||||
|
|
||||||
nbd_rpc_start_stop_verify $rpc_server "${bdev_list[*]}"
|
local nbd_all=(/dev/nbd+([0-9]))
|
||||||
nbd_rpc_data_verify $rpc_server "${bdev_list[*]}" "${nbd_list[*]}"
|
bdev_num=$((${#nbd_all[@]} < bdev_num ? ${#nbd_all[@]} : bdev_num))
|
||||||
nbd_with_lvol_verify $rpc_server "${nbd_list[*]}"
|
|
||||||
|
|
||||||
killprocess $nbd_pid
|
local nbd_list=(${nbd_all[@]::bdev_num})
|
||||||
trap - SIGINT SIGTERM EXIT
|
local bdev_list=(${bdev_all[@]::bdev_num})
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 --json "$conf" "$env_ctx" &
|
||||||
|
nbd_pid=$!
|
||||||
|
trap 'cleanup; killprocess $nbd_pid' SIGINT SIGTERM EXIT
|
||||||
|
waitforlisten $nbd_pid $rpc_server
|
||||||
|
|
||||||
|
nbd_rpc_start_stop_verify $rpc_server "${bdev_list[*]}"
|
||||||
|
nbd_rpc_data_verify $rpc_server "${bdev_list[*]}" "${nbd_list[*]}"
|
||||||
|
nbd_with_lvol_verify $rpc_server "${nbd_list[*]}"
|
||||||
|
|
||||||
|
killprocess $nbd_pid
|
||||||
|
trap - SIGINT SIGTERM EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
function fio_test_suite() {
|
function fio_test_suite() {
|
||||||
|
Loading…
Reference in New Issue
Block a user