Whamcloud - gitweb
LU-12236 tests: add tests for LNET network namespace 66/35666/10
authorAurelien Degremont <degremoa@amazon.com>
Thu, 1 Aug 2019 12:48:05 +0000 (12:48 +0000)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Sep 2019 01:52:01 +0000 (01:52 +0000)
This patch adds tests for LNET for this feature.

Test-Parameters: trivial testlist=sanity-lnet
Signed-off-by: Aurelien Degremont <degremoa@amazon.com>
Change-Id: I2320e5da1beef30be5dcca9529fa838fc9304876
Reviewed-on: https://review.whamcloud.com/35666
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/Makefile.am
lustre/tests/sanity-lnet.sh [new file with mode: 0755]
lustre/tests/test-groups/regression

index f65c116..bd81d6e 100644 (file)
@@ -39,7 +39,7 @@ noinst_SCRIPTS += posix.sh sanity-scrub.sh scrub-performance.sh ha.sh
 noinst_SCRIPTS += sanity-lfsck.sh lfsck-performance.sh
 noinst_SCRIPTS += resolveip
 noinst_SCRIPTS += sanity-hsm.sh sanity-lsnapshot.sh sanity-pfl.sh sanity-flr.sh
-noinst_SCRIPTS += sanity-dom.sh sanity-pcc.sh dom-performance.sh
+noinst_SCRIPTS += sanity-dom.sh sanity-pcc.sh dom-performance.sh sanity-lnet.sh
 nobase_noinst_SCRIPTS = cfg/local.sh
 nobase_noinst_SCRIPTS += test-groups/regression test-groups/regression-mpi
 nobase_noinst_SCRIPTS += acl/make-tree acl/run cfg/ncli.sh
diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh
new file mode 100755 (executable)
index 0000000..3ed3c07
--- /dev/null
@@ -0,0 +1,131 @@
+#!/bin/bash
+#
+# Run select tests by setting ONLY, or as arguments to the script.
+# Skip specific tests by setting EXCEPT.
+#
+
+set -e
+
+ONLY=${ONLY:-"$*"}
+# bug number for skipped test:
+ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT "
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+
+. $LUSTRE/tests/test-framework.sh
+CLEANUP=${CLEANUP:-:}
+SETUP=${SETUP:-:}
+init_test_env $@
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
+
+build_test_filter
+
+export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"}
+[ ! -f "$LNETCTL" ] &&
+       export LNETCTL=$(which lnetctl 2> /dev/null)
+[[ -z $LNETCTL ]] && skip "Need lnetctl"
+
+load_lnet() {
+       load_module ../libcfs/libcfs/libcfs
+       # Prevent local MODOPTS_LIBCFS being passed as part of environment
+       # variable to remote nodes
+       unset MODOPTS_LIBCFS
+
+       set_default_debug
+       load_module ../lnet/lnet/lnet "$@"
+
+       LNDPATH=${LNDPATH:-"../lnet/klnds"}
+       if [ -z "$LNETLND" ]; then
+               case $NETTYPE in
+               o2ib*)  LNETLND="o2iblnd/ko2iblnd" ;;
+               tcp*)   LNETLND="socklnd/ksocklnd" ;;
+               *)      local lnd="${NETTYPE%%[0-9]}lnd"
+                       [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
+                               LNETLND="$lnd/k$lnd" ||
+                               LNETLND="socklnd/ksocklnd"
+               esac
+       fi
+       load_module ../lnet/klnds/$LNETLND
+}
+
+cleanup_lnet() {
+       $LNETCTL lnet unconfigure 2>/dev/null
+       unload_modules
+}
+
+TESTNS='test_ns'
+RUN_NS="ip netns exec $TESTNS"
+FAKE_IF="test1pg"
+FAKE_IP="10.1.2.3"
+
+setup_netns() {
+       cleanup_netns
+
+       ip netns add $TESTNS
+       ip link add 'test1pl' type veth peer name $FAKE_IF netns $TESTNS
+       ip link set 'test1pl' up
+       $RUN_NS ip addr add "${FAKE_IP}/31" dev $FAKE_IF
+       $RUN_NS ip link set $FAKE_IF up
+}
+
+cleanup_netns() {
+       (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
+       if ip link show test1pl >/dev/null 2>&1; then
+               ip link del test1pl
+       fi
+}
+
+cleanupall -f
+
+setup_netns
+load_lnet
+
+test_1() {
+       $LNETCTL lnet configure
+}
+run_test 1 "configure lnet with lnetctl"
+
+
+### load lnet in default namespace, configure in target namespace
+
+test_2() {
+       cleanup_lnet || exit 1
+       load_lnet "networks=\"\""
+       $RUN_NS $LNETCTL lnet configure --all || exit 1
+       $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
+}
+run_test 2 "load lnet w/o module option, configure in a non-default namespace"
+
+test_3() {
+       cleanup_lnet || exit 1
+       load_lnet "networks=tcp($FAKE_IF)"
+       $RUN_NS $LNETCTL lnet configure --all || exit 1
+       $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
+}
+run_test 3 "load lnet using networks module options in a non-default namespace"
+
+test_4() {
+       cleanup_lnet || exit 1
+       load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
+       $RUN_NS $LNETCTL lnet configure --all || exit 1
+       $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
+}
+run_test 4 "load lnet using ip2nets in a non-default namespace"
+
+
+### Add the interfaces in the target namespace
+
+test_5() {
+       cleanup_lnet || exit 1
+       load_lnet
+       $LNETCTL lnet configure || exit 1
+       $RUN_NS $LNETCTL net add --net tcp0 --if $FAKE_IF
+}
+run_test 5 "add a network using an interface in the non-default namespace"
+
+cleanup_netns
+cleanup_lnet
+exit_status
index fb1d17c..b4a6da6 100644 (file)
@@ -26,3 +26,4 @@ sanity-hsm
 sanity-lsnapshot
 sanity-pfl
 sanity-pcc
+sanity-lnet