2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
11 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
12 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=default
17 #export PDSH="pdsh -S -Rssh -w"
19 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
23 if [ -z "${!name}" ]; then
24 echo "$0: $name must be set"
28 [ $failed ] && exit 1 || true
32 echo "usage: $0 [-r] [-f cfgfile]"
39 [ "$TESTSUITE" == "lfscktest" ] && return 0
40 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
41 local form="%-13s %-17s %s\n"
42 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
43 echo "------------------------------------------------------------------------------------"
44 for O in $TESTSUITE_LIST; do
47 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
50 local log=${TMP}/${o}.log
51 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
52 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
53 [ "${!O}" = "done" ] && \
54 printf "$form" "Done" "$O" "E=$skipped" && \
55 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
59 for O in $TESTSUITE_LIST; do
60 [ "${!O}" = "no" ] && \
61 printf "$form" "Skipped" "$O" ""
64 for O in $TESTSUITE_LIST; do
65 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
66 printf "$form" "UNFINISHED" "$O" ""
71 export LUSTRE=`absolute_path $LUSTRE`
72 export TESTSUITE=`basename $0 .sh`
74 [ -d /r ] && export ROOT=${ROOT:-/r}
75 export TMP=${TMP:-$ROOT/tmp}
76 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
77 export HOSTNAME=${HOSTNAME:-`hostname`}
78 if ! echo $PATH | grep -q $LUSTRE/utils; then
79 export PATH=$PATH:$LUSTRE/utils
81 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
82 export PATH=$PATH:$LUSTRE/utils/gss
84 if ! echo $PATH | grep -q $LUSTRE/tests; then
85 export PATH=$PATH:$LUSTRE/tests
87 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
88 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
89 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
90 [ ! -f "$LFS" ] && export LFS=$(which lfs)
91 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
92 if [ ! -f "$L_GETIDENTITY" ]; then
93 if `which l_getidentity > /dev/null 2>&1`; then
94 export L_GETIDENTITY=$(which l_getidentity)
96 export L_GETIDENTITY=NONE
99 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
100 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
101 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
102 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
103 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
104 export FSYTPE=${FSTYPE:-"ldiskfs"}
105 export NAME=${NAME:-local}
106 export LPROC=/proc/fs/lustre
107 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
108 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
109 export LGSSD=$(which lgssd)
110 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
111 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
112 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
114 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
116 if [ "$ACCEPTOR_PORT" ]; then
117 export PORT_OPT="--port $ACCEPTOR_PORT"
122 echo "Using GSS/krb5 ptlrpc security flavor"
133 IDENTITY_UPCALL=false
137 # Paths on remote nodes, if different
138 export RLUSTRE=${RLUSTRE:-$LUSTRE}
139 export RPWD=${RPWD:-$PWD}
140 export I_MOUNTED=${I_MOUNTED:-"no"}
144 while getopts "rvf:" opt $*; do
147 r) REFORMAT=--reformat;;
153 shift $((OPTIND - 1))
156 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
165 BASE=`basename $module $EXT`
166 lsmod | grep -q ${BASE} || \
167 if [ -f ${LUSTRE}/${module}${EXT} ]; then
168 insmod ${LUSTRE}/${module}${EXT} $@
170 # must be testing a "make install" or "rpm" installation
171 # note failed to load ptlrpc_gss is considered not fatal
172 if [ "$BASE" == "ptlrpc_gss" ]; then
173 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
181 if [ -n "$MODPROBE" ]; then
185 if [ "$HAVE_MODULES" = true ]; then
191 echo Loading modules from $LUSTRE
192 load_module ../lnet/libcfs/libcfs
193 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
194 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
195 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
196 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
197 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
198 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
199 echo "lnet options: '$LNETOPTS'"
200 # note that insmod will ignore anything in modprobe.conf
201 load_module ../lnet/lnet/lnet $LNETOPTS
202 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
203 load_module ../lnet/klnds/$LNETLND
204 load_module lvfs/lvfs
205 load_module obdclass/obdclass
206 load_module ptlrpc/ptlrpc
207 load_module ptlrpc/gss/ptlrpc_gss
208 # Now, some modules depend on lquota without USE_QUOTA check,
209 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
210 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
211 load_module quota/lquota
219 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
220 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
221 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
226 load_module lvfs/fsfilt_$FSTYPE
230 load_module obdfilter/obdfilter
233 load_module llite/lustre
234 load_module llite/llite_lloop
235 rm -f $TMP/ogdb-$HOSTNAME
237 [ -d /r ] && OGDB="/r/tmp"
238 $LCTL modules > $OGDB/ogdb-$HOSTNAME
240 # 'mount' doesn't look in $PATH, just sbin
241 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
245 if [ `uname -r | cut -c 3` -eq 4 ]; then
253 MODULES=$($LCTL modules | awk '{ print $2 }')
254 while [ -n "$MODULES" ]; do
256 $RMMOD $MODULES > /dev/null 2>&1 || true
257 MODULES=$($LCTL modules | awk '{ print $2 }')
258 if [ -z "$MODULES" ]; then
262 echo "waiting, $((MAX - WAIT)) secs left"
264 if [ $WAIT -eq $MAX ]; then
265 echo "LNET modules $MODULES will not unload"
273 wait_exit_ST client # bug 12845
275 lsmod | grep libcfs > /dev/null && $LCTL dl
276 local MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
277 $RMMOD $MODULES > /dev/null 2>&1 || true
278 # do it again, in case we tried to unload ksocklnd too early
279 MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
280 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
281 lsmod | grep libcfs > /dev/null && $LCTL dk $TMP/debug
283 MODULES=$($LCTL modules | awk '{ print $2 }')
284 if [ -n "$MODULES" ]; then
285 echo "Modules still loaded: "
287 if [ "$(lctl dl)" ]; then
288 echo "Lustre still loaded"
293 echo "Lustre stopped but LNET is still loaded, waiting..."
294 wait_for_lnet || return 3
300 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
301 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
302 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
303 echo "$LEAK_LUSTRE" 1>&2
304 echo "$LEAK_PORTALS" 1>&2
305 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
306 echo "Memory leaks detected"
307 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
310 echo "modules unloaded."
314 check_gss_daemon_facet() {
318 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
319 if [ $num -ne 1 ]; then
320 echo "$num instance of $dname on $facet"
329 do_facet $facet "killall -2 $@ 2>/dev/null || true"
332 start_gss_daemons() {
334 for num in `seq $MDSCOUNT`; do
335 do_facet mds$num "$LSVCGSSD -v"
337 do_facet mds$num "$LGSSD -v"
341 for num in `seq $OSTCOUNT`; do
342 do_facet ost$num "$LSVCGSSD -v"
345 # FIXME: is "client" the right facet name?
347 do_facet client "$LGSSD -v"
350 # wait daemons entering "stable" status
354 # check daemons are running
356 for num in `seq $MDSCOUNT`; do
357 check_gss_daemon_facet mds$num lsvcgssd
359 check_gss_daemon_facet mds$num lgssd
362 for num in `seq $OSTCOUNT`; do
363 check_gss_daemon_facet ost$num lsvcgssd
366 check_gss_daemon_facet client lgssd
371 for num in `seq $MDSCOUNT`; do
372 send_sigint mds$num lsvcgssd lgssd
374 for num in `seq $OSTCOUNT`; do
375 send_sigint ost$num lsvcgssd
377 send_sigint client lgssd
389 # maybe cleanup credential cache?
395 local device=`mdsdevname $num`
396 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
402 local device=`ostdevname $num`
403 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
411 local dev=${facet}_dev
412 local opt=${facet}_opt
413 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
414 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
416 if [ $RC -ne 0 ]; then
417 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
418 echo "Start of ${device} on ${facet} failed ${RC}"
420 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
421 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
422 lctl set_param debug_mb=${DEBUG_SIZE}; \
428 # start facet device options
434 eval export ${facet}_dev=${device}
435 eval export ${facet}_opt=\"$@\"
436 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
439 if [ $RC -eq 0 ]; then
440 label=$(do_facet ${facet} "e2label ${device}")
441 [ -z "$label" ] && echo no label for ${device} && exit 1
442 eval export ${facet}_svc=${label}
443 echo Started ${label}
452 HOST=`facet_active_host $facet`
453 [ -z $HOST ] && echo stop: no host for $facet && return 0
455 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
456 if [ ${running} -ne 0 ]; then
457 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
458 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
461 # umount should block, but we should wait for unrelated obd's
462 # like the MGS or MGC to also stop.
463 wait_exit_ST ${facet}
470 # Only supply -o to mount if we have options
471 if [ -n "$MOUNTOPT" ]; then
472 OPTIONS="-o $MOUNTOPT"
474 local device=$MGSNID:/$FSNAME
475 if [ -z "$mnt" -o -z "$FSNAME" ]; then
476 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
480 echo "Starting client: $client: $OPTIONS $device $mnt"
481 do_node $client mkdir -p $mnt
482 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
484 do_node $client "lctl set_param debug=$PTLDEBUG;
485 lctl set_param subsystem_debug=${SUBSYSTEM# };
486 lctl set_param debug_mb=${DEBUG_SIZE}"
487 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
495 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
496 if [ $running -ne 0 ]; then
497 echo "Stopping client $client $mnt (opts:$force)"
498 lsof | grep "$mnt" || true
499 do_node $client umount $force $mnt
503 zconf_mount_clients() {
509 # Only supply -o to mount if we have options
510 if [ -n "$MOUNTOPT" ]; then
511 OPTIONS="-o $MOUNTOPT"
513 local device=$MGSNID:/$FSNAME
514 if [ -z "$mnt" -o -z "$FSNAME" ]; then
515 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
519 echo "Starting client $clients: $OPTIONS $device $mnt"
520 do_nodes $clients mkdir -p $mnt
521 do_nodes $clients mount -t lustre $OPTIONS $device $mnt || return 1
523 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
524 lctl set_param subsystem_debug=${SUBSYSTEM# };
525 lctl set_param debug_mb=${DEBUG_SIZE};"
530 zconf_umount_clients() {
535 echo "Umounting clients: $clients"
536 echo "Stopping client $client $mnt (opts:$force)"
537 do_nodes $clients umount $force $mnt
542 if [ "$FAILURE_MODE" = HARD ]; then
543 $POWER_DOWN `facet_active_host $facet`
545 elif [ "$FAILURE_MODE" = SOFT ]; then
552 if [ "$FAILURE_MODE" = HARD ]; then
553 $POWER_UP `facet_active_host $facet`
559 # verify that lustre actually cleaned up properly
561 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
562 error "LBUG/LASSERT detected"
563 BUSY=`dmesg | grep -i destruct || true`
566 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
569 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
570 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
571 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
572 echo "$0: $LEAK_LUSTRE" 1>&2
573 echo "$0: $LEAK_PORTALS" 1>&2
574 echo "$0: Memory leak(s) detected..." 1>&2
575 mv $TMP/debug $TMP/debug-leak.`date +%s`
579 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
580 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
582 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
583 echo "$0: modules still loaded..." 1>&2
590 wait_delete_completed () {
591 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
592 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
596 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
598 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
599 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
600 [ "$TOTAL" -eq "$TOTALPREV" ] && break
601 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
605 echo "Delete completed."
610 check_network "$HOST" 900
611 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
616 HOST=`facet_active_host $facet`
620 wait_mds_recovery_done () {
621 local timeout=`do_facet mds lctl get_param -n timeout`
622 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
623 # as we are in process of changing obd_timeout in different ways
624 # let's set MAX longer than that
625 MAX=$(( timeout * 4 ))
627 while [ $WAIT -lt $MAX ]; do
628 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT*.recovery_status | grep status"`
629 echo $STATUS | grep COMPLETE && return 0
632 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
634 echo "MDS recovery not done in $MAX sec"
643 # conf-sanity 31 takes a long time cleanup
644 while [ $WAIT -lt 300 ]; do
645 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
646 [ -z "${running}" ] && return 0
647 echo "waited $WAIT for${running}"
648 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
650 WAIT=$((WAIT + INTERVAL))
652 echo "service didn't stop after $WAIT seconds. Still running:"
658 # not every config has many clients
659 if [ ! -z "$CLIENTS" ]; then
660 $PDSH $CLIENTS "df $MOUNT" > /dev/null
662 df $MOUNT > /dev/null
667 uname -n >> $MOUNT/recon
668 if [ ! -z "$CLIENTS" ]; then
669 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
671 echo Connected clients:
673 ls -l $MOUNT/recon > /dev/null
679 echo "Failing $facet on node `facet_active_host $facet`"
680 shutdown_facet $facet
684 echo "df pid is $DFPID"
686 TO=`facet_active_host $facet`
687 echo "Failover $facet to $TO"
689 mount_facet $facet || error "Restart of $facet failed"
700 local svc=${facet}_svc
701 do_facet $facet $LCTL --device %${!svc} readonly
702 do_facet $facet $LCTL --device %${!svc} notransno
703 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
704 $LCTL mark "local REPLAY BARRIER on ${!svc}"
707 replay_barrier_nodf() {
708 local facet=$1 echo running=${running}
710 local svc=${facet}_svc
711 echo Replay barrier on ${!svc}
712 do_facet $facet $LCTL --device %${!svc} readonly
713 do_facet $facet $LCTL --device %${!svc} notransno
714 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
715 $LCTL mark "local REPLAY BARRIER on ${!svc}"
719 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
720 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
724 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
725 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
729 facet_failover $* || error "failover: $?"
730 df $MOUNT || error "post-failover df: $?"
735 facet_failover $facet
742 mount_facet $facet -o abort_recovery
743 df $MOUNT || echo "first df failed: $?"
745 df $MOUNT || error "post-failover df: $?"
749 echo There is no lmc. This is mountconf, baby.
754 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
755 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
761 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
767 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
768 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
769 if [ -z "$ID" ]; then
770 echo "Could not get a ptl id for $1..."
779 h2name_or_ip "$1" "tcp"
784 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
785 if type __h2elan >/dev/null 2>&1; then
788 ID=`echo $1 | sed 's/[^0-9]*//g'`
796 h2name_or_ip "$1" "openib"
801 h2name_or_ip "$1" "o2ib"
807 varname=${facet}_HOST
808 if [ -z "${!varname}" ]; then
809 if [ "${facet:0:3}" == "ost" ]; then
810 eval ${facet}_HOST=${ost_HOST}
818 local activevar=${facet}active
820 if [ -f $TMP/${facet}active ] ; then
821 source $TMP/${facet}active
825 if [ -z "$active" ] ; then
832 facet_active_host() {
834 local active=`facet_active $facet`
835 if [ "$facet" == client ]; then
838 echo `facet_host $active`
844 failover=${facet}failover
845 host=`facet_host $failover`
846 [ -z "$host" ] && return
847 curactive=`facet_active $facet`
848 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
849 eval export ${facet}active=$facet
851 eval export ${facet}active=$failover
853 # save the active host for this facet
854 activevar=${facet}active
855 echo "$activevar=${!activevar}" > $TMP/$activevar
862 if [ "$HOST" = "$HOSTNAME" ]; then
864 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
865 echo "cannot run remote command on $HOST with $myPDSH"
869 echo "CMD: $HOST $@" >&2
870 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
873 if [ "$myPDSH" = "rsh" ]; then
874 # we need this because rsh does not return exit code of an executed command
875 local command_status="$TMP/cs"
876 rsh $HOST ":> $command_status"
877 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
878 cd $RPWD; sh -c \"$@\") ||
879 echo command failed >$command_status"
880 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
883 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
884 return ${PIPESTATUS[0]}
892 # split list to local and remote
893 local rnodes=$(echo " $nodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
895 if [ "$(get_node_count $nodes)" != "$(get_node_count $rnodes)" ]; then
899 [ -z "$(echo $rnodes)" ] && return 0
901 # This is part from do_node
904 rnodes=$(comma_list $rnodes)
905 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ] && \
906 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
909 echo "CMD: $rnodes $@" >&2
910 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
913 if [ "$myPDSH" = "rsh" ]; then
914 # we need this because rsh does not return exit code of an executed command
915 local command_status="$TMP/cs"
916 rsh $rnodes ":> $command_status"
917 rsh $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
918 cd $RPWD; sh -c \"$@\") ||
919 echo command failed >$command_status"
920 [ -n "$($myPDSH $rnodes cat $command_status)" ] && return 1 || true
923 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
924 return ${PIPESTATUS[0]}
931 HOST=`facet_active_host $facet`
932 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
939 # make sure its not already running
941 rm -f $TMP/${facet}active
942 do_facet ${facet} $MKFS $*
948 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
949 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
956 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
957 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
965 # make sure we are using the primary server, so test-framework will
966 # be able to clean up properly.
967 activemds=`facet_active mds1`
968 if [ $activemds != "mds1" ]; then
972 # assume client mount is local
973 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
974 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
976 if [ -n "$CLIENTS" ]; then
977 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
978 zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
981 [ "$CLIENTONLY" ] && return
982 # The add fn does rm ${facet}active file, this would be enough
983 # if we use do_facet <facet> only after the facet added, but
984 # currently we use do_facet mds in local.sh
985 for num in `seq $MDSCOUNT`; do
987 rm -f ${TMP}/mds${num}active
990 for num in `seq $OSTCOUNT`; do
992 rm -f $TMP/ost${num}active
1007 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1011 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1013 if [ ! -z $SEC ]; then
1014 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1015 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1019 # We need ldiskfs here, may as well load them all
1021 [ "$CLIENTONLY" ] && return
1022 echo "Formatting mdts, osts"
1023 for num in `seq $MDSCOUNT`; do
1024 echo "Format mds$num: $(mdsdevname $num)"
1026 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1028 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1032 for num in `seq $OSTCOUNT`; do
1033 echo "Format ost$num: $(ostdevname $num)"
1035 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1037 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1043 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1047 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1051 # 0: success, the old identity set already.
1052 # 1: success, the old identity does not set.
1057 local j=`expr $num - 1`
1058 local MDT="`do_facet mds$num lctl get_param -N mdt.*MDT*$j | cut -d"." -f2 2>/dev/null || true`"
1060 if [ -z "$MDT" ]; then
1064 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1067 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1069 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1072 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1074 if [ $old = "NONE" ]; then
1083 zconf_umount `hostname` $1 || error "umount failed"
1084 zconf_mount `hostname` $1 || error "mount failed"
1091 do_facet $facet lsmod | grep -q obdclass || \
1092 do_facet $facet "modprobe obdclass"
1094 do_facet $facet "lctl set_param timeout=$timeout"
1100 if [ -z "$CLIENTONLY" ]; then
1101 echo "Setup mdts, osts"
1102 for num in `seq $MDSCOUNT`; do
1103 DEVNAME=$(mdsdevname $num)
1104 echo $REFORMAT | grep -q "reformat" \
1105 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1106 set_obd_timeout mds$num $TIMEOUT
1107 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1109 # We started mds, now we should set failover variables properly.
1110 # Set mds${num}failover_HOST if it is not set (the default failnode).
1111 if [ -z "$mds${num}failover_HOST" ]; then
1112 mds${num}failover_HOST=$(facet_host mds$num)
1115 if [ $IDENTITY_UPCALL != "default" ]; then
1116 switch_identity $num $IDENTITY_UPCALL
1119 for num in `seq $OSTCOUNT`; do
1120 DEVNAME=$(ostdevname $num)
1121 set_obd_timeout ost$num $TIMEOUT
1122 start ost$num $DEVNAME $OST_MOUNT_OPTS
1124 # We started ost$num, now we should set ost${num}failover variable properly.
1125 # Set ost${num}failover_HOST if it is not set (the default failnode).
1126 varname=ost${num}failover_HOST
1127 if [ -z "${!varname}" ]; then
1128 eval ost${num}failover_HOST=$(facet_host ost${num})
1133 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1135 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1137 if [ "$MOUNT_2" ]; then
1138 mount_client $MOUNT2
1139 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1142 # by remounting mdt before ost, initial connect from mdt to ost might
1143 # timeout because ost is not ready yet. wait some time to its fully
1144 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1145 # by a context negotiation rpc with $TIMEOUT.
1146 # FIXME better by monitoring import status.
1148 sleep $((TIMEOUT + 5))
1154 mounted_lustre_filesystems() {
1155 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1158 check_and_setup_lustre() {
1159 MOUNTED="`mounted_lustre_filesystems`"
1160 if [ -z "$MOUNTED" ]; then
1161 [ "$REFORMAT" ] && formatall
1163 MOUNTED="`mounted_lustre_filesystems`"
1164 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1165 export I_MOUNTED=yes
1167 if [ "$ONLY" == "setup" ]; then
1172 cleanup_and_setup_lustre() {
1173 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1174 lctl set_param debug=0 || true
1176 if [ "$ONLY" == "cleanup" ]; then
1180 check_and_setup_lustre
1183 check_and_cleanup_lustre() {
1184 if [ "`mount | grep $MOUNT`" ]; then
1185 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1187 if [ "$I_MOUNTED" = "yes" ]; then
1188 cleanupall -f || error "cleanup failed"
1200 while [ $NETWORK -eq 0 ]; do
1201 ping -c 1 -w 3 $1 > /dev/null
1202 if [ $? -eq 0 ]; then
1206 echo "waiting for $1, $((MAX - WAIT)) secs left"
1209 if [ $WAIT -gt $MAX ]; then
1210 echo "Network not available"
1216 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1227 # the sed converts spaces to commas, but leaves the last space
1228 # alone, so the line doesn't end with a comma.
1229 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1233 (cd `dirname $1`; echo $PWD/`basename $1`)
1236 ##################################
1240 # OBD_FAIL_MDS_ALL_REQUEST_NET
1242 do_facet mds lctl set_param fail_loc=0x123
1243 do_facet client "$1" || RC=$?
1244 do_facet mds lctl set_param fail_loc=0
1249 # OBD_FAIL_MDS_ALL_REPLY_NET
1251 do_facet mds lctl set_param fail_loc=0x122
1252 do_facet client "$@" || RC=$?
1253 do_facet mds lctl set_param fail_loc=0
1257 drop_reint_reply() {
1258 # OBD_FAIL_MDS_REINT_NET_REP
1260 do_facet mds lctl set_param fail_loc=0x119
1261 do_facet client "$@" || RC=$?
1262 do_facet mds lctl set_param fail_loc=0
1267 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1269 do_facet ost1 lctl set_param fail_loc=0x214
1270 do_facet client "$1" || RC=$?
1271 do_facet client "sync"
1272 do_facet ost1 lctl set_param fail_loc=0
1276 drop_ldlm_cancel() {
1277 #define OBD_FAIL_LDLM_CANCEL 0x304
1279 do_facet client lctl set_param fail_loc=0x304
1280 do_facet client "$@" || RC=$?
1281 do_facet client lctl set_param fail_loc=0
1285 drop_bl_callback() {
1286 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1288 do_facet client lctl set_param fail_loc=0x305
1289 do_facet client "$@" || RC=$?
1290 do_facet client lctl set_param fail_loc=0
1295 #define OBD_FAIL_LDLM_REPLY 0x30c
1297 do_facet mds lctl set_param fail_loc=0x30c
1298 do_facet client "$@" || RC=$?
1299 do_facet mds lctl set_param fail_loc=0
1307 echo "clearing fail_loc on $facet"
1308 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1311 set_nodes_failloc () {
1315 for node in $nodes ; do
1316 do_node $node lctl set_param fail_loc=$2
1320 set_nodes_failloc () {
1324 for node in $nodes ; do
1325 do_node $node lctl set_param fail_loc=$2
1329 cancel_lru_locks() {
1330 $LCTL mark "cancel_lru_locks $1 start"
1331 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1332 lctl get_param ldlm.namespaces.*$1*.lock_unused_count | grep -v '=0'
1333 $LCTL mark "cancel_lru_locks $1 stop"
1338 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1339 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1340 echo "$DEFAULT_LRU_SIZE"
1345 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1348 lru_resize_disable()
1350 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1355 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1356 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1357 echo there is still data in page cache $FILE ?
1358 lctl get_param -n $FILE
1366 DEBUGSAVE="$(lctl get_param -n debug)"
1370 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1374 ##################################
1376 ##################################
1379 local TYPE=${TYPE:-"FAIL"}
1381 lctl set_param fail_loc=0 2>/dev/null || true
1382 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1383 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1384 echo "Dumping lctl log to $ERRLOG"
1385 # We need to dump the logs on all nodes
1386 local NODES=$(nodes_list)
1387 for NODE in $NODES; do
1388 do_node $NODE $LCTL dk $ERRLOG
1391 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1396 $FAIL_ON_ERROR && exit 1 || true
1404 # use only if we are ignoring failures for this test, bugno required.
1405 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1406 # e.g. error_ignore 5494 "your message"
1408 TYPE="IGNORE (bz$1)"
1414 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1415 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1418 build_test_filter() {
1419 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1423 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1424 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1425 [ "$EXCEPT_SLOW" ] && \
1426 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1427 for E in $EXCEPT $ALWAYS_EXCEPT; do
1428 eval EXCEPT_${E}=true
1430 for E in $EXCEPT_SLOW; do
1431 eval EXCEPT_SLOW_${E}=true
1433 for G in $GRANT_CHECK_LIST; do
1434 eval GCHECK_ONLY_${G}=true
1443 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1447 export base=`basetest $1`
1448 if [ ! -z "$ONLY" ]; then
1450 if [ ${!testname}x != x ]; then
1455 if [ ${!testname}x != x ]; then
1463 if [ ${!testname}x != x ]; then
1464 TESTNAME=test_$1 skip "skipping excluded test $1"
1467 testname=EXCEPT_$base
1468 if [ ${!testname}x != x ]; then
1469 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1472 testname=EXCEPT_SLOW_$1
1473 if [ ${!testname}x != x ]; then
1474 TESTNAME=test_$1 skip "skipping SLOW test $1"
1477 testname=EXCEPT_SLOW_$base
1478 if [ ${!testname}x != x ]; then
1479 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1488 EQUALS="======================================================================"
1492 local suffixlen=$((${#EQUALS} - ${#msg}))
1493 [ $suffixlen -lt 5 ] && suffixlen=5
1494 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1499 lsmod | grep lnet > /dev/null || load_modules
1510 local NODES=$(nodes_list)
1511 for NODE in $NODES; do
1512 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1518 strace -o $TMP/$1.strace -ttt $*
1520 log "FINISHED: $*: rc $RC"
1529 FFREE=`lctl get_param -n osd.*MDT*.filesfree`
1530 FTOTAL=`lctl get_param -n osd.*MDT*.filestotal`
1531 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1535 local myNODES=$(nodes_list)
1538 for NODE in $myNODES; do
1539 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1547 export tdir=d0.${TESTSUITE}/d${base}
1548 local SAVE_UMASK=`umask`
1553 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1555 export TESTNAME=test_$testnum
1556 test_${testnum} || error "test_$testnum failed with $?"
1560 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1561 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1562 error "LBUG/LASSERT detected"
1563 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1564 pass "($((`date +%s` - $BEFORE))s)"
1565 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1573 (cd `dirname $1`; echo $PWD/`basename $1`)
1577 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1578 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1583 export base=`basetest $1`
1584 [ "$CHECK_GRANT" == "no" ] && return 0
1586 testname=GCHECK_ONLY_${base}
1587 [ ${!testname}x == x ] && return 0
1589 echo -n "checking grant......"
1591 # write some data to sync client lost_grant
1592 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1593 for i in `seq $OSTCOUNT`; do
1594 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1595 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1596 count=1 > /dev/null 2>&1
1598 # sync all the data and make sure no pending data on server
1601 #get client grant and server grant
1603 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1604 client_grant=$((client_grant + $d))
1607 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1608 server_grant=$((server_grant + $d))
1611 # cleanup the check_grant file
1612 for i in `seq $OSTCOUNT`; do
1613 rm $DIR1/${tfile}_check_grant_$i
1616 #check whether client grant == server grant
1617 if [ $client_grant != $server_grant ]; then
1618 echo "failed: client:${client_grant} server: ${server_grant}"
1625 ########################
1631 ost=`echo $1 | awk -F_ '{print $3}'`
1632 if [ -z $ost ]; then
1633 ost=`echo $1 | sed 's/-osc.*//'`
1640 [ -z "$(lctl dl | grep mdt)" ]
1645 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1650 [ -z "$(lctl dl | grep ost)" ]
1655 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1659 local MDSNODES=$(facet_host $SINGLEMDS)
1662 # FIXME: Currenly we use only $SINGLEMDS,
1663 # should be fixed when we will start to test cmd.
1667 for num in `seq $MDSCOUNT`; do
1668 local myMDS=$(facet_host mds$num)
1669 MDSNODES="$MDSNODES $myMDS"
1671 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1677 local OSTNODES=$(facet_host ost1)
1680 for num in `seq $OSTCOUNT`; do
1681 local myOST=$(facet_host ost$num)
1682 OSTNODES="$OSTNODES $myOST"
1684 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1690 # FIXME. We need a list of clients
1691 local myNODES=$HOSTNAME
1694 # CLIENTS (if specified) contains the local client
1695 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1697 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1698 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1701 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1708 lctl get_param version | grep -q patchless
1713 echo $nodes | wc -w || true
1717 local nodes=$(osts_nodes)
1718 local osscount=$(get_node_count "$nodes")
1719 [ ! "$OSTCOUNT" = "$osscount" ]
1722 check_runas_id_ret() {
1727 if [ -z "$myRUNAS" ]; then
1728 error_exit "myRUNAS command must be specified for check_runas_id"
1731 $myRUNAS krb5_login.sh || \
1732 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1734 mkdir $DIR/d0_runas_test
1736 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1737 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1738 rm -rf $DIR/d0_runas_test
1746 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1747 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1748 Please set RUNAS_ID to some UID which exists on MDS and client or
1749 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1752 # Run multiop in the background, but wait for it to print
1753 # "PAUSING" to its stdout before returning from this function.
1754 multiop_bg_pause() {
1755 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1759 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1762 echo "$MULTIOP_PROG $FILE v$ARGS"
1763 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1765 echo "TMPPIPE=${TMPPIPE}"
1766 read -t 60 multiop_output < $TMPPIPE
1767 if [ $? -ne 0 ]; then
1772 if [ "$multiop_output" != "PAUSING" ]; then
1773 echo "Incorrect multiop output: $multiop_output"
1781 # reset llite stat counters
1782 clear_llite_stats(){
1783 lctl set_param -n llite.*.stats 0
1786 # sum llite stat items
1787 calc_llite_stats() {
1788 local res=$(lctl get_param -n llite.*.stats |
1789 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1793 # save_lustre_params(node, parameter_mask)
1794 # generate a stream of formatted strings (<node> <param name>=<param value>)
1795 save_lustre_params() {
1797 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1800 # restore lustre parameters from input stream, produces by save_lustre_params
1801 restore_lustre_params() {
1805 while IFS=" =" read node name val; do
1806 do_node $node "lctl set_param -n $name $val"