Commit 6e1611da authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

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

Reviewed-on: https://review.gerrithub.io/406464


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 26dd844d
Loading
Loading
Loading
Loading
+9 −26
Original line number Diff line number Diff line
@@ -233,33 +233,16 @@ function waitforlisten() {
		if ! kill -s 0 $1; then
			exit 1
		fi
		if netstat -an -x | grep -iw LISTENING | grep -q $rpc_addr; then
		if hash ss; then
			if ss -lx | 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
		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
}