From 6e1611da186c5aad42d898b277e16548ada073fd Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 4 Apr 2018 12:47:52 -0700 Subject: [PATCH] test: use ss -lx instead of netstat by default netstat is deprecated on CentOS/RHEL in favor of iproute utilities. At least on one of the systems in our test pool, netstat isn't installed - we could install it but let's instead try to use ss if it's available and still fall back to netstat when it's not. While here, remove waitforlisten_tcp instead of changing it to use ss. We are not using waitforlisten_tcp anywhere and do not recommend enabling RPC over TCP except for test purposes. Signed-off-by: Jim Harris Change-Id: I4ee3597536797f501750915a4a219b55004bd454 Reviewed-on: https://review.gerrithub.io/406464 Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System --- test/common/autotest_common.sh | 35 +++++++++------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 24329d10c..68f0c90da 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -233,32 +233,15 @@ function waitforlisten() { if ! kill -s 0 $1; then exit 1 fi - if netstat -an -x | grep -iw LISTENING | grep -q $rpc_addr; then - ret=0 - fi - done - set -x -} - -function waitforlisten_tcp() { - # $1 = process pid - # $2 = TCP port number - if [ -z "$1" ] || [ -z "$2" ]; then - exit 1 - fi - - echo "Waiting for process to start up and listen on TCP port $2..." - # turn off trace for this loop - set +x - ret=1 - while [ $ret -ne 0 ]; do - # if the process is no longer running, then exit the script - # since it means the application crashed - if ! kill -s 0 $1; then - exit - fi - if netstat -an --tcp | grep -iw listen | grep -q $2; then - ret=0 + if hash ss; then + if ss -lx | grep -q $rpc_addr; then + ret=0 + fi + else + # if system doesn't have ss, just assume it has netstat + if netstat -an -x | grep -iw LISTENING | grep -q $rpc_addr; then + ret=0 + fi fi done set -x