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 <james.r.harris@intel.com>
Change-Id: I4ee3597536797f501750915a4a219b55004bd454

Reviewed-on: https://review.gerrithub.io/406464
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Jim Harris 2018-04-04 12:47:52 -07:00 committed by Daniel Verkamp
parent 26dd844d8a
commit 6e1611da18

View File

@ -233,32 +233,15 @@ function waitforlisten() {
if ! kill -s 0 $1; then
exit 1
fi
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
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
fi
done
set -x