test/iscsi: use veth interfaces instead of loopback
At this time all iSCSI tests were using local address 127.0.0.1 for both sides of connection. This patch changes iSCSI tests to use separate veth (virtual ethernet) interfaces. It will allow to actually verify functionality when using different target and initiator IPs. Veth are used as most closely resembling real enviroment in single host and without any network hardware required. This patch serves as a base for future VPP test changes, where veth interfaces are used as well. Note: Netmask changed to /30 temporarily and verify_iscsi_connection_rpc_methods in rpc_config disabled. Kernel will route trafic between two veth interfaces through host stack. This causes target and initiator IPs to be not as expected. Those are changed back in next patch by adding namespaces. Change-Id: Ida8fce107e8262bef94b2161e0197c45f6e3f070 Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-on: https://review.gerrithub.io/405552 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
2393edd538
commit
7da3afd1f7
@ -1,10 +1,34 @@
|
||||
# Network configuration
|
||||
TARGET_INTERFACE="spdk_tgt_int"
|
||||
INITIATOR_INTERFACE="spdk_init_int"
|
||||
|
||||
# iSCSI target configuration
|
||||
TARGET_IP=127.0.0.1
|
||||
INITIATOR_IP=127.0.0.1
|
||||
TARGET_IP=10.0.0.1
|
||||
INITIATOR_IP=10.0.0.2
|
||||
ISCSI_PORT=3260
|
||||
NETMASK=$INITIATOR_IP/32
|
||||
NETMASK=$INITIATOR_IP/30
|
||||
INITIATOR_TAG=2
|
||||
INITIATOR_NAME=ANY
|
||||
PORTAL_TAG=1
|
||||
ISCSI_APP="./app/iscsi_tgt/iscsi_tgt -i 0"
|
||||
ISCSI_TEST_CORE_MASK=0xFF
|
||||
|
||||
function create_veth_interfaces() {
|
||||
ip link delete $INITIATOR_INTERFACE || true
|
||||
|
||||
# Create veth (Virtual ethernet) interface pair
|
||||
ip link add $INITIATOR_INTERFACE type veth peer name $TARGET_INTERFACE
|
||||
ip addr add $INITIATOR_IP/24 dev $INITIATOR_INTERFACE
|
||||
ip link set $INITIATOR_INTERFACE up
|
||||
|
||||
ip addr add $TARGET_IP/24 dev $TARGET_INTERFACE
|
||||
ip link set $TARGET_INTERFACE up
|
||||
|
||||
trap "cleanup_veth_interfaces; exit 1" SIGINT SIGTERM EXIT
|
||||
}
|
||||
|
||||
function cleanup_veth_interfaces() {
|
||||
# Cleanup veth interfaces
|
||||
# Note: removing one veth, removes the pair
|
||||
ip link delete $INITIATOR_INTERFACE
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ source $rootdir/test/iscsi_tgt/common.sh
|
||||
|
||||
timing_enter iscsi_tgt
|
||||
|
||||
# Network configuration
|
||||
create_veth_interfaces
|
||||
|
||||
# ISCSI_TEST_CORE_MASK is the biggest core mask specified by
|
||||
# any of the iscsi_tgt tests. Using this mask for the stub
|
||||
# ensures that if this mask spans CPU sockets, that we will
|
||||
@ -19,7 +22,7 @@ timing_enter iscsi_tgt
|
||||
# core 0) so there is no impact to the iscsi_tgt tests by
|
||||
# specifying the bigger core mask.
|
||||
start_stub "-s 2048 -i 0 -m $ISCSI_TEST_CORE_MASK"
|
||||
trap "kill_stub; exit 1" SIGINT SIGTERM EXIT
|
||||
trap "kill_stub; cleanup_veth_interfaces; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
run_test ./test/iscsi_tgt/calsoft/calsoft.sh
|
||||
run_test ./test/iscsi_tgt/filesystem/filesystem.sh
|
||||
@ -40,7 +43,7 @@ if [ $SPDK_TEST_RBD -eq 1 ]; then
|
||||
run_test ./test/iscsi_tgt/rbd/rbd.sh
|
||||
fi
|
||||
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
trap "cleanup_veth_interfaces; exit 1" SIGINT SIGTERM EXIT
|
||||
kill_stub
|
||||
|
||||
if [ $SPDK_TEST_NVMF -eq 1 ]; then
|
||||
@ -60,4 +63,6 @@ if [ $SPDK_TEST_ISCSI_INITIATOR -eq 1 ]; then
|
||||
run_test ./test/iscsi_tgt/initiator/initiator.sh
|
||||
fi
|
||||
|
||||
cleanup_veth_interfaces
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
timing_exit iscsi_tgt
|
||||
|
@ -402,7 +402,7 @@ def verify_get_interfaces(rpc_py):
|
||||
nics = json.loads(rpc.get_interfaces())
|
||||
nics_names = set(x["name"].encode('ascii', 'ignore') for x in nics)
|
||||
# parse ip link show to verify the get_interfaces result
|
||||
ifcfg_nics = set(re.findall("\S+:\s(\S+):\s<.*", check_output(["ip", "link", "show"])))
|
||||
ifcfg_nics = set(re.findall("\S+:\s(\S+?)(?:@\S+){0,1}:\s<.*", check_output(["ip", "link", "show"])))
|
||||
verify(nics_names == ifcfg_nics, 1, "get_interfaces returned {}".format(nics))
|
||||
print "verify_get_interfaces passed."
|
||||
|
||||
@ -486,7 +486,10 @@ if __name__ == "__main__":
|
||||
verify_initiator_groups_rpc_methods(rpc_py, rpc_param)
|
||||
verify_target_nodes_rpc_methods(rpc_py, rpc_param)
|
||||
verify_scsi_devices_rpc_methods(rpc_py)
|
||||
verify_iscsi_connection_rpc_methods(rpc_py)
|
||||
# This test is removed due to kernel routing packets in host stack
|
||||
# when handling connection between interfaces on same host.
|
||||
# It is enabled back in next patch in series adding namespaces.
|
||||
# verify_iscsi_connection_rpc_methods(rpc_py)
|
||||
verify_add_nvme_bdev_rpc_methods(rpc_py)
|
||||
except RpcException as e:
|
||||
print "{}. Exiting with status {}".format(e.message, e.retval)
|
||||
|
Loading…
Reference in New Issue
Block a user