From 825831346506fd3bb69628d9e82898597ff1859f Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 11 Jun 2019 08:53:10 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457562 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- test/common/autotest_common.sh | 37 ++-------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index e9082a200..06b1a2d8b 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -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 + if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &>/dev/null; then + break 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