test/common: refactor waitforlisten to try sending RPC commands
Instead of doing some OS-specific magic to detect if the spdk app has already initialized, just try to send it an RPC. This serves mostly as cleanup, but also simplifies test output in cases where the spdk app could not be fully initialized. Previous waitforlisten implementation would return as soon as the rpc subsystem was initialized, but the app could have still failed on e.g. bdev initialization later on. Since waitforlisten() returned success, the script could continue its execution and try to execute some RPCs. The logs from the SPDK app and the bash script could easily mix, rendering the entire output not so clear to the user. To fix it, just try to send some RPC commands inside waitforlisten(). Change-Id: I33eaf362e3cc645f8ea3ee22fd48db1643442129 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457562 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
fe2d4b0274
commit
8258313465
@ -341,18 +341,6 @@ function waitforlisten() {
|
||||
|
||||
local rpc_addr="${2:-$DEFAULT_RPC_ADDR}"
|
||||
|
||||
if hash ip &>/dev/null; then
|
||||
local have_ip_cmd=true
|
||||
else
|
||||
local have_ip_cmd=false
|
||||
fi
|
||||
|
||||
if hash ss &>/dev/null; then
|
||||
local have_ss_cmd=true
|
||||
else
|
||||
local have_ss_cmd=false
|
||||
fi
|
||||
|
||||
echo "Waiting for process to start up and listen on UNIX domain socket $rpc_addr..."
|
||||
# turn off trace for this loop
|
||||
xtrace_disable
|
||||
@ -367,31 +355,10 @@ function waitforlisten() {
|
||||
break
|
||||
fi
|
||||
|
||||
# FIXME: don't know how to fix this for FreeBSD
|
||||
if $have_ip_cmd; then
|
||||
namespace=$(ip netns identify $1)
|
||||
if [ -n "$namespace" ]; then
|
||||
ns_cmd="ip netns exec $namespace"
|
||||
fi
|
||||
fi
|
||||
|
||||
if $have_ss_cmd; then
|
||||
if $ns_cmd ss -ln | egrep -q "\s+$rpc_addr\s+"; then
|
||||
break
|
||||
fi
|
||||
elif [[ "$(uname -s)" == "Linux" ]]; then
|
||||
# For Linux, if system doesn't have ss, just assume it has netstat
|
||||
if $ns_cmd netstat -an | grep -iw LISTENING | egrep -q "\s+$rpc_addr\$"; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
# On FreeBSD netstat output 'State' column is missing for Unix sockets.
|
||||
# To workaround this issue just try to use provided address.
|
||||
# XXX: This solution could be used for other distros.
|
||||
if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &>/dev/null; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user