3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
11 # bug number for skipped test:
12 ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT "
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skip test ARM testing until they are fixed
16 if [[ $(uname -m) = aarch64 ]]; then
17 # bug number for skipped test: LU-13704 LU-13701 LU-13701 LU-13701
18 ALWAYS_EXCEPT+=" 204 205 206 207 "
21 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
23 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
25 . $LUSTRE/tests/test-framework.sh
29 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
34 export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"}
35 [ ! -f "$LNETCTL" ] &&
36 export LNETCTL=$(which lnetctl 2> /dev/null)
37 [[ -z $LNETCTL ]] && skip "Need lnetctl"
41 if is_mounted $MOUNT || is_mounted $MOUNT2; then
42 cleanupall || error "Failed cleanup prior to test execution"
47 echo "Cleaning up LNet"
48 $LNETCTL lnet unconfigure 2>/dev/null
53 if module_loaded lnet ; then
54 cleanup_lnet || error "Failed to unload modules before test execution"
60 rm -f $TMP/sanity-dlc*
63 if $restore_mounts; then
64 setupall || error "Failed to setup Lustre after test execution"
65 elif $restore_modules; then
67 error "Couldn't load modules after test execution"
73 load_module ../libcfs/libcfs/libcfs
74 # Prevent local MODOPTS_LIBCFS being passed as part of environment
75 # variable to remote nodes
78 set_default_debug "neterror net nettrace malloc"
79 load_module ../lnet/lnet/lnet "$@"
81 LNDPATH=${LNDPATH:-"../lnet/klnds"}
82 if [ -z "$LNETLND" ]; then
84 o2ib*) LNETLND="o2iblnd/ko2iblnd" ;;
85 tcp*) LNETLND="socklnd/ksocklnd" ;;
86 *) local lnd="${NETTYPE%%[0-9]}lnd"
87 [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
88 LNETLND="$lnd/k$lnd" ||
89 LNETLND="socklnd/ksocklnd"
92 load_module ../lnet/klnds/$LNETLND
104 echo "ip netns exec $TESTNS $@"
105 ip netns exec $TESTNS "$@"
112 ip link add 'test1pl' type veth peer name $FAKE_IF netns $TESTNS
113 ip link set 'test1pl' up
114 do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF
115 do_ns ip link set $FAKE_IF up
119 (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
120 ip link show test1pl >& /dev/null && ip link del test1pl || return 0
124 echo "Loading LNet and configuring DLC"
126 do_lnetctl lnet configure
129 GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml
130 define_global_yaml() {
131 $LNETCTL export --backup >${GLOBAL_YAML_FILE} ||
132 error "Failed to export global yaml $?"
136 if lsmod | grep -q lnet; then
137 do_lnetctl lnet unconfigure ||
138 error "lnetctl lnet unconfigure failed $?"
139 do_lnetctl lnet configure ||
140 error "lnetctl lnet configure failed $?"
142 configure_dlc || error "configure_dlc failed $?"
147 append_global_yaml() {
148 [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
149 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
151 cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
154 create_base_yaml_file() {
158 compare_yaml_files() {
159 local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
160 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
162 ! [[ -e $expected ]] && echo "$expected not found" && return 1
163 ! [[ -e $actual ]] && echo "$actual not found" && return 1
164 diff -upN ${actual} ${expected} || rc=$?
174 local net="${nid//*@/}"
175 local addr="${nid//@*/}"
177 local num_re='[0-9]\+'
178 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
180 if [[ $net =~ gni[0-9]* ]]; then
181 [[ $addr =~ ${num_re} ]] && return 0
183 [[ $addr =~ ${ip_re} ]] && return 0
188 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
189 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
190 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
191 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
194 for nid in $primary_nids $secondary_nids; do
195 validate_nid "$nid" || error "Bad NID \"${nid}\""
200 validate_peer_nids() {
202 local nids_per_peer="$2"
204 local expect_p="$num_peers"
205 # The primary nid also shows up in the list of secondary nids
206 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
208 local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
209 local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
210 if [[ $expect_p -ne $actual_p ]]; then
212 error "Expected $expect_p but found $actual_p primary nids"
213 elif [[ $expect_s -ne $actual_s ]]; then
215 error "Expected $expect_s but found $actual_s secondary nids"
220 validate_gateway_nids() {
221 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
222 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
223 if [[ $expect_gw -ne $actual_gw ]]; then
225 error "Expected $expect_gw gateways but found $actual_gw gateways"
231 setup_netns || error "setup_netns failed with $?"
233 stack_trap 'cleanup_testsuite' EXIT
236 load_module ../lnet/lnet/lnet || error "Failed to load module rc = $?"
237 do_lnetctl lnet configure || error "lnet configure failed rc = $?"
239 reinit_dlc || return $?
240 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
241 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
242 create_base_yaml_file
243 compare_yaml_files || error "Configuration changed after import"
245 run_test 0 "Export empty config, import the config, compare"
248 local prim_nid="${1:+--prim_nid $1}"
249 local nid="${2:+--nid $2}"
251 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
253 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
254 $LNETCTL export --backup > $actual || error "export failed $?"
260 reinit_dlc || return $?
261 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
263 - primary nid: 1.1.1.1@tcp
269 compare_peer_add "1.1.1.1@tcp"
271 run_test 1 "Add peer with single nid (tcp)"
274 reinit_dlc || return $?
275 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
277 - primary nid: 2.2.2.2@o2ib
283 compare_peer_add "2.2.2.2@o2ib"
285 run_test 2 "Add peer with single nid (o2ib)"
288 reinit_dlc || return $?
289 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
291 - primary nid: 3.3.3.3@tcp
298 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
300 run_test 3 "Add peer with tcp primary o2ib secondary"
303 reinit_dlc || return $?
304 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
306 - primary nid: 4.4.4.4@tcp
315 echo "Add peer with nidrange (tcp)"
316 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
318 echo "Add peer with nidrange that overlaps primary nid (tcp)"
319 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
321 run_test 4 "Add peer with nidrange (tcp)"
324 reinit_dlc || return $?
325 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
327 - primary nid: 5.5.5.5@o2ib
337 echo "Add peer with nidrange (o2ib)"
338 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
340 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
341 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
343 run_test 5 "Add peer with nidrange (o2ib)"
346 reinit_dlc || return $?
347 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
349 - primary nid: 6.6.6.6@tcp
369 compare_peer_add "6.6.6.6@tcp" \
370 "6.6.[6-7].[0-4/2]@tcp,6.6.[1-4/2].[0-6/3]@o2ib,[6-12/4]@gni"
372 run_test 6 "Add peer with multiple nidranges"
375 local prim_nid="${1:+--prim_nid $1}"
376 local nid="${2:+--nid $2}"
378 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
380 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
381 $LNETCTL export --backup > $actual || error "export failed $?"
387 reinit_dlc || return $?
388 create_base_yaml_file
390 echo "Delete peer with single nid (tcp)"
391 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
392 compare_peer_del "7.7.7.7@tcp"
394 echo "Delete peer with single nid (o2ib)"
395 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
396 compare_peer_del "7.7.7.7@o2ib"
398 echo "Delete peer that has multiple nids (tcp)"
399 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
400 error "Peer add failed $?"
401 compare_peer_del "7.7.7.7@tcp"
403 echo "Delete peer that has multiple nids (o2ib)"
404 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
405 error "Peer add failed $?"
406 compare_peer_del "7.7.7.7@o2ib"
408 echo "Delete peer that has both tcp and o2ib nids"
409 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
410 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
411 error "Peer add failed $?"
412 compare_peer_del "7.7.7.7@tcp"
414 echo "Delete peer with single nid (gni)"
415 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
416 compare_peer_del "7@gni"
418 echo "Delete peer that has multiple nids (gni)"
419 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
420 error "Peer add failed $?"
421 compare_peer_del "7@gni"
423 echo "Delete peer that has tcp, o2ib and gni nids"
424 do_lnetctl peer add --prim_nid 7@gni \
425 --nid [8-12]@gni,7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
426 error "Peer add failed $?"
427 compare_peer_del "7@gni"
429 run_test 7 "Various peer delete tests"
432 reinit_dlc || return $?
434 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
436 - primary nid: 8.8.8.8@tcp
448 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
449 error "Peer add failed $?"
450 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
452 run_test 8 "Delete single secondary nid from peer (tcp)"
455 reinit_dlc || return $?
457 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
459 - primary nid: 9.9.9.9@tcp
466 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
467 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
468 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
470 run_test 9 "Delete all secondary nids from peer (tcp)"
473 reinit_dlc || return $?
475 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
477 - primary nid: 10.10.10.10@tcp
480 - nid: 10.10.10.10@tcp
481 - nid: 10.10.10.12@tcp
482 - nid: 10.10.10.13@tcp
483 - nid: 10.10.10.15@tcp
484 - nid: 10.10.10.16@tcp
487 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
488 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
489 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
491 run_test 10 "Delete single secondary nid from peer (o2ib)"
494 reinit_dlc || return $?
496 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
498 - primary nid: 11.11.11.11@tcp
501 - nid: 11.11.11.11@tcp
504 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
505 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
506 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
508 run_test 11 "Delete all secondary nids from peer (o2ib)"
511 reinit_dlc || return $?
513 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
515 - primary nid: 12.12.12.12@o2ib
518 - nid: 12.12.12.12@o2ib
519 - nid: 13.13.13.13@o2ib
520 - nid: 14.13.13.13@o2ib
521 - nid: 14.15.13.13@o2ib
523 - nid: 15.17.1.10@tcp
524 - nid: 15.17.1.20@tcp
527 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
528 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
529 error "Peer add failed $?"
530 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
532 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
535 reinit_dlc || return $?
537 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
539 - primary nid: 13.13.13.13@o2ib
542 - nid: 13.13.13.13@o2ib
545 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
546 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
547 error "Peer add failed $?"
548 compare_peer_del "13.13.13.13@o2ib" \
549 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
551 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
557 if [[ $net =~ gni* ]]; then
560 echo "${num}.${num}.${num}.${num}@${net}"
564 create_mr_peer_yaml() {
566 local secondary_nids="$2"
569 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
570 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
572 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
575 while [[ $created -lt $num_peers ]]; do
576 local primary=$(create_nid ${nidnum} ${net})
577 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
578 - primary nid: $primary
584 local start=$((nidnum + 1))
585 local end=$((nidnum + $secondary_nids))
586 for j in $(seq ${start} ${end}); do
587 local nid=$(create_nid $j ${net})
588 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
596 reinit_dlc || return $?
598 echo "Create single peer, single nid, using import"
599 create_mr_peer_yaml 1 0 tcp
600 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
601 error "Import failed $?"
603 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
606 echo "Delete single peer using import --del"
607 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
608 error "Import failed $?"
609 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
610 create_base_yaml_file
611 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
614 run_test 14 "import peer create/delete with single nid"
617 reinit_dlc || return $?
619 echo "Create multiple peers, single nid per peer, using import"
620 create_mr_peer_yaml 5 0 o2ib
621 # The ordering of nids for this use-case is non-deterministic, so we
622 # we can't just diff the expected/actual output.
623 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
624 error "Import failed $?"
625 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
626 validate_peer_nids 5 0
628 echo "Delete multiple peers, single nid per peer, using import --del"
629 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
630 error "Import failed $?"
631 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
632 create_base_yaml_file
633 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
636 run_test 15 "import multi peer create/delete with single nid per peer"
639 reinit_dlc || return $?
641 echo "Create single peer, multiple nids, using import"
642 create_mr_peer_yaml 1 5 tcp
643 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
644 error "Import failed $?"
645 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
646 validate_peer_nids 1 5
648 echo "Delete single peer, multiple nids, using import --del"
649 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
650 error "Import failed $?"
651 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
652 create_base_yaml_file
653 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
656 run_test 16 "import peer create/delete with multiple nids"
659 reinit_dlc || return $?
661 echo "Create multiple peers, multiple nids per peer, using import"
662 create_mr_peer_yaml 5 7 o2ib
663 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
664 error "Import failed $?"
665 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
666 validate_peer_nids 5 7
668 echo "Delete multiple peers, multiple nids per peer, using import --del"
669 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
670 error "Import failed $?"
671 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
672 create_base_yaml_file
673 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
676 run_test 17 "import multi peer create/delete with multiple nids"
679 reinit_dlc || return $?
681 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
683 - primary nid: 1.1.1.1@tcp
692 echo "Import peer with 5 nids"
693 cat $TMP/sanity-lnet-$testnum-expected.yaml
694 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
695 error "Import failed $?"
696 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
698 - primary nid: 1.1.1.1@tcp
705 echo "Delete three of the nids"
706 cat $TMP/sanity-lnet-$testnum-expected.yaml
707 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
708 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
710 - primary nid: 1.1.1.1@tcp
716 echo "Check peer has expected nids remaining"
717 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
721 run_test 18a "Delete a subset of nids from a single peer using import --del"
724 reinit_dlc || return $?
726 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
728 - primary nid: 1.1.1.1@tcp
736 - primary nid: 6.6.6.6@o2ib
745 echo "Import two peers with 5 nids each"
746 cat $TMP/sanity-lnet-$testnum-expected.yaml
747 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
748 error "Import failed $?"
749 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
751 - primary nid: 1.1.1.1@tcp
757 - primary nid: 6.6.6.6@o2ib
764 echo "Delete three of the nids from each peer"
765 cat $TMP/sanity-lnet-$testnum-expected.yaml
766 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
767 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
769 - primary nid: 6.6.6.6@o2ib
774 - primary nid: 1.1.1.1@tcp
781 echo "Check peers have expected nids remaining"
782 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
784 validate_peer_nids 2 1
786 run_test 18b "Delete multiple nids from multiple peers using import --del"
789 reinit_dlc || return $?
790 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
792 - primary nid: 19@gni
798 compare_peer_add "19@gni"
800 run_test 19 "Add peer with single nid (gni)"
803 reinit_dlc || return $?
804 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
806 - primary nid: 20@gni
810 - nid: 20.20.20.20@tcp
811 - nid: 20.20.20.20@o2ib
814 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
816 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
819 reinit_dlc || return $?
820 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
822 - primary nid: 21@gni
832 echo"Add peer with nidrange (gni)"
833 compare_peer_add "21@gni" "[22-25]@gni" || error
834 echo "Add peer with nidrange that overlaps primary nid (gni)"
835 compare_peer_add "21@gni" "[21-25]@gni"
837 run_test 21 "Add peer with nidrange (gni)"
840 reinit_dlc || return $?
841 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
843 - primary nid: 22@gni
854 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
855 error "Peer add failed $?"
856 compare_peer_del "22@gni" "26@gni"
858 run_test 22 "Delete single secondary nid from peer (gni)"
861 reinit_dlc || return $?
862 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
864 - primary nid: 23@gni
871 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
872 error "Peer add failed $?"
873 compare_peer_del "23@gni" "[25-29]@gni"
875 run_test 23 "Delete all secondary nids from peer (gni)"
878 reinit_dlc || return $?
879 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
881 - primary nid: 24@gni
886 - nid: 13.13.13.13@o2ib
887 - nid: 14.13.13.13@o2ib
888 - nid: 14.15.13.13@o2ib
890 - nid: 15.17.1.10@tcp
891 - nid: 15.17.1.20@tcp
894 do_lnetctl peer add --prim_nid 24@gni \
895 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp,[5-12/6]@gni ||
896 error "Peer add failed $?"
897 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
899 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
902 reinit_dlc || return $?
903 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
905 - primary nid: 25@gni
911 do_lnetctl peer add --prim_nid 25@gni \
912 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
913 error "Peer add failed $?"
914 compare_peer_del "25@gni" \
915 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
917 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
920 reinit_dlc || return $?
922 echo "Invalid prim_nid - peer add"
923 do_lnetctl peer add --prim_nid foobar &&
924 error "Command should have failed"
926 echo "Invalid prim_nid - peer del"
927 do_lnetctl peer del --prim_nid foobar &&
928 error "Command should have failed"
930 echo "Delete non-existing peer"
931 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
932 error "Command should have failed"
934 echo "Don't provide mandatory arguments peer del"
935 do_lnetctl peer del --nid 1.1.1.1@tcp &&
936 error "Command should have failed"
938 echo "Don't provide mandatory arguments peer add"
939 do_lnetctl peer add &&
940 error "Command should have failed"
942 echo "Invalid secondary nids"
943 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
944 error "Command should have failed"
946 echo "Exceed max nids per peer"
947 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
948 error "Command should have failed"
950 echo "Invalid net type"
951 do_lnetctl peer add --prim_nid 1@foo &&
952 error "Command should have failed"
954 echo "Invalid nid format"
955 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
958 for nid in ${invalid_nids}; do
959 echo "Check invalid primary nid - '$nid'"
960 do_lnetctl peer add --prim_nid $nid &&
961 error "Command should have failed"
964 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
965 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
966 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
969 for nidstr in ${invalid_strs}; do
970 echo "Check invalid nidstring - '$nidstr'"
971 do_lnetctl peer add --nid $nidstr &&
972 error "Command should have failed"
975 echo "Add non-local gateway"
976 do_lnetctl route add --net tcp --gateway 1@gni &&
977 error "Command should have failed"
981 run_test 99a "Check various invalid inputs to lnetctl peer"
984 reinit_dlc || return $?
986 create_base_yaml_file
988 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
990 - primary nid: 99.99.99.99@tcp
993 - nid: 99.99.99.99@tcp
995 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
996 error "import should have failed"
997 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
1000 run_test 99b "Invalid value for Multi-Rail in yaml import"
1004 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1012 if ! lsmod | grep -q ksocklnd ; then
1013 load_module ../lnet/klnds/socklnd/ksocklnd ||
1014 error "Can't load ksocklnd.ko"
1017 do_lnetctl net add --net ${net} --if ${if} ||
1018 error "Failed to add net ${net} on if ${if}"
1021 compare_route_add() {
1025 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1027 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1028 error "route add failed $?"
1029 # CPT configuration is pruned from the exported yaml, since the default
1030 # can vary across test systems (unlike default values for things like
1031 # peer_credits, peer_timeout, etc.)
1032 $LNETCTL export --backup | grep -v CPT > $actual ||
1033 error "export failed $?"
1034 validate_gateway_nids
1039 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1040 reinit_dlc || return $?
1041 add_net "tcp" "eth0"
1042 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1051 peer_buffer_credits: 0
1055 gateway: 7.7.7.7@tcp
1058 health_sensitivity: 1
1060 - primary nid: 7.7.7.7@tcp
1066 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
1069 run_test 100 "Add route with single gw (tcp)"
1072 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1073 reinit_dlc || return $?
1074 add_net "tcp" "eth0"
1075 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1084 peer_buffer_credits: 0
1088 gateway: 8.8.8.10@tcp
1091 health_sensitivity: 1
1093 gateway: 8.8.8.9@tcp
1096 health_sensitivity: 1
1098 gateway: 8.8.8.8@tcp
1101 health_sensitivity: 1
1103 - primary nid: 8.8.8.9@tcp
1107 - primary nid: 8.8.8.10@tcp
1111 - primary nid: 8.8.8.8@tcp
1117 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
1119 run_test 101 "Add route with multiple gw (tcp)"
1121 compare_route_del() {
1125 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1127 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1128 error "route del failed $?"
1129 $LNETCTL export --backup > $actual ||
1130 error "export failed $?"
1131 validate_gateway_nids
1135 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1136 reinit_dlc || return $?
1137 add_net "tcp" "eth0"
1138 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1139 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
1140 error "route add failed $?"
1141 compare_route_del "tcp102" "102.102.102.102@tcp"
1143 run_test 102 "Delete route with single gw (tcp)"
1146 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1147 reinit_dlc || return $?
1148 add_net "tcp" "eth0"
1149 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1150 do_lnetctl route add --net tcp103 \
1151 --gateway 103.103.103.[103-120/4]@tcp ||
1152 error "route add failed $?"
1153 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
1155 run_test 103 "Delete route with multiple gw (tcp)"
1157 ### load lnet in default namespace, configure in target namespace
1160 cleanup_lnet || exit 1
1161 load_lnet "networks=\"\""
1162 do_ns $LNETCTL lnet configure --all || exit 1
1163 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1165 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1168 cleanup_lnet || exit 1
1169 load_lnet "networks=tcp($FAKE_IF)"
1170 do_ns $LNETCTL lnet configure --all || exit 1
1171 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1173 run_test 201 "load lnet using networks module options in a non-default namespace"
1176 cleanup_lnet || exit 1
1177 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1178 do_ns $LNETCTL lnet configure --all || exit 1
1179 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1181 run_test 202 "load lnet using ip2nets in a non-default namespace"
1184 ### Add the interfaces in the target namespace
1187 cleanup_lnet || exit 1
1189 do_lnetctl lnet configure || exit 1
1190 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1192 run_test 203 "add a network using an interface in the non-default namespace"
1194 LNET_PARAMS_FILE="$TMP/$TESTSUITE.parameters"
1195 function save_lnet_params() {
1196 $LNETCTL global show | egrep -v '^global:$' |
1197 sed 's/://' > $LNET_PARAMS_FILE
1200 function restore_lnet_params() {
1202 while read param value; do
1203 [[ $param == max_intf ]] && continue
1204 [[ $param == lnd_timeout ]] && continue
1205 $LNETCTL set ${param} ${value} ||
1206 error "Failed to restore ${param} to ${value}"
1207 done < $LNET_PARAMS_FILE
1210 function lnet_health_pre() {
1213 # Lower transaction timeout to speed up test execution
1214 $LNETCTL set transaction_timeout 10 ||
1215 error "Failed to set transaction_timeout $?"
1217 # Increase recovery interval so we have time to capture health values
1218 $LNETCTL set recovery_interval 20 ||
1219 error "Failed to set recovery_interval $?"
1221 RETRY_PARAM=$($LNETCTL global show | awk '/retry_count/{print $NF}')
1222 RSND_PRE=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1223 LO_HVAL_PRE=$($LNETCTL net show -v 2 | awk '/health value/{print $NF}' |
1224 xargs echo | sed 's/ /+/g' | bc -l)
1226 local my_nid=$($LCTL list_nids | head -n 1)
1228 RMT_HVAL_PRE=$($LNETCTL peer show --nid $my_nid -v 2 2>/dev/null |
1229 awk '/health value/{print $NF}' | xargs echo |
1230 sed 's/ /+/g' | bc -l)
1232 # Might not have any peers so initialize to zero.
1233 RMT_HVAL_PRE=${RMT_HVAL_PRE:-0}
1238 function lnet_health_post() {
1239 RSND_POST=$($LNETCTL stats show | awk '/resend_count/{print $NF}')
1240 LO_HVAL_POST=$($LNETCTL net show -v 2 |
1241 awk '/health value/{print $NF}' |
1242 xargs echo | sed 's/ /+/g' | bc -l)
1244 local my_nid=$($LCTL list_nids | head -n 1)
1246 RMT_HVAL_POST=$($LNETCTL peer show --nid $my_nid -v 2 2>/dev/null |
1247 awk '/health value/{print $NF}' | xargs echo |
1248 sed 's/ /+/g' | bc -l)
1250 # Might not have any peers so initialize to zero.
1251 RMT_HVAL_POST=${RMT_HVAL_POST:-0}
1254 echo "Pre resends: $RSND_PRE" &&
1255 echo "Post resends: $RSND_POST" &&
1256 echo "Resends delta: $((RSND_POST - RSND_PRE))" &&
1257 echo "Pre local health: $LO_HVAL_PRE" &&
1258 echo "Post local health: $LO_HVAL_POST" &&
1259 echo "Pre remote health: $RMT_HVAL_PRE" &&
1260 echo "Post remote health: $RMT_HVAL_POST"
1267 function check_no_resends() {
1268 echo "Check that no resends took place"
1269 [[ $RSND_POST -ne $RSND_PRE ]] &&
1270 error "Found resends: $RSND_POST != $RSND_PRE"
1275 function check_resends() {
1276 local delta=$((RSND_POST - RSND_PRE))
1278 echo "Check that $RETRY_PARAM resends took place"
1279 [[ $delta -ne $RETRY_PARAM ]] &&
1280 error "Expected $RETRY_PARAM resends found $delta"
1285 function check_no_local_health() {
1286 echo "Check that local NI health is unchanged"
1287 [[ $LO_HVAL_POST -ne $LO_HVAL_PRE ]] &&
1288 error "Local health changed: $LO_HVAL_POST != $LO_HVAL_PRE"
1293 function check_local_health() {
1294 echo "Check that local NI health has been changed"
1295 [[ $LO_HVAL_POST -eq $LO_HVAL_PRE ]] &&
1296 error "Local health unchanged: $LO_HVAL_POST == $LO_HVAL_PRE"
1301 function check_no_remote_health() {
1302 echo "Check that remote NI health is unchanged"
1303 [[ $RMT_HVAL_POST -ne $RMT_HVAL_PRE ]] &&
1304 error "Remote health changed: $RMT_HVAL_POST != $RMT_HVAL_PRE"
1309 function check_remote_health() {
1310 echo "Check that remote NI health has been changed"
1311 [[ $RMT_HVAL_POST -eq $RMT_HVAL_PRE ]] &&
1312 error "Remote health unchanged: $RMT_HVAL_POST == $RMT_HVAL_PRE"
1317 # See lnet/lnet/lib-msg.c:lnet_health_check()
1318 LNET_LOCAL_RESEND_STATUSES="local_interrupt local_dropped local_aborted"
1319 LNET_LOCAL_RESEND_STATUSES+=" local_no_route local_timeout"
1320 LNET_LOCAL_NO_RESEND_STATUSES="local_error"
1322 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1323 reinit_dlc || return $?
1324 add_net "tcp" "eth0" || return $?
1326 lnet_health_pre || return $?
1329 for hstatus in ${LNET_LOCAL_RESEND_STATUSES} \
1330 ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1331 echo "Simulate $hstatus"
1332 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e ${hstatus}
1333 do_lnetctl discover $($LCTL list_nids | head -n 1) &&
1334 error "Should have failed"
1335 $LCTL net_drop_del *
1340 check_no_resends || return $?
1341 check_no_local_health || return $?
1345 run_test 204 "Check no health or resends for single-rail local failures"
1348 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1351 for hstatus in ${LNET_LOCAL_RESEND_STATUSES}; do
1352 reinit_dlc || return $?
1353 add_net "tcp" "eth0" || return $?
1354 add_net "tcp1" "eth0" || return $?
1356 echo "Simulate $hstatus"
1359 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e ${hstatus}
1360 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e ${hstatus}
1361 do_lnetctl discover $($LCTL list_nids | head -n 1) &&
1362 error "Should have failed"
1363 $LCTL net_drop_del *
1367 check_resends || return $?
1368 check_local_health || return $?
1371 for hstatus in ${LNET_LOCAL_NO_RESEND_STATUSES}; do
1372 reinit_dlc || return $?
1373 add_net "tcp" "eth0" || return $?
1374 add_net "tcp1" "eth0" || return $?
1376 echo "Simulate $hstatus"
1377 lnet_health_pre || return $?
1379 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e ${hstatus}
1380 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e ${hstatus}
1381 do_lnetctl discover $($LCTL list_nids | head -n 1) &&
1382 error "Should have failed"
1383 $LCTL net_drop_del *
1387 check_no_resends || return $?
1388 check_local_health || return $?
1393 run_test 205 "Check health and resends for multi-rail local failures"
1395 # See lnet/lnet/lib-msg.c:lnet_health_check()
1396 LNET_REMOTE_RESEND_STATUSES="remote_dropped"
1397 LNET_REMOTE_NO_RESEND_STATUSES="remote_error remote_timeout network_timeout"
1399 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1400 reinit_dlc || return $?
1401 add_net "tcp" "eth0" || return $?
1403 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
1404 error "failed to discover myself"
1406 lnet_health_pre || return $?
1409 for hstatus in ${LNET_REMOTE_RESEND_STATUSES} \
1410 ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1411 echo "Simulate $hstatus"
1412 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e ${hstatus}
1413 do_lnetctl discover $($LCTL list_nids | head -n 1) &&
1414 error "Should have failed"
1415 $LCTL net_drop_del *
1420 check_no_resends || return $?
1421 check_no_local_health || return $?
1422 check_no_remote_health || return $?
1426 run_test 206 "Check no health or resends for single-rail remote failures"
1429 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1432 for hstatus in ${LNET_REMOTE_RESEND_STATUSES}; do
1433 reinit_dlc || return $?
1434 add_net "tcp" "eth0" || return $?
1435 add_net "tcp1" "eth0" || return $?
1437 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
1438 error "failed to discover myself"
1440 echo "Simulate $hstatus"
1441 lnet_health_pre || return $?
1442 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e ${hstatus}
1443 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e ${hstatus}
1444 do_lnetctl discover $($LCTL list_nids | head -n 1) &&
1445 error "Should have failed"
1446 $LCTL net_drop_del *
1450 check_resends || return $?
1451 check_no_local_health || return $?
1452 check_remote_health || return $?
1454 for hstatus in ${LNET_REMOTE_NO_RESEND_STATUSES}; do
1455 reinit_dlc || return $?
1456 add_net "tcp" "eth0" || return $?
1457 add_net "tcp1" "eth0" || return $?
1459 do_lnetctl discover $($LCTL list_nids | head -n 1) ||
1460 error "failed to discover myself"
1462 echo "Simulate $hstatus"
1463 lnet_health_pre || return $?
1464 $LCTL net_drop_add -s *@tcp -d *@tcp -m GET -r 1 -e ${hstatus}
1465 $LCTL net_drop_add -s *@tcp1 -d *@tcp1 -m GET -r 1 -e ${hstatus}
1466 do_lnetctl discover $($LCTL list_nids | head -n 1) &&
1467 error "Should have failed"
1468 $LCTL net_drop_del *
1472 check_no_resends || return $?
1473 check_no_local_health || return $?
1474 check_remote_health || return $?
1479 run_test 207 "Check health and resends for multi-rail remote errors"
1484 local out=$TMP/$tfile
1485 local prefix=/usr/include/linux/lnet
1487 # We use a hard coded prefix so that this test will not fail
1490 if ! which $CC > /dev/null 2>&1; then
1491 skip_env "$CC is not installed"
1494 cleanup_lnet || exit 1
1497 if ! [[ -d $prefix ]]; then
1498 # Assume we're running in tree and fixup the include path.
1499 prefix=$LUSTRE/../lnet/include/uapi/linux/lnet
1502 for header in $prefix/*.h; do
1503 if ! [[ -f "$header" ]]; then
1507 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
1508 error "cannot compile '$header'"
1512 run_test 300 "packaged LNet UAPI headers can be compiled"