diff --git a/test/iscsi_tgt/common.sh b/test/iscsi_tgt/common.sh index 9ddfd10a5..53b261b38 100644 --- a/test/iscsi_tgt/common.sh +++ b/test/iscsi_tgt/common.sh @@ -19,11 +19,10 @@ fi ISCSI_TEST_CORE_MASK=0xFF function create_veth_interfaces() { - # $1 = test type (posix/vpp) ip netns del $TARGET_NAMESPACE || true ip link delete $INITIATOR_INTERFACE || true - trap 'cleanup_veth_interfaces $1; exit 1' SIGINT SIGTERM EXIT + trap 'cleanup_veth_interfaces; exit 1' SIGINT SIGTERM EXIT # Create veth (Virtual ethernet) interface pair ip link add $INITIATOR_INTERFACE type veth peer name $TARGET_INTERFACE @@ -39,24 +38,15 @@ function create_veth_interfaces() { "${TARGET_NS_CMD[@]}" ip link set $TARGET_INTERFACE up - if [ "$1" == "posix" ]; then - "${TARGET_NS_CMD[@]}" ip link set lo up - "${TARGET_NS_CMD[@]}" ip addr add $TARGET_IP/24 dev $TARGET_INTERFACE + "${TARGET_NS_CMD[@]}" ip link set lo up + "${TARGET_NS_CMD[@]}" ip addr add $TARGET_IP/24 dev $TARGET_INTERFACE - # Verify connectivity - ping -c 1 $TARGET_IP - ip netns exec $TARGET_NAMESPACE ping -c 1 $INITIATOR_IP - else - start_vpp - fi + # Verify connectivity + ping -c 1 $TARGET_IP + ip netns exec $TARGET_NAMESPACE ping -c 1 $INITIATOR_IP } function cleanup_veth_interfaces() { - # $1 = test type (posix/vpp) - if [ "$1" == "vpp" ]; then - kill_vpp - fi - # Cleanup veth interfaces and network namespace # Note: removing one veth, removes the pair ip link delete $INITIATOR_INTERFACE @@ -66,12 +56,7 @@ function cleanup_veth_interfaces() { function iscsitestinit() { if [ "$TEST_MODE" == "iso" ]; then $rootdir/scripts/setup.sh - if [ -n "$1" ]; then - create_veth_interfaces $1 - else - # default to posix - create_veth_interfaces "posix" - fi + create_veth_interfaces fi } @@ -92,99 +77,11 @@ function waitforiscsidevices() { function iscsitestfini() { if [ "$TEST_MODE" == "iso" ]; then - if [ -n "$1" ]; then - cleanup_veth_interfaces $1 - else - # default to posix - cleanup_veth_interfaces "posix" - fi + cleanup_veth_interfaces $rootdir/scripts/setup.sh reset fi } -function start_vpp() { - # We need to make sure that posix side doesn't send jumbo packets while - # for VPP side maximal size of MTU for TCP is 1460 and tests doesn't work - # stable with larger packets - MTU=1460 - MTU_W_HEADER=$((MTU + 20)) - ip link set dev $INITIATOR_INTERFACE mtu $MTU - ethtool -K $INITIATOR_INTERFACE tso off - ethtool -k $INITIATOR_INTERFACE - - # Start VPP process in SPDK target network namespace - "${TARGET_NS_CMD[@]}" vpp \ - unix { nodaemon cli-listen /run/vpp/cli.sock } \ - dpdk { no-pci } \ - session { evt_qs_memfd_seg } \ - socksvr { socket-name /run/vpp-api.sock } \ - plugins { \ - plugin default { disable } \ - plugin dpdk_plugin.so { enable } \ - } & - - vpp_pid=$! - echo "VPP Process pid: $vpp_pid" - - gdb_attach $vpp_pid & - - # Wait until VPP starts responding - xtrace_disable - counter=40 - while [ $counter -gt 0 ]; do - vppctl show version | grep -E "vpp v[0-9]+\.[0-9]+" && break - counter=$((counter - 1)) - sleep 0.5 - done - xtrace_restore - if [ $counter -eq 0 ]; then - return 1 - fi - - # Below VPP commands are masked with "|| true" for the sake of - # running the test in the CI system. For reasons unknown when - # run via CI these commands result in 141 return code (pipefail) - # even despite producing valid output. - # Using "|| true" does not impact the "-e" flag used in test scripts - # because vppctl cli commands always return with 0, even if - # there was an error. - # As a result - grep checks on command outputs must be used to - # verify vpp configuration and connectivity. - - # Setup host interface - vppctl create host-interface name $TARGET_INTERFACE || true - VPP_TGT_INT="host-$TARGET_INTERFACE" - vppctl set interface state $VPP_TGT_INT up || true - vppctl set interface ip address $VPP_TGT_INT $TARGET_IP/24 || true - vppctl set interface mtu $MTU $VPP_TGT_INT || true - - vppctl show interface | tr -s " " | grep -E "host-$TARGET_INTERFACE [0-9]+ up $MTU/0/0/0" - - # Disable session layer - # NOTE: VPP net framework should enable it itself. - vppctl session disable || true - - # Verify connectivity - vppctl show int addr | grep -E "$TARGET_IP/24" - ip addr show $INITIATOR_INTERFACE - ip netns exec $TARGET_NAMESPACE ip addr show $TARGET_INTERFACE - sleep 3 - # SC1010: ping -M do - in this case do is an option not bash special word - # shellcheck disable=SC1010 - ping -c 1 $TARGET_IP -s $((MTU - 28)) -M do - vppctl ping $INITIATOR_IP repeat 1 size $((MTU - (28 + 8))) verbose | grep -E "$MTU_W_HEADER bytes from $INITIATOR_IP" -} - -function kill_vpp() { - vppctl delete host-interface name $TARGET_INTERFACE || true - - # Dump VPP configuration before kill - vppctl show api clients || true - vppctl show session || true - vppctl show errors || true - - killprocess $vpp_pid -} function initiator_json_config() { # Prepare config file for iSCSI initiator jq . <<- JSON diff --git a/test/iscsi_tgt/iscsi_tgt.sh b/test/iscsi_tgt/iscsi_tgt.sh index 0316229b6..6d10a407e 100755 --- a/test/iscsi_tgt/iscsi_tgt.sh +++ b/test/iscsi_tgt/iscsi_tgt.sh @@ -22,9 +22,9 @@ fi iscsicleanup # Network configuration -create_veth_interfaces $TEST_TYPE +create_veth_interfaces -trap 'cleanup_veth_interfaces $TEST_TYPE; exit 1' SIGINT SIGTERM EXIT +trap 'cleanup_veth_interfaces; exit 1' SIGINT SIGTERM EXIT run_test "iscsi_tgt_sock" ./test/iscsi_tgt/sock/sock.sh $TEST_TYPE if [ "$TEST_TYPE" == "posix" ]; then @@ -70,7 +70,7 @@ if [ $SPDK_TEST_RBD -eq 1 ]; then fi fi -trap 'cleanup_veth_interfaces $TEST_TYPE; exit 1' SIGINT SIGTERM EXIT +trap 'cleanup_veth_interfaces; exit 1' SIGINT SIGTERM EXIT if [ $SPDK_TEST_NVMF -eq 1 ]; then # NVMe-oF tests do not support network namespaces, @@ -93,5 +93,5 @@ if [ $SPDK_TEST_ISCSI_INITIATOR -eq 1 ]; then run_test "iscsi_tgt_bdev_io_wait" ./test/iscsi_tgt/bdev_io_wait/bdev_io_wait.sh fi -cleanup_veth_interfaces $TEST_TYPE +cleanup_veth_interfaces trap - SIGINT SIGTERM EXIT