3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 # bug number for skipped test:
11 ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT "
12 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
17 . $LUSTRE/tests/test-framework.sh
21 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
26 export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"}
27 [ ! -f "$LNETCTL" ] &&
28 export LNETCTL=$(which lnetctl 2> /dev/null)
29 [[ -z $LNETCTL ]] && skip "Need lnetctl"
33 if is_mounted $MOUNT || is_mounted $MOUNT2; then
34 cleanupall || error "Failed cleanup prior to test execution"
39 echo "Cleaning up LNet"
40 $LNETCTL lnet unconfigure 2>/dev/null
45 if module_loaded lnet ; then
46 cleanup_lnet || error "Failed to unload modules before test execution"
52 rm -f $TMP/sanity-dlc*
55 if $restore_mounts; then
56 setupall || error "Failed to setup Lustre after test execution"
57 elif $restore_modules; then
59 error "Couldn't load modules after test execution"
65 load_module ../libcfs/libcfs/libcfs
66 # Prevent local MODOPTS_LIBCFS being passed as part of environment
67 # variable to remote nodes
71 load_module ../lnet/lnet/lnet "$@"
73 LNDPATH=${LNDPATH:-"../lnet/klnds"}
74 if [ -z "$LNETLND" ]; then
76 o2ib*) LNETLND="o2iblnd/ko2iblnd" ;;
77 tcp*) LNETLND="socklnd/ksocklnd" ;;
78 *) local lnd="${NETTYPE%%[0-9]}lnd"
79 [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
80 LNETLND="$lnd/k$lnd" ||
81 LNETLND="socklnd/ksocklnd"
84 load_module ../lnet/klnds/$LNETLND
96 echo "ip netns exec $TESTNS $@"
97 ip netns exec $TESTNS "$@"
104 ip link add 'test1pl' type veth peer name $FAKE_IF netns $TESTNS
105 ip link set 'test1pl' up
106 do_ns ip addr add "${FAKE_IP}/31" dev $FAKE_IF
107 do_ns ip link set $FAKE_IF up
111 (ip netns list | grep -q $TESTNS) && ip netns del $TESTNS
112 if ip link show test1pl >/dev/null 2>&1; then
118 echo "Loading LNet and configuring DLC"
120 do_lnetctl lnet configure
123 GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml
124 define_global_yaml() {
125 $LNETCTL export --backup >${GLOBAL_YAML_FILE} ||
126 error "Failed to export global yaml $?"
130 if lsmod | grep -q lnet; then
131 do_lnetctl lnet unconfigure ||
132 error "lnetctl lnet unconfigure failed $?"
133 do_lnetctl lnet configure ||
134 error "lnetctl lnet configure failed $?"
136 configure_dlc || error "configure_dlc failed $?"
141 append_global_yaml() {
142 [[ ! -e ${GLOBAL_YAML_FILE} ]] &&
143 error "Missing global yaml at ${GLOBAL_YAML_FILE}"
145 cat ${GLOBAL_YAML_FILE} >> $TMP/sanity-lnet-$testnum-expected.yaml
148 create_base_yaml_file() {
152 compare_yaml_files() {
153 local expected="$TMP/sanity-lnet-$testnum-expected.yaml"
154 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
156 ! [[ -e $expected ]] && echo "$expected not found" && return 1
157 ! [[ -e $actual ]] && echo "$actual not found" && return 1
158 diff -upN ${actual} ${expected} || rc=$?
168 local net="${nid//*@/}"
169 local addr="${nid//@*/}"
171 local num_re='[0-9]\+'
172 local ip_re="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
174 if [[ $net =~ gni[0-9]* ]]; then
175 [[ $addr =~ ${num_re} ]] && return 0
177 [[ $addr =~ ${ip_re} ]] && return 0
182 local yfile=$TMP/sanity-lnet-$testnum-actual.yaml
183 local primary_nids=$(awk '/- primary nid:/{print $NF}' $yfile | xargs echo)
184 local secondary_nids=$(awk '/- nid:/{print $NF}' $yfile | xargs echo)
185 local gateway_nids=$(awk '/gateway:/{print $NF}' $yfile | xargs echo)
188 for nid in $primary_nids $secondary_nids; do
189 validate_nid "$nid" || error "Bad NID \"${nid}\""
194 validate_peer_nids() {
196 local nids_per_peer="$2"
198 local expect_p="$num_peers"
199 # The primary nid also shows up in the list of secondary nids
200 local expect_s="$(($num_peers + $(($nids_per_peer*$num_peers))))"
202 local actual_p=$(grep -c -- '- primary nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
203 local actual_s=$(grep -c -- '- nid:' $TMP/sanity-lnet-$testnum-actual.yaml)
204 if [[ $expect_p -ne $actual_p ]]; then
206 error "Expected $expect_p but found $actual_p primary nids"
207 elif [[ $expect_s -ne $actual_s ]]; then
209 error "Expected $expect_s but found $actual_s secondary nids"
214 validate_gateway_nids() {
215 local expect_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-expected.yaml)
216 local actual_gw=$(grep -c -- 'gateway:' $TMP/sanity-lnet-$testnum-actual.yaml)
217 if [[ $expect_gw -ne $actual_gw ]]; then
219 error "Expected $expect_gw gateways but found $actual_gw gateways"
225 setup_netns || error "setup_netns failed with $?"
227 stack_trap 'cleanup_testsuite' EXIT
230 load_module ../lnet/lnet/lnet || error "Failed to load module rc = $?"
231 do_lnetctl lnet configure || error "lnet configure failed rc = $?"
233 reinit_dlc || return $?
234 do_lnetctl import < ${GLOBAL_YAML_FILE} || error "Import failed $?"
235 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
236 create_base_yaml_file
237 compare_yaml_files || error "Configuration changed after import"
239 run_test 0 "Export empty config, import the config, compare"
242 local prim_nid="${1:+--prim_nid $1}"
243 local nid="${2:+--nid $2}"
245 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
247 do_lnetctl peer add ${prim_nid} ${nid} || error "peer add failed $?"
248 $LNETCTL export --backup > $actual || error "export failed $?"
254 reinit_dlc || return $?
255 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
257 - primary nid: 1.1.1.1@tcp
263 compare_peer_add "1.1.1.1@tcp"
265 run_test 1 "Add peer with single nid (tcp)"
268 reinit_dlc || return $?
269 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
271 - primary nid: 2.2.2.2@o2ib
277 compare_peer_add "2.2.2.2@o2ib"
279 run_test 2 "Add peer with single nid (o2ib)"
282 reinit_dlc || return $?
283 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
285 - primary nid: 3.3.3.3@tcp
292 compare_peer_add "3.3.3.3@tcp" "3.3.3.3@o2ib"
294 run_test 3 "Add peer with tcp primary o2ib secondary"
297 reinit_dlc || return $?
298 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
300 - primary nid: 4.4.4.4@tcp
309 echo "Add peer with nidrange (tcp)"
310 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-3]@tcp"
312 echo "Add peer with nidrange that overlaps primary nid (tcp)"
313 compare_peer_add "4.4.4.4@tcp" "4.4.4.[1-4]@tcp"
315 run_test 4 "Add peer with nidrange (tcp)"
318 reinit_dlc || return $?
319 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
321 - primary nid: 5.5.5.5@o2ib
331 echo "Add peer with nidrange (o2ib)"
332 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
334 echo "Add peer with nidranage that overlaps primary nid (o2ib)"
335 compare_peer_add "5.5.5.5@o2ib" "5.5.5.[1-4]@o2ib"
337 run_test 5 "Add peer with nidrange (o2ib)"
340 reinit_dlc || return $?
341 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
343 - primary nid: 6.6.6.6@tcp
363 compare_peer_add "6.6.6.6@tcp" \
364 "6.6.[6-7].[0-4/2]@tcp,6.6.[1-4/2].[0-6/3]@o2ib,[6-12/4]@gni"
366 run_test 6 "Add peer with multiple nidranges"
369 local prim_nid="${1:+--prim_nid $1}"
370 local nid="${2:+--nid $2}"
372 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
374 do_lnetctl peer del ${prim_nid} ${nid} || error "peer del failed $?"
375 $LNETCTL export --backup > $actual || error "export failed $?"
381 reinit_dlc || return $?
382 create_base_yaml_file
384 echo "Delete peer with single nid (tcp)"
385 do_lnetctl peer add --prim_nid 7.7.7.7@tcp || error "Peer add failed $?"
386 compare_peer_del "7.7.7.7@tcp"
388 echo "Delete peer with single nid (o2ib)"
389 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib || error "Peer add failed $?"
390 compare_peer_del "7.7.7.7@o2ib"
392 echo "Delete peer that has multiple nids (tcp)"
393 do_lnetctl peer add --prim_nid 7.7.7.7@tcp --nid 7.7.7.[8-12]@tcp ||
394 error "Peer add failed $?"
395 compare_peer_del "7.7.7.7@tcp"
397 echo "Delete peer that has multiple nids (o2ib)"
398 do_lnetctl peer add --prim_nid 7.7.7.7@o2ib --nid 7.7.7.[8-12]@o2ib ||
399 error "Peer add failed $?"
400 compare_peer_del "7.7.7.7@o2ib"
402 echo "Delete peer that has both tcp and o2ib nids"
403 do_lnetctl peer add --prim_nid 7.7.7.7@tcp \
404 --nid 7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
405 error "Peer add failed $?"
406 compare_peer_del "7.7.7.7@tcp"
408 echo "Delete peer with single nid (gni)"
409 do_lnetctl peer add --prim_nid 7@gni || error "Peer add failed $?"
410 compare_peer_del "7@gni"
412 echo "Delete peer that has multiple nids (gni)"
413 do_lnetctl peer add --prim_nid 7@gni --nid [8-12]@gni ||
414 error "Peer add failed $?"
415 compare_peer_del "7@gni"
417 echo "Delete peer that has tcp, o2ib and gni nids"
418 do_lnetctl peer add --prim_nid 7@gni \
419 --nid [8-12]@gni,7.7.7.[9-12]@tcp,7.7.7.[13-15]@o2ib ||
420 error "Peer add failed $?"
421 compare_peer_del "7@gni"
423 run_test 7 "Various peer delete tests"
426 reinit_dlc || return $?
428 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
430 - primary nid: 8.8.8.8@tcp
442 do_lnetctl peer add --prim_nid 8.8.8.8@tcp --nid 8.8.8.[10-15]@tcp ||
443 error "Peer add failed $?"
444 compare_peer_del "8.8.8.8@tcp" "8.8.8.13@tcp"
446 run_test 8 "Delete single secondary nid from peer (tcp)"
449 reinit_dlc || return $?
451 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
453 - primary nid: 9.9.9.9@tcp
460 do_lnetctl peer add --prim_nid 9.9.9.9@tcp \
461 --nid 9.9.9.[11-16]@tcp || error "Peer add failed $?"
462 compare_peer_del "9.9.9.9@tcp" "9.9.9.[11-16]@tcp"
464 run_test 9 "Delete all secondary nids from peer (tcp)"
467 reinit_dlc || return $?
469 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
471 - primary nid: 10.10.10.10@tcp
474 - nid: 10.10.10.10@tcp
475 - nid: 10.10.10.12@tcp
476 - nid: 10.10.10.13@tcp
477 - nid: 10.10.10.15@tcp
478 - nid: 10.10.10.16@tcp
481 do_lnetctl peer add --prim_nid 10.10.10.10@tcp \
482 --nid 10.10.10.[12-16]@tcp || error "Peer add failed $?"
483 compare_peer_del "10.10.10.10@tcp" "10.10.10.14@tcp"
485 run_test 10 "Delete single secondary nid from peer (o2ib)"
488 reinit_dlc || return $?
490 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
492 - primary nid: 11.11.11.11@tcp
495 - nid: 11.11.11.11@tcp
498 do_lnetctl peer add --prim_nid 11.11.11.11@tcp \
499 --nid 11.11.11.[13-17]@tcp || error "Peer add failed $?"
500 compare_peer_del "11.11.11.11@tcp" "11.11.11.[13-17]@tcp"
502 run_test 11 "Delete all secondary nids from peer (o2ib)"
505 reinit_dlc || return $?
507 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
509 - primary nid: 12.12.12.12@o2ib
512 - nid: 12.12.12.12@o2ib
513 - nid: 13.13.13.13@o2ib
514 - nid: 14.13.13.13@o2ib
515 - nid: 14.15.13.13@o2ib
517 - nid: 15.17.1.10@tcp
518 - nid: 15.17.1.20@tcp
521 do_lnetctl peer add --prim_nid 12.12.12.12@o2ib \
522 --nid [13-14/1].[13-15/2].13.13@o2ib,[15-16/3].[17-19/4].[1].[5-20/5]@tcp ||
523 error "Peer add failed $?"
524 compare_peer_del "12.12.12.12@o2ib" "13.15.13.13@o2ib,15.17.1.15@tcp"
526 run_test 12 "Delete a secondary nid from peer (tcp and o2ib)"
529 reinit_dlc || return $?
531 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
533 - primary nid: 13.13.13.13@o2ib
536 - nid: 13.13.13.13@o2ib
539 do_lnetctl peer add --prim_nid 13.13.13.13@o2ib \
540 --nid [14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib ||
541 error "Peer add failed $?"
542 compare_peer_del "13.13.13.13@o2ib" \
543 "[14-15].[1-2/1].[1].[100-254/10]@tcp,14.14.[254].14@o2ib"
545 run_test 13 "Delete all secondary nids from peer (tcp and o2ib)"
551 if [[ $net =~ gni* ]]; then
554 echo "${num}.${num}.${num}.${num}@${net}"
558 create_mr_peer_yaml() {
560 local secondary_nids="$2"
563 echo "Generating peer yaml for $num_peers peers with $secondary_nids secondary nids"
564 echo "peer:" >> $TMP/sanity-lnet-$testnum-expected.yaml
566 local total_nids=$((num_peers + $((num_peers * secondary_nids))))
569 while [[ $created -lt $num_peers ]]; do
570 local primary=$(create_nid ${nidnum} ${net})
571 cat <<EOF >> $TMP/sanity-lnet-$testnum-expected.yaml
572 - primary nid: $primary
578 local start=$((nidnum + 1))
579 local end=$((nidnum + $secondary_nids))
580 for j in $(seq ${start} ${end}); do
581 local nid=$(create_nid $j ${net})
582 echo " - nid: $nid" >> $TMP/sanity-lnet-$testnum-expected.yaml
590 reinit_dlc || return $?
592 echo "Create single peer, single nid, using import"
593 create_mr_peer_yaml 1 0 tcp
594 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
595 error "Import failed $?"
597 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
600 echo "Delete single peer using import --del"
601 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
602 error "Import failed $?"
603 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
604 create_base_yaml_file
605 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
608 run_test 14 "import peer create/delete with single nid"
611 reinit_dlc || return $?
613 echo "Create multiple peers, single nid per peer, using import"
614 create_mr_peer_yaml 5 0 o2ib
615 # The ordering of nids for this use-case is non-deterministic, so we
616 # we can't just diff the expected/actual output.
617 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
618 error "Import failed $?"
619 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
620 validate_peer_nids 5 0
622 echo "Delete multiple peers, single nid per peer, using import --del"
623 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
624 error "Import failed $?"
625 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
626 create_base_yaml_file
627 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
630 run_test 15 "import multi peer create/delete with single nid per peer"
633 reinit_dlc || return $?
635 echo "Create single peer, multiple nids, using import"
636 create_mr_peer_yaml 1 5 tcp
637 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
638 error "Import failed $?"
639 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
640 validate_peer_nids 1 5
642 echo "Delete single peer, multiple nids, using import --del"
643 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
644 error "Import failed $?"
645 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
646 create_base_yaml_file
647 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
650 run_test 16 "import peer create/delete with multiple nids"
653 reinit_dlc || return $?
655 echo "Create multiple peers, multiple nids per peer, using import"
656 create_mr_peer_yaml 5 7 o2ib
657 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
658 error "Import failed $?"
659 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
660 validate_peer_nids 5 7
662 echo "Delete multiple peers, multiple nids per peer, using import --del"
663 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml ||
664 error "Import failed $?"
665 rm -f $TMP/sanity-lnet-$testnum-expected.yaml
666 create_base_yaml_file
667 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
670 run_test 17 "import multi peer create/delete with multiple nids"
673 reinit_dlc || return $?
675 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
677 - primary nid: 1.1.1.1@tcp
686 echo "Import peer with 5 nids"
687 cat $TMP/sanity-lnet-$testnum-expected.yaml
688 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
689 error "Import failed $?"
690 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
692 - primary nid: 1.1.1.1@tcp
699 echo "Delete three of the nids"
700 cat $TMP/sanity-lnet-$testnum-expected.yaml
701 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
702 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
704 - primary nid: 1.1.1.1@tcp
710 echo "Check peer has expected nids remaining"
711 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
715 run_test 18a "Delete a subset of nids from a single peer using import --del"
718 reinit_dlc || return $?
720 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
722 - primary nid: 1.1.1.1@tcp
730 - primary nid: 6.6.6.6@o2ib
739 echo "Import two peers with 5 nids each"
740 cat $TMP/sanity-lnet-$testnum-expected.yaml
741 do_lnetctl import < $TMP/sanity-lnet-$testnum-expected.yaml ||
742 error "Import failed $?"
743 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
745 - primary nid: 1.1.1.1@tcp
751 - primary nid: 6.6.6.6@o2ib
758 echo "Delete three of the nids from each peer"
759 cat $TMP/sanity-lnet-$testnum-expected.yaml
760 do_lnetctl import --del < $TMP/sanity-lnet-$testnum-expected.yaml
761 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
763 - primary nid: 6.6.6.6@o2ib
768 - primary nid: 1.1.1.1@tcp
775 echo "Check peers have expected nids remaining"
776 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
778 validate_peer_nids 2 1
780 run_test 18b "Delete multiple nids from multiple peers using import --del"
783 reinit_dlc || return $?
784 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
786 - primary nid: 19@gni
792 compare_peer_add "19@gni"
794 run_test 19 "Add peer with single nid (gni)"
797 reinit_dlc || return $?
798 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
800 - primary nid: 20@gni
804 - nid: 20.20.20.20@tcp
805 - nid: 20.20.20.20@o2ib
808 compare_peer_add "20@gni" "20.20.20.20@tcp,20.20.20.20@o2ib"
810 run_test 20 "Add peer with gni primary and tcp, o2ib secondary"
813 reinit_dlc || return $?
814 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
816 - primary nid: 21@gni
826 echo"Add peer with nidrange (gni)"
827 compare_peer_add "21@gni" "[22-25]@gni" || error
828 echo "Add peer with nidrange that overlaps primary nid (gni)"
829 compare_peer_add "21@gni" "[21-25]@gni"
831 run_test 21 "Add peer with nidrange (gni)"
834 reinit_dlc || return $?
835 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
837 - primary nid: 22@gni
848 do_lnetctl peer add --prim_nid 22@gni --nid [24-29]@gni ||
849 error "Peer add failed $?"
850 compare_peer_del "22@gni" "26@gni"
852 run_test 22 "Delete single secondary nid from peer (gni)"
855 reinit_dlc || return $?
856 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
858 - primary nid: 23@gni
865 do_lnetctl peer add --prim_nid 23@gni --nid [25-29]@gni ||
866 error "Peer add failed $?"
867 compare_peer_del "23@gni" "[25-29]@gni"
869 run_test 23 "Delete all secondary nids from peer (gni)"
872 reinit_dlc || return $?
873 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
875 - primary nid: 24@gni
880 - nid: 13.13.13.13@o2ib
881 - nid: 14.13.13.13@o2ib
882 - nid: 14.15.13.13@o2ib
884 - nid: 15.17.1.10@tcp
885 - nid: 15.17.1.20@tcp
888 do_lnetctl peer add --prim_nid 24@gni \
889 --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 ||
890 error "Peer add failed $?"
891 compare_peer_del "24@gni" "5@gni,13.15.13.13@o2ib,15.17.1.15@tcp"
893 run_test 24 "Delete a secondary nid from peer (tcp, o2ib and gni)"
896 reinit_dlc || return $?
897 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
899 - primary nid: 25@gni
905 do_lnetctl peer add --prim_nid 25@gni \
906 --nid [26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni ||
907 error "Peer add failed $?"
908 compare_peer_del "25@gni" \
909 "[26-27].[4-10/3].26.26@tcp,26.26.26.26@o2ib,[30-35]@gni"
911 run_test 25 "Delete all secondary nids from peer (tcp, gni and o2ib)"
914 reinit_dlc || return $?
916 echo "Invalid prim_nid - peer add"
917 do_lnetctl peer add --prim_nid foobar &&
918 error "Command should have failed"
920 echo "Invalid prim_nid - peer del"
921 do_lnetctl peer del --prim_nid foobar &&
922 error "Command should have failed"
924 echo "Delete non-existing peer"
925 do_lnetctl peer del --prim_nid 1.1.1.1@o2ib &&
926 error "Command should have failed"
928 echo "Don't provide mandatory arguments peer del"
929 do_lnetctl peer del --nid 1.1.1.1@tcp &&
930 error "Command should have failed"
932 echo "Don't provide mandatory arguments peer add"
933 do_lnetctl peer add &&
934 error "Command should have failed"
936 echo "Invalid secondary nids"
937 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid foobar &&
938 error "Command should have failed"
940 echo "Exceed max nids per peer"
941 do_lnetctl peer add --prim_nid 1.1.1.1@tcp --nid 1.1.1.[2-255]@tcp &&
942 error "Command should have failed"
944 echo "Invalid net type"
945 do_lnetctl peer add --prim_nid 1@foo &&
946 error "Command should have failed"
948 echo "Invalid nid format"
949 local invalid_nids="1@tcp 1@o2ib 1.1.1.1@gni"
952 for nid in ${invalid_nids}; do
953 echo "Check invalid primary nid - '$nid'"
954 do_lnetctl peer add --prim_nid $nid &&
955 error "Command should have failed"
958 local invalid_strs="[2-1]@gni [a-f/x]@gni 256.256.256.256@tcp"
959 invalid_strs+=" 1.1.1.1.[2-5/f]@tcp 1.]2[.3.4@o2ib"
960 invalid_strs+="1.[2-4,[5-6],7-8].1.1@tcp foobar"
963 for nidstr in ${invalid_strs}; do
964 echo "Check invalid nidstring - '$nidstr'"
965 do_lnetctl peer add --nid $nidstr &&
966 error "Command should have failed"
969 echo "Add non-local gateway"
970 do_lnetctl route add --net tcp --gateway 1@gni &&
971 error "Command should have failed"
975 run_test 99a "Check various invalid inputs to lnetctl peer"
978 reinit_dlc || return $?
980 create_base_yaml_file
982 cat <<EOF > $TMP/sanity-lnet-$testnum-invalid.yaml
984 - primary nid: 99.99.99.99@tcp
987 - nid: 99.99.99.99@tcp
989 do_lnetctl import < $TMP/sanity-lnet-$testnum-invalid.yaml &&
990 error "import should have failed"
991 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
994 run_test 99b "Invalid value for Multi-Rail in yaml import"
998 local ip=$(ip addr show dev $if | awk '/ inet /{print $2}')
1006 reinit_dlc || return $?
1007 load_module ../lnet/klnds/socklnd/ksocklnd ||
1008 error "Can't load ksocklnd.ko"
1009 do_lnetctl net add --net ${net} --if ${if} ||
1010 error "Failed to add net ${net} on if ${if}"
1013 compare_route_add() {
1017 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1019 do_lnetctl route add --net ${rnet} --gateway ${gw} ||
1020 error "route add failed $?"
1021 # CPT configuration is pruned from the exported yaml, since the default
1022 # can vary across test systems (unlike default values for things like
1023 # peer_credits, peer_timeout, etc.)
1024 $LNETCTL export --backup | grep -v CPT > $actual ||
1025 error "export failed $?"
1026 validate_gateway_nids
1031 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1032 add_net "tcp" "eth0"
1033 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1042 peer_buffer_credits: 0
1046 gateway: 7.7.7.7@tcp
1049 health_sensitivity: 1
1051 - primary nid: 7.7.7.7@tcp
1057 compare_route_add "tcp7" "7.7.7.7@tcp" || return $?
1060 run_test 100 "Add route with single gw (tcp)"
1063 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1064 add_net "tcp" "eth0"
1065 cat <<EOF > $TMP/sanity-lnet-$testnum-expected.yaml
1074 peer_buffer_credits: 0
1078 gateway: 8.8.8.10@tcp
1081 health_sensitivity: 1
1083 gateway: 8.8.8.9@tcp
1086 health_sensitivity: 1
1088 gateway: 8.8.8.8@tcp
1091 health_sensitivity: 1
1093 - primary nid: 8.8.8.9@tcp
1097 - primary nid: 8.8.8.10@tcp
1101 - primary nid: 8.8.8.8@tcp
1107 compare_route_add "tcp8" "8.8.8.[8-10]@tcp"
1109 run_test 101 "Add route with multiple gw (tcp)"
1111 compare_route_del() {
1115 local actual="$TMP/sanity-lnet-$testnum-actual.yaml"
1117 do_lnetctl route del --net ${rnet} --gateway ${gw} ||
1118 error "route del failed $?"
1119 $LNETCTL export --backup > $actual ||
1120 error "export failed $?"
1121 validate_gateway_nids
1125 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1126 add_net "tcp" "eth0"
1127 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1128 do_lnetctl route add --net tcp102 --gateway 102.102.102.102@tcp ||
1129 error "route add failed $?"
1130 compare_route_del "tcp102" "102.102.102.102@tcp"
1132 run_test 102 "Delete route with single gw (tcp)"
1135 have_interface "eth0" || skip "Need eth0 interface with ipv4 configured"
1136 add_net "tcp" "eth0"
1137 $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
1138 do_lnetctl route add --net tcp103 \
1139 --gateway 103.103.103.[103-120/4]@tcp ||
1140 error "route add failed $?"
1141 compare_route_del "tcp103" "103.103.103.[103-120/4]@tcp"
1143 run_test 103 "Delete route with multiple gw (tcp)"
1145 ### load lnet in default namespace, configure in target namespace
1148 cleanup_lnet || exit 1
1149 load_lnet "networks=\"\""
1150 do_ns $LNETCTL lnet configure --all || exit 1
1151 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1153 run_test 200 "load lnet w/o module option, configure in a non-default namespace"
1156 cleanup_lnet || exit 1
1157 load_lnet "networks=tcp($FAKE_IF)"
1158 do_ns $LNETCTL lnet configure --all || exit 1
1159 $LNETCTL net show --net tcp | grep -q "nid: ${FAKE_IP}@tcp$"
1161 run_test 201 "load lnet using networks module options in a non-default namespace"
1164 cleanup_lnet || exit 1
1165 load_lnet "networks=\"\" ip2nets=\"tcp0($FAKE_IF) ${FAKE_IP}\""
1166 do_ns $LNETCTL lnet configure --all || exit 1
1167 $LNETCTL net show | grep -q "nid: ${FAKE_IP}@tcp$"
1169 run_test 202 "load lnet using ip2nets in a non-default namespace"
1172 ### Add the interfaces in the target namespace
1175 cleanup_lnet || exit 1
1177 do_lnetctl lnet configure || exit 1
1178 do_ns $LNETCTL net add --net tcp0 --if $FAKE_IF
1180 run_test 203 "add a network using an interface in the non-default namespace"