Spdk/test/iscsi_tgt/sock/sock.sh
Tomasz Zawadzki ef489303b4 net/vpp: include VPP into iSCSI test scripts
Tests that were thus far performed using posix net framework
can now be run with VPP. This patch adds network interface
configuration for VPP to work in iSCSI tests.

Some tests are disabled on purpose:
- IP Migration, RBD and NVMe-oF due to their tests lacking network
  namespace support
- rpc_config adding/deleting IP, as VPP has separate utility for that

calsoft.sh doesn't handle TCP stream properly and fails decoding iSCSI
requests when are divided by TCP segmentation. This is very common
situation for VPP and causes that calsoft.sh never PASS.

Change-Id: I7c80427ca1675a1789ce7440796cc8d9956f1c9e
Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/394174
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-06-27 08:23:08 +00:00

128 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/iscsi_tgt/common.sh
function waitfortcp() {
local addr="$2"
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 address $addr..."
# turn off trace for this loop
xtrace_disable
local ret=0
local i
for (( i = 40; i != 0; i-- )); do
# if the process is no longer running, then exit the script
# since it means the application crashed
if ! kill -s 0 $1; then
echo "ERROR: process (pid: $1) is no longer running"
ret=1
break
fi
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+$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+$addr\$"; then
break
fi
fi
sleep 0.5
done
xtrace_restore
if (( i == 0 )); then
echo "ERROR: timeout while waiting for process (pid: $1) to start listening on '$addr'"
ret=1
fi
return $ret
}
# $1 = "iso" - triggers isolation mode (setting up required environment).
# $2 = test type posix or vpp. defaults to posix.
iscsitestinit $1 $2
HELLO_SOCK_APP="$TARGET_NS_CMD $rootdir/examples/sock/hello_world/hello_sock"
if [ $SPDK_TEST_VPP -eq 1 ]; then
HELLO_SOCK_APP+=" -L sock_vpp"
fi
SOCAT_APP="socat"
# ----------------
# Test client path
# ----------------
timing_enter sock_client
echo "Testing client path"
# start echo server using socat
$SOCAT_APP tcp-l:$ISCSI_PORT,fork,bind=$INITIATOR_IP exec:'/bin/cat' & server_pid=$!
trap "killprocess $server_pid;iscsitestfini $1 $2; exit 1" SIGINT SIGTERM EXIT
waitfortcp $server_pid $INITIATOR_IP:$ISCSI_PORT
# send message using hello_sock client
message="**MESSAGE:This is a test message from the client**"
response=$( echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT )
if ! echo "$response" | grep -q "$message"; then
exit 1
fi
trap '-' SIGINT SIGTERM EXIT
# NOTE: socat returns code 143 on SIGINT
killprocess $server_pid || true
report_test_completion "sock_client"
timing_exit sock_client
# ----------------
# Test server path
# ----------------
timing_enter sock_server
# start echo server using hello_sock echo server
$HELLO_SOCK_APP -H $TARGET_IP -P $ISCSI_PORT -S & server_pid=$!
trap "killprocess $server_pid; iscsitestfini $1 $2; exit 1" SIGINT SIGTERM EXIT
waitforlisten $server_pid
# send message to server using socat
message="**MESSAGE:This is a test message to the server**"
response=$( echo $message | $SOCAT_APP - tcp:$TARGET_IP:$ISCSI_PORT 2>/dev/null )
if [ "$message" != "$response" ]; then
exit 1
fi
trap - SIGINT SIGTERM EXIT
killprocess $server_pid
iscsitestfini $1 $2
report_test_completion "sock_server"
timing_exit sock_server