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`}
79 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
80 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
81 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
82 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
83 [ ! -f "$LFS" ] && export LFS=$(which lfs)
84 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
85 if [ ! -f "$L_GETIDENTITY" ]; then
86 if `which l_getidentity > /dev/null 2>&1`; then
87 export L_GETIDENTITY=$(which l_getidentity)
89 export L_GETIDENTITY=NONE
92 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
93 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
94 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
95 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
96 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
97 export FSYTPE=${FSTYPE:-"ldiskfs"}
98 export NAME=${NAME:-local}
99 export LPROC=/proc/fs/lustre
100 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
101 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
102 export LGSSD=$(which lgssd)
103 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
104 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
105 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
107 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
109 if [ "$ACCEPTOR_PORT" ]; then
110 export PORT_OPT="--port $ACCEPTOR_PORT"
115 echo "Using GSS/krb5 ptlrpc security flavor"
126 IDENTITY_UPCALL=false
130 # Paths on remote nodes, if different
131 export RLUSTRE=${RLUSTRE:-$LUSTRE}
132 export RPWD=${RPWD:-$PWD}
133 export I_MOUNTED=${I_MOUNTED:-"no"}
137 while getopts "rvf:" opt $*; do
140 r) REFORMAT=--reformat;;
146 shift $((OPTIND - 1))
149 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
158 BASE=`basename $module $EXT`
159 lsmod | grep -q ${BASE} || \
160 if [ -f ${LUSTRE}/${module}${EXT} ]; then
161 insmod ${LUSTRE}/${module}${EXT} $@
163 # must be testing a "make install" or "rpm" installation
164 # note failed to load ptlrpc_gss is considered not fatal
165 if [ "$BASE" == "ptlrpc_gss" ]; then
166 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
174 if [ -n "$MODPROBE" ]; then
178 if [ "$HAVE_MODULES" = true ]; then
184 echo Loading modules from $LUSTRE
185 load_module ../lnet/libcfs/libcfs
186 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
187 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
188 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
189 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
190 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
191 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
192 echo "lnet options: '$LNETOPTS'"
193 # note that insmod will ignore anything in modprobe.conf
194 load_module ../lnet/lnet/lnet $LNETOPTS
195 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
196 load_module ../lnet/klnds/$LNETLND
197 load_module lvfs/lvfs
198 load_module obdclass/obdclass
199 load_module ptlrpc/ptlrpc
200 load_module ptlrpc/gss/ptlrpc_gss
201 # Now, some modules depend on lquota without USE_QUOTA check,
202 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
203 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
204 load_module quota/lquota
212 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
213 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
214 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
219 load_module lvfs/fsfilt_$FSTYPE
223 load_module obdfilter/obdfilter
226 load_module llite/lustre
227 load_module llite/llite_lloop
228 rm -f $TMP/ogdb-$HOSTNAME
230 [ -d /r ] && OGDB="/r/tmp"
231 $LCTL modules > $OGDB/ogdb-$HOSTNAME
233 # 'mount' doesn't look in $PATH, just sbin
234 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
238 if [ `uname -r | cut -c 3` -eq 4 ]; then
246 MODULES=$($LCTL modules | awk '{ print $2 }')
247 while [ -n "$MODULES" ]; do
249 $RMMOD $MODULES > /dev/null 2>&1 || true
250 MODULES=$($LCTL modules | awk '{ print $2 }')
251 if [ -z "$MODULES" ]; then
255 echo "waiting, $((MAX - WAIT)) secs left"
257 if [ $WAIT -eq $MAX ]; then
258 echo "LNET modules $MODULES will not unload"
266 wait_exit_ST client # bug 12845
268 lsmod | grep libcfs > /dev/null && $LCTL dl
269 local MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
270 $RMMOD $MODULES > /dev/null 2>&1 || true
271 # do it again, in case we tried to unload ksocklnd too early
272 MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
273 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
274 lsmod | grep libcfs > /dev/null && $LCTL dk $TMP/debug
276 MODULES=$($LCTL modules | awk '{ print $2 }')
277 if [ -n "$MODULES" ]; then
278 echo "Modules still loaded: "
280 if [ "$(lctl dl)" ]; then
281 echo "Lustre still loaded"
286 echo "Lustre stopped but LNET is still loaded, waiting..."
287 wait_for_lnet || return 3
293 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
294 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
295 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
296 echo "$LEAK_LUSTRE" 1>&2
297 echo "$LEAK_PORTALS" 1>&2
298 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
299 echo "Memory leaks detected"
300 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
303 echo "modules unloaded."
307 check_gss_daemon_facet() {
311 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
312 if [ $num -ne 1 ]; then
313 echo "$num instance of $dname on $facet"
322 do_facet $facet "killall -2 $@ 2>/dev/null || true"
325 start_gss_daemons() {
327 for num in `seq $MDSCOUNT`; do
328 do_facet mds$num "$LSVCGSSD -v"
330 do_facet mds$num "$LGSSD -v"
334 for num in `seq $OSTCOUNT`; do
335 do_facet ost$num "$LSVCGSSD -v"
338 # FIXME: is "client" the right facet name?
340 do_facet client "$LGSSD -v"
343 # wait daemons entering "stable" status
347 # check daemons are running
349 for num in `seq $MDSCOUNT`; do
350 check_gss_daemon_facet mds$num lsvcgssd
352 check_gss_daemon_facet mds$num lgssd
355 for num in `seq $OSTCOUNT`; do
356 check_gss_daemon_facet ost$num lsvcgssd
359 check_gss_daemon_facet client lgssd
364 for num in `seq $MDSCOUNT`; do
365 send_sigint mds$num lsvcgssd lgssd
367 for num in `seq $OSTCOUNT`; do
368 send_sigint ost$num lsvcgssd
370 send_sigint client lgssd
382 # maybe cleanup credential cache?
388 local device=`mdsdevname $num`
389 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
395 local device=`ostdevname $num`
396 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
404 local dev=${facet}_dev
405 local opt=${facet}_opt
406 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
407 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
409 if [ $RC -ne 0 ]; then
410 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
411 echo "Start of ${device} on ${facet} failed ${RC}"
413 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
414 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
415 lctl set_param debug_mb=${DEBUG_SIZE}; \
421 # start facet device options
427 eval export ${facet}_dev=${device}
428 eval export ${facet}_opt=\"$@\"
429 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
432 if [ $RC -eq 0 ]; then
433 label=$(do_facet ${facet} "e2label ${device}")
434 [ -z "$label" ] && echo no label for ${device} && exit 1
435 eval export ${facet}_svc=${label}
436 echo Started ${label}
445 HOST=`facet_active_host $facet`
446 [ -z $HOST ] && echo stop: no host for $facet && return 0
448 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
449 if [ ${running} -ne 0 ]; then
450 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
451 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
454 # umount should block, but we should wait for unrelated obd's
455 # like the MGS or MGC to also stop.
456 wait_exit_ST ${facet}
463 # Only supply -o to mount if we have options
464 if [ -n "$MOUNTOPT" ]; then
465 OPTIONS="-o $MOUNTOPT"
467 local device=$MGSNID:/$FSNAME
468 if [ -z "$mnt" -o -z "$FSNAME" ]; then
469 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
473 echo "Starting client: $client: $OPTIONS $device $mnt"
474 do_node $client mkdir -p $mnt
475 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
477 do_node $client "lctl set_param debug=$PTLDEBUG;
478 lctl set_param subsystem_debug=${SUBSYSTEM# };
479 lctl set_param debug_mb=${DEBUG_SIZE}"
480 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
488 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
489 if [ $running -ne 0 ]; then
490 echo "Stopping client $client $mnt (opts:$force)"
491 lsof | grep "$mnt" || true
492 do_node $client umount $force $mnt
496 zconf_mount_clients() {
502 # Only supply -o to mount if we have options
503 if [ -n "$MOUNTOPT" ]; then
504 OPTIONS="-o $MOUNTOPT"
506 local device=$MGSNID:/$FSNAME
507 if [ -z "$mnt" -o -z "$FSNAME" ]; then
508 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
512 echo "Starting client $clients: $OPTIONS $device $mnt"
513 do_nodes $clients mkdir -p $mnt
514 do_nodes $clients mount -t lustre $OPTIONS $device $mnt || return 1
516 do_nodes $clients "sysctl -w lnet.debug=$PTLDEBUG;
517 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
518 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
523 zconf_umount_clients() {
528 echo "Umounting clients: $clients"
529 echo "Stopping client $client $mnt (opts:$force)"
530 do_nodes $clients umount $force $mnt
535 if [ "$FAILURE_MODE" = HARD ]; then
536 $POWER_DOWN `facet_active_host $facet`
538 elif [ "$FAILURE_MODE" = SOFT ]; then
545 if [ "$FAILURE_MODE" = HARD ]; then
546 $POWER_UP `facet_active_host $facet`
552 # verify that lustre actually cleaned up properly
554 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
555 error "LBUG/LASSERT detected"
556 BUSY=`dmesg | grep -i destruct || true`
559 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
562 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
563 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
564 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
565 echo "$0: $LEAK_LUSTRE" 1>&2
566 echo "$0: $LEAK_PORTALS" 1>&2
567 echo "$0: Memory leak(s) detected..." 1>&2
568 mv $TMP/debug $TMP/debug-leak.`date +%s`
572 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
573 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
575 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
576 echo "$0: modules still loaded..." 1>&2
583 wait_delete_completed () {
584 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
585 $LPROC/osc/*/kbytesavail`
589 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
591 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
592 $LPROC/osc/*/kbytesavail`
593 [ "$TOTAL" -eq "$TOTALPREV" ] && break
594 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
598 echo "Delete completed."
603 check_network "$HOST" 900
604 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
609 HOST=`facet_active_host $facet`
613 wait_mds_recovery_done () {
614 local timeout=`do_facet mds lctl get_param -n timeout`
615 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
616 # as we are in process of changing obd_timeout in different ways
617 # let's set MAX longer than that
618 MAX=$(( timeout * 4 ))
620 while [ $WAIT -lt $MAX ]; do
621 STATUS=`do_facet $SINGLEMDS grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
622 echo $STATUS | grep COMPLETE && return 0
625 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
627 echo "MDS recovery not done in $MAX sec"
636 # conf-sanity 31 takes a long time cleanup
637 while [ $WAIT -lt 300 ]; do
638 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
639 [ -z "${running}" ] && return 0
640 echo "waited $WAIT for${running}"
641 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
643 WAIT=$((WAIT + INTERVAL))
645 echo "service didn't stop after $WAIT seconds. Still running:"
651 # not every config has many clients
652 if [ ! -z "$CLIENTS" ]; then
653 $PDSH $CLIENTS "df $MOUNT" > /dev/null
655 df $MOUNT > /dev/null
660 uname -n >> $MOUNT/recon
661 if [ ! -z "$CLIENTS" ]; then
662 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
664 echo Connected clients:
666 ls -l $MOUNT/recon > /dev/null
672 echo "Failing $facet on node `facet_active_host $facet`"
673 shutdown_facet $facet
677 echo "df pid is $DFPID"
679 TO=`facet_active_host $facet`
680 echo "Failover $facet to $TO"
682 mount_facet $facet || error "Restart of $facet failed"
693 local svc=${facet}_svc
694 do_facet $facet $LCTL --device %${!svc} readonly
695 do_facet $facet $LCTL --device %${!svc} notransno
696 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
697 $LCTL mark "local REPLAY BARRIER on ${!svc}"
700 replay_barrier_nodf() {
701 local facet=$1 echo running=${running}
703 local svc=${facet}_svc
704 echo Replay barrier on ${!svc}
705 do_facet $facet $LCTL --device %${!svc} readonly
706 do_facet $facet $LCTL --device %${!svc} notransno
707 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
708 $LCTL mark "local REPLAY BARRIER on ${!svc}"
712 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
713 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
717 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
718 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
722 facet_failover $* || error "failover: $?"
723 df $MOUNT || error "post-failover df: $?"
728 facet_failover $facet
735 mount_facet $facet -o abort_recovery
736 df $MOUNT || echo "first df failed: $?"
738 df $MOUNT || error "post-failover df: $?"
742 echo There is no lmc. This is mountconf, baby.
747 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
748 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
754 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
760 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
761 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
762 if [ -z "$ID" ]; then
763 echo "Could not get a ptl id for $1..."
772 h2name_or_ip "$1" "tcp"
777 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
778 if type __h2elan >/dev/null 2>&1; then
781 ID=`echo $1 | sed 's/[^0-9]*//g'`
789 h2name_or_ip "$1" "openib"
794 h2name_or_ip "$1" "o2ib"
800 varname=${facet}_HOST
801 if [ -z "${!varname}" ]; then
802 if [ "${facet:0:3}" == "ost" ]; then
803 eval ${facet}_HOST=${ost_HOST}
811 local activevar=${facet}active
813 if [ -f $TMP/${facet}active ] ; then
814 source $TMP/${facet}active
818 if [ -z "$active" ] ; then
825 facet_active_host() {
827 local active=`facet_active $facet`
828 if [ "$facet" == client ]; then
831 echo `facet_host $active`
837 failover=${facet}failover
838 host=`facet_host $failover`
839 [ -z "$host" ] && return
840 curactive=`facet_active $facet`
841 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
842 eval export ${facet}active=$facet
844 eval export ${facet}active=$failover
846 # save the active host for this facet
847 activevar=${facet}active
848 echo "$activevar=${!activevar}" > $TMP/$activevar
855 if [ "$HOST" = "$HOSTNAME" ]; then
857 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
858 echo "cannot run remote command on $HOST with $myPDSH"
862 echo "CMD: $HOST $@" >&2
863 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
866 if [ "$myPDSH" = "rsh" ]; then
867 # we need this because rsh does not return exit code of an executed command
868 local command_status="$TMP/cs"
869 rsh $HOST ":> $command_status"
870 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
871 cd $RPWD; sh -c \"$@\") ||
872 echo command failed >$command_status"
873 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
876 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
877 return ${PIPESTATUS[0]}
885 # split list to local and remote
886 local rnodes=$(echo " $nodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
888 if [ "$(get_node_count $nodes)" != "$(get_node_count $rnodes)" ]; then
892 [ -z "$(echo $rnodes)" ] && return 0
894 # This is part from do_node
897 rnodes=$(comma_list $rnodes)
898 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ] && \
899 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
902 echo "CMD: $rnodes $@" >&2
903 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
906 if [ "$myPDSH" = "rsh" ]; then
907 # we need this because rsh does not return exit code of an executed command
908 local command_status="$TMP/cs"
909 rsh $rnodes ":> $command_status"
910 rsh $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
911 cd $RPWD; sh -c \"$@\") ||
912 echo command failed >$command_status"
913 [ -n "$($myPDSH $rnodes cat $command_status)" ] && return 1 || true
916 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
917 return ${PIPESTATUS[0]}
924 HOST=`facet_active_host $facet`
925 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
932 # make sure its not already running
934 rm -f $TMP/${facet}active
935 do_facet ${facet} $MKFS $*
941 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
942 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
949 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
950 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
958 # make sure we are using the primary server, so test-framework will
959 # be able to clean up properly.
960 activemds=`facet_active mds1`
961 if [ $activemds != "mds1" ]; then
965 # assume client mount is local
966 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
967 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
969 if [ -n "$CLIENTS" ]; then
970 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
971 zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
974 [ "$CLIENTONLY" ] && return
975 # The add fn does rm ${facet}active file, this would be enough
976 # if we use do_facet <facet> only after the facet added, but
977 # currently we use do_facet mds in local.sh
978 for num in `seq $MDSCOUNT`; do
980 rm -f ${TMP}/mds${num}active
983 for num in `seq $OSTCOUNT`; do
985 rm -f $TMP/ost${num}active
1000 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1004 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1006 if [ ! -z $SEC ]; then
1007 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1008 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1012 # We need ldiskfs here, may as well load them all
1014 [ "$CLIENTONLY" ] && return
1015 echo "Formatting mdts, osts"
1016 for num in `seq $MDSCOUNT`; do
1017 echo "Format mds$num: $(mdsdevname $num)"
1019 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1021 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1025 for num in `seq $OSTCOUNT`; do
1026 echo "Format ost$num: $(ostdevname $num)"
1028 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1030 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1036 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1040 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1044 # 0: success, the old identity set already.
1045 # 1: success, the old identity does not set.
1050 local j=`expr $num - 1`
1051 local MDT="`do_facet mds$num find $LPROC/mdt/ -name \*MDT\*$j -printf %f 2>/dev/null || true`"
1053 if [ -z "$MDT" ]; then
1057 local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
1060 do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
1062 do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
1065 do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
1067 if [ $old = "NONE" ]; then
1076 zconf_umount `hostname` $1 || error "umount failed"
1077 zconf_mount `hostname` $1 || error "mount failed"
1084 do_facet $facet lsmod | grep -q obdclass || \
1085 do_facet $facet "modprobe obdclass"
1087 do_facet $facet "lctl set_param timeout=$timeout"
1093 if [ -z "$CLIENTONLY" ]; then
1094 echo "Setup mdts, osts"
1095 for num in `seq $MDSCOUNT`; do
1096 DEVNAME=$(mdsdevname $num)
1097 echo $REFORMAT | grep -q "reformat" \
1098 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1099 set_obd_timeout mds$num $TIMEOUT
1100 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1102 # We started mds, now we should set failover variables properly.
1103 # Set mds${num}failover_HOST if it is not set (the default failnode).
1104 if [ -z "$mds${num}failover_HOST" ]; then
1105 mds${num}failover_HOST=$(facet_host mds$num)
1108 if [ $IDENTITY_UPCALL != "default" ]; then
1109 switch_identity $num $IDENTITY_UPCALL
1112 for num in `seq $OSTCOUNT`; do
1113 DEVNAME=$(ostdevname $num)
1114 set_obd_timeout ost$num $TIMEOUT
1115 start ost$num $DEVNAME $OST_MOUNT_OPTS
1117 # We started ost$num, now we should set ost${num}failover variable properly.
1118 # Set ost${num}failover_HOST if it is not set (the default failnode).
1119 varname=ost${num}failover_HOST
1120 if [ -z "${!varname}" ]; then
1121 eval ost${num}failover_HOST=$(facet_host ost${num})
1126 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1128 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1130 if [ "$MOUNT_2" ]; then
1131 mount_client $MOUNT2
1132 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1135 # by remounting mdt before ost, initial connect from mdt to ost might
1136 # timeout because ost is not ready yet. wait some time to its fully
1137 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1138 # by a context negotiation rpc with $TIMEOUT.
1139 # FIXME better by monitoring import status.
1141 sleep $((TIMEOUT + 5))
1147 mounted_lustre_filesystems() {
1148 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1151 check_and_setup_lustre() {
1152 MOUNTED="`mounted_lustre_filesystems`"
1153 if [ -z "$MOUNTED" ]; then
1154 [ "$REFORMAT" ] && formatall
1156 MOUNTED="`mounted_lustre_filesystems`"
1157 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1158 export I_MOUNTED=yes
1160 if [ "$ONLY" == "setup" ]; then
1165 cleanup_and_setup_lustre() {
1166 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1167 lctl set_param debug=0 || true
1169 if [ "$ONLY" == "cleanup" ]; then
1173 check_and_setup_lustre
1176 check_and_cleanup_lustre() {
1177 if [ "`mount | grep $MOUNT`" ]; then
1178 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1180 if [ "$I_MOUNTED" = "yes" ]; then
1181 cleanupall -f || error "cleanup failed"
1193 while [ $NETWORK -eq 0 ]; do
1194 ping -c 1 -w 3 $1 > /dev/null
1195 if [ $? -eq 0 ]; then
1199 echo "waiting for $1, $((MAX - WAIT)) secs left"
1202 if [ $WAIT -gt $MAX ]; then
1203 echo "Network not available"
1209 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1220 # the sed converts spaces to commas, but leaves the last space
1221 # alone, so the line doesn't end with a comma.
1222 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1226 (cd `dirname $1`; echo $PWD/`basename $1`)
1229 ##################################
1233 # OBD_FAIL_MDS_ALL_REQUEST_NET
1235 do_facet mds lctl set_param fail_loc=0x123
1236 do_facet client "$1" || RC=$?
1237 do_facet mds lctl set_param fail_loc=0
1242 # OBD_FAIL_MDS_ALL_REPLY_NET
1244 do_facet mds lctl set_param fail_loc=0x122
1245 do_facet client "$@" || RC=$?
1246 do_facet mds lctl set_param fail_loc=0
1250 drop_reint_reply() {
1251 # OBD_FAIL_MDS_REINT_NET_REP
1253 do_facet mds lctl set_param fail_loc=0x119
1254 do_facet client "$@" || RC=$?
1255 do_facet mds lctl set_param fail_loc=0
1260 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1262 do_facet ost1 lctl set_param fail_loc=0x214
1263 do_facet client "$1" || RC=$?
1264 do_facet client "sync"
1265 do_facet ost1 lctl set_param fail_loc=0
1269 drop_ldlm_cancel() {
1270 #define OBD_FAIL_LDLM_CANCEL 0x304
1272 do_facet client lctl set_param fail_loc=0x304
1273 do_facet client "$@" || RC=$?
1274 do_facet client lctl set_param fail_loc=0
1278 drop_bl_callback() {
1279 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1281 do_facet client lctl set_param fail_loc=0x305
1282 do_facet client "$@" || RC=$?
1283 do_facet client lctl set_param fail_loc=0
1288 #define OBD_FAIL_LDLM_REPLY 0x30c
1290 do_facet mds lctl set_param fail_loc=0x30c
1291 do_facet client "$@" || RC=$?
1292 do_facet mds lctl set_param fail_loc=0
1300 echo "clearing fail_loc on $facet"
1301 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1304 set_nodes_failloc () {
1308 for node in $nodes ; do
1309 do_node $node lctl set_param fail_loc=$2
1313 set_nodes_failloc () {
1317 for node in $nodes ; do
1318 do_node $node sysctl -w lustre.fail_loc=$2
1322 cancel_lru_locks() {
1323 $LCTL mark "cancel_lru_locks $1 start"
1324 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1325 [ -f $d/lru_size ] && echo clear > $d/lru_size
1326 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1328 $LCTL mark "cancel_lru_locks $1 stop"
1333 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1334 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1335 echo "$DEFAULT_LRU_SIZE"
1341 test "x$NS" = "x" && NS="mdc"
1342 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1344 log "Enable lru resize for $(basename $D)"
1349 lru_resize_disable()
1352 test "x$NS" = "x" && NS="mdc"
1353 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1355 log "Disable lru resize for $(basename $D)"
1356 DEFAULT_LRU_SIZE=$(default_lru_size)
1357 echo "$DEFAULT_LRU_SIZE" > $F
1362 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1363 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1364 echo there is still data in page cache $a ?
1373 DEBUGSAVE="$(lctl get_param -n debug)"
1377 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1381 ##################################
1383 ##################################
1386 local TYPE=${TYPE:-"FAIL"}
1388 lctl set_param fail_loc=0 2>/dev/null || true
1389 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1390 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1391 echo "Dumping lctl log to $ERRLOG"
1392 # We need to dump the logs on all nodes
1393 local NODES=$(nodes_list)
1394 for NODE in $NODES; do
1395 do_node $NODE $LCTL dk $ERRLOG
1398 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1403 $FAIL_ON_ERROR && exit 1 || true
1411 # use only if we are ignoring failures for this test, bugno required.
1412 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1413 # e.g. error_ignore 5494 "your message"
1415 TYPE="IGNORE (bz$1)"
1421 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1422 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1425 build_test_filter() {
1426 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1430 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1431 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1432 [ "$EXCEPT_SLOW" ] && \
1433 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1434 for E in $EXCEPT $ALWAYS_EXCEPT; do
1435 eval EXCEPT_${E}=true
1437 for E in $EXCEPT_SLOW; do
1438 eval EXCEPT_SLOW_${E}=true
1440 for G in $GRANT_CHECK_LIST; do
1441 eval GCHECK_ONLY_${G}=true
1450 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1454 export base=`basetest $1`
1455 if [ ! -z "$ONLY" ]; then
1457 if [ ${!testname}x != x ]; then
1462 if [ ${!testname}x != x ]; then
1470 if [ ${!testname}x != x ]; then
1471 TESTNAME=test_$1 skip "skipping excluded test $1"
1474 testname=EXCEPT_$base
1475 if [ ${!testname}x != x ]; then
1476 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1479 testname=EXCEPT_SLOW_$1
1480 if [ ${!testname}x != x ]; then
1481 TESTNAME=test_$1 skip "skipping SLOW test $1"
1484 testname=EXCEPT_SLOW_$base
1485 if [ ${!testname}x != x ]; then
1486 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1495 EQUALS="======================================================================"
1499 local suffixlen=$((${#EQUALS} - ${#msg}))
1500 [ $suffixlen -lt 5 ] && suffixlen=5
1501 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1506 lsmod | grep lnet > /dev/null || load_modules
1517 local NODES=$(nodes_list)
1518 for NODE in $NODES; do
1519 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1525 strace -o $TMP/$1.strace -ttt $*
1527 log "FINISHED: $*: rc $RC"
1536 FFREE=`cat /proc/fs/lustre/osd/*MDT*/filesfree`
1537 FTOTAL=`cat /proc/fs/lustre/osd/*MDT*/filestotal`
1538 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1542 local myNODES=$(nodes_list)
1545 for NODE in $myNODES; do
1546 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1554 export tdir=d0.${TESTSUITE}/d${base}
1555 local SAVE_UMASK=`umask`
1560 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1562 export TESTNAME=test_$testnum
1563 test_${testnum} || error "test_$testnum failed with $?"
1567 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1568 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1569 error "LBUG/LASSERT detected"
1570 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1571 pass "($((`date +%s` - $BEFORE))s)"
1572 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1580 (cd `dirname $1`; echo $PWD/`basename $1`)
1584 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1585 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1590 export base=`basetest $1`
1591 [ "$CHECK_GRANT" == "no" ] && return 0
1593 testname=GCHECK_ONLY_${base}
1594 [ ${!testname}x == x ] && return 0
1596 echo -n "checking grant......"
1598 # write some data to sync client lost_grant
1599 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1600 for i in `seq $OSTCOUNT`; do
1601 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1602 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1603 count=1 > /dev/null 2>&1
1605 # sync all the data and make sure no pending data on server
1608 #get client grant and server grant
1610 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1611 client_grant=$((client_grant + `cat $d`))
1614 for d in ${LPROC}/obdfilter/*/tot_granted; do
1615 server_grant=$((server_grant + `cat $d`))
1618 # cleanup the check_grant file
1619 for i in `seq $OSTCOUNT`; do
1620 rm $DIR1/${tfile}_check_grant_$i
1623 #check whether client grant == server grant
1624 if [ $client_grant != $server_grant ]; then
1625 echo "failed: client:${client_grant} server: ${server_grant}"
1632 ########################
1638 ost=`echo $1 | awk -F_ '{print $3}'`
1639 if [ -z $ost ]; then
1640 ost=`echo $1 | sed 's/-osc.*//'`
1647 [ -z "$(lctl dl | grep mdt)" ]
1652 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1657 [ -z "$(lctl dl | grep ost)" ]
1662 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1666 local MDSNODES=$(facet_host $SINGLEMDS)
1669 # FIXME: Currenly we use only $SINGLEMDS,
1670 # should be fixed when we will start to test cmd.
1674 for num in `seq $MDSCOUNT`; do
1675 local myMDS=$(facet_host mds$num)
1676 MDSNODES="$MDSNODES $myMDS"
1678 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1684 local OSTNODES=$(facet_host ost1)
1687 for num in `seq $OSTCOUNT`; do
1688 local myOST=$(facet_host ost$num)
1689 OSTNODES="$OSTNODES $myOST"
1691 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1697 # FIXME. We need a list of clients
1698 local myNODES=$HOSTNAME
1701 # CLIENTS (if specified) contains the local client
1702 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1704 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1705 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1708 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1715 lctl get_param version | grep -q patchless
1720 echo $nodes | wc -w || true
1724 local nodes=$(osts_nodes)
1725 local osscount=$(get_node_count "$nodes")
1726 [ ! "$OSTCOUNT" = "$osscount" ]
1729 check_runas_id_ret() {
1734 if [ -z "$myRUNAS" ]; then
1735 error_exit "myRUNAS command must be specified for check_runas_id"
1738 $myRUNAS krb5_login.sh || \
1739 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1741 mkdir $DIR/d0_runas_test
1743 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1744 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1745 rm -rf $DIR/d0_runas_test
1753 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1754 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1755 Please set RUNAS_ID to some UID which exists on MDS and client or
1756 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1759 # Run multiop in the background, but wait for it to print
1760 # "PAUSING" to its stdout before returning from this function.
1761 multiop_bg_pause() {
1762 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1766 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1769 echo "$MULTIOP_PROG $FILE v$ARGS"
1770 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1772 echo "TMPPIPE=${TMPPIPE}"
1773 read -t 60 multiop_output < $TMPPIPE
1774 if [ $? -ne 0 ]; then
1779 if [ "$multiop_output" != "PAUSING" ]; then
1780 echo "Incorrect multiop output: $multiop_output"
1788 # reset llite stat counters
1789 clear_llite_stats(){
1790 lctl set_param -n llite.*.stats 0
1793 # sum llite stat items
1794 calc_llite_stats() {
1795 local res=$(lctl get_param -n llite.*.stats |
1796 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1800 # save_lustre_params(node, parameter_mask)
1801 # generate a stream of formatted strings (<node> <param name>=<param value>)
1802 save_lustre_params() {
1804 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1807 # restore lustre parameters from input stream, produces by save_lustre_params
1808 restore_lustre_params() {
1812 while IFS=" =" read node name val; do
1813 do_node $node "lctl set_param -n $name $val"