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=false
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`
73 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
75 [ -d /r ] && export ROOT=${ROOT:-/r}
76 export TMP=${TMP:-$ROOT/tmp}
77 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
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"}
108 if [ "$ACCEPTOR_PORT" ]; then
109 export PORT_OPT="--port $ACCEPTOR_PORT"
114 echo "Using GSS/krb5 ptlrpc security flavor"
125 IDENTITY_UPCALL=false
129 # Paths on remote nodes, if different
130 export RLUSTRE=${RLUSTRE:-$LUSTRE}
131 export RPWD=${RPWD:-$PWD}
132 export I_MOUNTED=${I_MOUNTED:-"no"}
136 while getopts "rvf:" opt $*; do
139 r) REFORMAT=--reformat;;
145 shift $((OPTIND - 1))
148 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
160 BASE=`basename $module $EXT`
161 lsmod | grep -q ${BASE} || \
162 if [ -f ${LUSTRE}/${module}${EXT} ]; then
163 insmod ${LUSTRE}/${module}${EXT} $@
165 # must be testing a "make install" or "rpm" installation
166 # note failed to load ptlrpc_gss is considered not fatal
167 if [ "$BASE" == "ptlrpc_gss" ]; then
168 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
176 if [ -n "$MODPROBE" ]; then
180 # we already loaded ?
181 have_modules && return 0
183 echo Loading modules from $LUSTRE
184 load_module ../lnet/libcfs/libcfs
185 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
186 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
187 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
188 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
189 echo "lnet options: '$LNETOPTS'"
190 # note that insmod will ignore anything in modprobe.conf
191 load_module ../lnet/lnet/lnet $LNETOPTS
192 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
193 load_module ../lnet/klnds/$LNETLND
194 load_module lvfs/lvfs
195 load_module obdclass/obdclass
196 load_module ptlrpc/ptlrpc
197 load_module ptlrpc/gss/ptlrpc_gss
198 # Now, some modules depend on lquota without USE_QUOTA check,
199 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
200 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
201 load_module quota/lquota
209 if [ -z "$CLIENTONLY" ]; then
210 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
215 load_module lvfs/fsfilt_$FSTYPE
219 load_module obdfilter/obdfilter
222 load_module llite/lustre
223 load_module llite/llite_lloop
224 rm -f $TMP/ogdb-`hostname`
225 $LCTL modules > $TMP/ogdb-`hostname`
226 # 'mount' doesn't look in $PATH, just sbin
227 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
231 if [ `uname -r | cut -c 3` -eq 4 ]; then
239 MODULES=$($LCTL modules | awk '{ print $2 }')
240 while [ -n "$MODULES" ]; do
242 $RMMOD $MODULES > /dev/null 2>&1 || true
243 MODULES=$($LCTL modules | awk '{ print $2 }')
244 if [ -z "$MODULES" ]; then
248 echo "waiting, $((MAX - WAIT)) secs left"
250 if [ $WAIT -eq $MAX ]; then
251 echo "LNET modules $MODULES will not unload"
259 wait_exit_ST client # bug 12845
261 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
262 local MODULES=$($LCTL modules | awk '{ print $2 }')
263 $RMMOD $MODULES > /dev/null 2>&1 || true
264 # do it again, in case we tried to unload ksocklnd too early
265 MODULES=$($LCTL modules | awk '{ print $2 }')
266 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
267 MODULES=$($LCTL modules | awk '{ print $2 }')
268 if [ -n "$MODULES" ]; then
269 echo "Modules still loaded: "
271 if [ -e $LPROC ]; then
272 echo "Lustre still loaded"
273 cat $LPROC/devices || true
277 echo "Lustre stopped but LNET is still loaded, waiting..."
278 wait_for_lnet || return 3
282 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
283 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
284 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
285 echo "$LEAK_LUSTRE" 1>&2
286 echo "$LEAK_PORTALS" 1>&2
287 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
288 echo "Memory leaks detected"
289 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
292 echo "modules unloaded."
296 check_gss_daemon_facet() {
300 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
301 if [ $num -ne 1 ]; then
302 echo "$num instance of $dname on $facet"
311 do_facet $facet "killall -2 $@ 2>/dev/null || true"
314 start_gss_daemons() {
316 for num in `seq $MDSCOUNT`; do
317 do_facet mds$num "$LSVCGSSD -v"
319 do_facet mds$num "$LGSSD -v"
323 for num in `seq $OSTCOUNT`; do
324 do_facet ost$num "$LSVCGSSD -v"
327 # FIXME: is "client" the right facet name?
329 do_facet client "$LGSSD -v"
332 # wait daemons entering "stable" status
336 # check daemons are running
338 for num in `seq $MDSCOUNT`; do
339 check_gss_daemon_facet mds$num lsvcgssd
341 check_gss_daemon_facet mds$num lgssd
344 for num in `seq $OSTCOUNT`; do
345 check_gss_daemon_facet ost$num lsvcgssd
348 check_gss_daemon_facet client lgssd
353 for num in `seq $MDSCOUNT`; do
354 send_sigint mds$num lsvcgssd lgssd
356 for num in `seq $OSTCOUNT`; do
357 send_sigint ost$num lsvcgssd
359 send_sigint client lgssd
371 # maybe cleanup credential cache?
377 local device=`mdsdevname $num`
378 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
384 local device=`ostdevname $num`
385 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
390 # start facet device options
396 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
397 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
398 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
400 if [ $RC -ne 0 ]; then
401 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
402 echo Start of ${device} on ${facet} failed ${RC}
404 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
405 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
406 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
408 do_facet ${facet} sync
409 label=$(do_facet ${facet} "e2label ${device}")
410 [ -z "$label" ] && echo no label for ${device} && exit 1
411 eval export ${facet}_svc=${label}
412 eval export ${facet}_dev=${device}
413 eval export ${facet}_opt=\"$@\"
414 echo Started ${label}
423 HOST=`facet_active_host $facet`
424 [ -z $HOST ] && echo stop: no host for $facet && return 0
426 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
427 if [ ${running} -ne 0 ]; then
428 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
429 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
432 # umount should block, but we should wait for unrelated obd's
433 # like the MGS or MGC to also stop.
434 wait_exit_ST ${facet}
441 # Only supply -o to mount if we have options
442 if [ -n "$MOUNTOPT" ]; then
443 OPTIONS="-o $MOUNTOPT"
445 local device=$MGSNID:/$FSNAME
446 if [ -z "$mnt" -o -z "$FSNAME" ]; then
447 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
451 echo "Starting client: $OPTIONS $device $mnt"
452 do_node $client mkdir -p $mnt
453 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
455 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
456 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
457 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
458 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
466 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
467 if [ $running -ne 0 ]; then
468 echo "Stopping client $mnt (opts:$force)"
469 do_node $client umount $force $mnt
475 if [ "$FAILURE_MODE" = HARD ]; then
476 $POWER_DOWN `facet_active_host $facet`
478 elif [ "$FAILURE_MODE" = SOFT ]; then
485 if [ "$FAILURE_MODE" = HARD ]; then
486 $POWER_UP `facet_active_host $facet`
492 # verify that lustre actually cleaned up properly
494 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
495 error "LBUG/LASSERT detected"
496 BUSY=`dmesg | grep -i destruct || true`
499 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
502 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
503 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
504 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
505 echo "$0: $LEAK_LUSTRE" 1>&2
506 echo "$0: $LEAK_PORTALS" 1>&2
507 echo "$0: Memory leak(s) detected..." 1>&2
508 mv $TMP/debug $TMP/debug-leak.`date +%s`
512 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
513 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
515 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
516 echo "$0: modules still loaded..." 1>&2
523 wait_delete_completed () {
524 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
525 $LPROC/osc/*/kbytesavail`
529 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
531 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
532 $LPROC/osc/*/kbytesavail`
533 [ "$TOTAL" -eq "$TOTALPREV" ] && break
534 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
538 echo "Delete completed."
543 check_network "$HOST" 900
544 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
549 HOST=`facet_active_host $facet`
553 wait_mds_recovery_done () {
554 local timeout=`do_facet mds cat /proc/sys/lustre/timeout`
555 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
556 # as we are in process of changing obd_timeout in different ways
557 # let's set MAX longer than that
558 MAX=$(( timeout * 4 ))
560 while [ $WAIT -lt $MAX ]; do
561 STATUS=`do_facet mds grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
562 echo $STATUS | grep COMPLETE && return 0
565 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
567 echo "MDS recovery not done in $MAX sec"
576 # conf-sanity 31 takes a long time cleanup
577 while [ $WAIT -lt 300 ]; do
578 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
579 [ -z "${running}" ] && return 0
580 echo "waited $WAIT for${running}"
581 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
583 WAIT=$((WAIT + INTERVAL))
585 echo "service didn't stop after $WAIT seconds. Still running:"
591 # not every config has many clients
592 if [ ! -z "$CLIENTS" ]; then
593 $PDSH $CLIENTS "df $MOUNT" > /dev/null
598 uname -n >> $MOUNT/recon
599 if [ ! -z "$CLIENTS" ]; then
600 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
602 echo Connected clients:
604 ls -l $MOUNT/recon > /dev/null
610 echo "Failing $facet on node `facet_active_host $facet`"
611 shutdown_facet $facet
615 echo "df pid is $DFPID"
617 TO=`facet_active_host $facet`
618 echo "Failover $facet to $TO"
620 local dev=${facet}_dev
621 local opt=${facet}_opt
622 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
633 local svc=${facet}_svc
634 do_facet $facet $LCTL --device %${!svc} readonly
635 do_facet $facet $LCTL --device %${!svc} notransno
636 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
637 $LCTL mark "local REPLAY BARRIER on ${!svc}"
640 replay_barrier_nodf() {
641 local facet=$1 echo running=${running}
643 local svc=${facet}_svc
644 echo Replay barrier on ${!svc}
645 do_facet $facet $LCTL --device %${!svc} readonly
646 do_facet $facet $LCTL --device %${!svc} notransno
647 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
648 $LCTL mark "local REPLAY BARRIER on ${!svc}"
652 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
653 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
657 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
658 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
662 facet_failover $* || error "failover: $?"
663 df $MOUNT || error "post-failover df: $?"
670 local svc=${facet}_svc
671 local dev=${facet}_dev
672 local opt=${facet}_opt
673 start $facet ${!dev} ${!opt}
674 do_facet $facet lctl --device %${!svc} abort_recovery
675 df $MOUNT || echo "first df failed: $?"
677 df $MOUNT || error "post-failover df: $?"
681 echo There is no lmc. This is mountconf, baby.
686 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
687 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
693 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
699 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
700 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
701 if [ -z "$ID" ]; then
702 echo "Could not get a ptl id for $1..."
711 h2name_or_ip "$1" "tcp"
716 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
717 if type __h2elan >/dev/null 2>&1; then
720 ID=`echo $1 | sed 's/[^0-9]*//g'`
728 h2name_or_ip "$1" "openib"
733 h2name_or_ip "$1" "o2ib"
739 varname=${facet}_HOST
740 if [ -z "${!varname}" ]; then
741 if [ "${facet:0:3}" == "ost" ]; then
742 eval ${facet}_HOST=${ost_HOST}
750 local activevar=${facet}active
752 if [ -f ./${facet}active ] ; then
753 source ./${facet}active
757 if [ -z "$active" ] ; then
764 facet_active_host() {
766 local active=`facet_active $facet`
767 if [ "$facet" == client ]; then
770 echo `facet_host $active`
776 failover=${facet}failover
777 host=`facet_host $failover`
778 [ -z "$host" ] && return
779 curactive=`facet_active $facet`
780 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
781 eval export ${facet}active=$facet
783 eval export ${facet}active=$failover
785 # save the active host for this facet
786 activevar=${facet}active
787 echo "$activevar=${!activevar}" > ./$activevar
794 if [ "$HOST" = "$(hostname)" ]; then
798 echo "CMD: $HOST $@" >&2
799 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
801 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
802 return ${PIPESTATUS[0]}
808 HOST=`facet_active_host $facet`
809 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
816 # make sure its not already running
819 do_facet ${facet} $MKFS $*
825 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
826 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
833 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
834 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
842 # make sure we are using the primary server, so test-framework will
843 # be able to clean up properly.
844 activemds=`facet_active mds1`
845 if [ $activemds != "mds1" ]; then
849 # assume client mount is local
850 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
851 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
852 [ "$CLIENTONLY" ] && return
853 for num in `seq $MDSCOUNT`; do
856 for num in `seq $OSTCOUNT`; do
871 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
875 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
877 if [ ! -z $SEC ]; then
878 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
879 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
883 # We need ldiskfs here, may as well load them all
885 [ "$CLIENTONLY" ] && return
886 echo "Formatting mdts, osts"
887 for num in `seq $MDSCOUNT`; do
888 echo "Format mds$num: $(mdsdevname $num)"
890 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
892 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
896 for num in `seq $OSTCOUNT`; do
897 echo "Format ost$num: $(ostdevname $num)"
899 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
901 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
907 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
911 # 0: success, the old identity set already.
912 # 1: success, the old identity does not set.
917 local j=`expr $num - 1`
918 local MDT="`do_facet mds$num ls -l $LPROC/mdt/ 2>/dev/null | grep MDT | awk '{print $9}' | grep $j$`"
920 if [ -z "$MDT" ]; then
924 local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
927 do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
929 do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
932 do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
934 if [ $old = "NONE" ]; then
944 if [ -z "$CLIENTONLY" ]; then
945 echo "Setup mdts, osts"
946 for num in `seq $MDSCOUNT`; do
947 DEVNAME=$(mdsdevname $num)
948 echo $REFORMAT | grep -q "reformat" \
949 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
950 start mds$num $DEVNAME $MDS_MOUNT_OPTS
951 switch_identity $num $IDENTITY_UPCALL
953 for num in `seq $OSTCOUNT`; do
954 DEVNAME=$(ostdevname $num)
955 start ost$num $DEVNAME $OST_MOUNT_OPTS
958 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
960 if [ "$MOUNT_2" ]; then
966 mounted_lustre_filesystems() {
967 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
970 check_and_setup_lustre() {
971 MOUNTED="`mounted_lustre_filesystems`"
972 if [ -z "$MOUNTED" ]; then
973 [ "$REFORMAT" ] && formatall
975 MOUNTED="`mounted_lustre_filesystems`"
976 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
979 if [ "$ONLY" == "setup" ]; then
984 cleanup_and_setup_lustre() {
985 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
986 sysctl -w lnet.debug=0 || true
988 if [ "$ONLY" == "cleanup" ]; then
992 check_and_setup_lustre
995 check_and_cleanup_lustre() {
996 if [ "`mount | grep $MOUNT`" ]; then
997 rm -rf $DIR/[Rdfs][0-9]*
998 rm -f $DIR/${TESTSUITE}/[Rdfs][1-9]*
1000 if [ "$I_MOUNTED" = "yes" ]; then
1001 cleanupall -f || error "cleanup failed"
1013 while [ $NETWORK -eq 0 ]; do
1014 ping -c 1 -w 3 $1 > /dev/null
1015 if [ $? -eq 0 ]; then
1019 echo "waiting for $1, $((MAX - WAIT)) secs left"
1022 if [ $WAIT -gt $MAX ]; then
1023 echo "Network not available"
1029 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1040 # the sed converts spaces to commas, but leaves the last space
1041 # alone, so the line doesn't end with a comma.
1042 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1046 (cd `dirname $1`; echo $PWD/`basename $1`)
1049 ##################################
1053 # OBD_FAIL_MDS_ALL_REQUEST_NET
1055 do_facet mds sysctl -w lustre.fail_loc=0x123
1056 do_facet client "$1" || RC=$?
1057 do_facet mds sysctl -w lustre.fail_loc=0
1062 # OBD_FAIL_MDS_ALL_REPLY_NET
1064 do_facet mds sysctl -w lustre.fail_loc=0x122
1065 do_facet client "$@" || RC=$?
1066 do_facet mds sysctl -w lustre.fail_loc=0
1070 drop_reint_reply() {
1071 # OBD_FAIL_MDS_REINT_NET_REP
1073 do_facet mds sysctl -w lustre.fail_loc=0x119
1074 do_facet client "$@" || RC=$?
1075 do_facet mds sysctl -w lustre.fail_loc=0
1080 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1082 do_facet ost1 sysctl -w lustre.fail_loc=0x214
1083 do_facet client "$1" || RC=$?
1084 do_facet client "sync"
1085 do_facet ost1 sysctl -w lustre.fail_loc=0
1089 drop_ldlm_cancel() {
1090 #define OBD_FAIL_LDLM_CANCEL 0x304
1092 do_facet client sysctl -w lustre.fail_loc=0x304
1093 do_facet client "$@" || RC=$?
1094 do_facet client sysctl -w lustre.fail_loc=0
1098 drop_bl_callback() {
1099 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1101 do_facet client sysctl -w lustre.fail_loc=0x305
1102 do_facet client "$@" || RC=$?
1103 do_facet client sysctl -w lustre.fail_loc=0
1108 #define OBD_FAIL_LDLM_REPLY 0x30c
1110 do_facet mds sysctl -w lustre.fail_loc=0x30c
1111 do_facet client "$@" || RC=$?
1112 do_facet mds sysctl -w lustre.fail_loc=0
1120 echo "clearing fail_loc on $facet"
1121 do_facet $facet "sysctl -w lustre.fail_loc=0"
1124 cancel_lru_locks() {
1125 $LCTL mark "cancel_lru_locks $1 start"
1126 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1127 [ -f $d/lru_size ] && echo clear > $d/lru_size
1128 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1130 $LCTL mark "cancel_lru_locks $1 stop"
1135 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1136 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1137 echo there is still data in page cache $a ?
1146 DEBUGSAVE="$(sysctl -n lnet.debug)"
1150 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1154 ##################################
1156 ##################################
1159 local FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
1160 local TYPE=${TYPE:-"FAIL"}
1162 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1163 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1164 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1165 echo "Dumping lctl log to $ERRLOG"
1166 # We need to dump the logs on all nodes
1167 local NODES=$(nodes_list)
1168 for NODE in $NODES; do
1169 do_node $NODE $LCTL dk $ERRLOG
1172 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1173 if $FAIL_ON_ERROR; then
1178 # use only if we are ignoring failures for this test, bugno required.
1179 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1180 # e.g. error_ignore 5494 "your message"
1182 FAIL_ON_ERROR=false TYPE="IGNORE (bz$1)" error $2
1186 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1187 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1190 build_test_filter() {
1191 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1195 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1196 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1197 [ "$EXCEPT_SLOW" ] && \
1198 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1199 for E in $EXCEPT $ALWAYS_EXCEPT; do
1200 eval EXCEPT_${E}=true
1202 for E in $EXCEPT_SLOW; do
1203 eval EXCEPT_SLOW_${E}=true
1205 for G in $GRANT_CHECK_LIST; do
1206 eval GCHECK_ONLY_${G}=true
1215 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1219 export base=`basetest $1`
1220 if [ ! -z "$ONLY" ]; then
1222 if [ ${!testname}x != x ]; then
1227 if [ ${!testname}x != x ]; then
1235 if [ ${!testname}x != x ]; then
1236 TESTNAME=test_$1 skip "skipping excluded test $1"
1239 testname=EXCEPT_$base
1240 if [ ${!testname}x != x ]; then
1241 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1244 testname=EXCEPT_SLOW_$1
1245 if [ ${!testname}x != x ]; then
1246 TESTNAME=test_$1 skip "skipping SLOW test $1"
1249 testname=EXCEPT_SLOW_$base
1250 if [ ${!testname}x != x ]; then
1251 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1260 EQUALS="======================================================================"
1264 local suffixlen=$((${#EQUALS} - ${#msg}))
1265 [ $suffixlen -lt 5 ] && suffixlen=5
1266 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1272 local HAVE_MODULES=""
1273 lsmod | grep lnet > /dev/null || { load_modules && HAVE_MODULES="yes"; }
1284 local NODES=$(nodes_list)
1285 for NODE in $NODES; do
1286 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1289 [ -z "$HAVE_MODULES" ] || unload_modules
1294 strace -o $TMP/$1.strace -ttt $*
1296 log "FINISHED: $*: rc $RC"
1305 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1306 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1307 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1311 local myNODES=$(nodes_list)
1314 for NODE in $myNODES; do
1315 do_node $NODE sysctl -w lustre.fail_loc=0 || true
1323 export tdir=d${TESTSUITE}/d${base}
1324 local SAVE_UMASK=`umask`
1329 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1331 export TESTNAME=test_$testnum
1332 test_${testnum} || error "test_$testnum failed with $?"
1335 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1336 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1337 error "LBUG/LASSERT detected"
1338 pass "($((`date +%s` - $BEFORE))s)"
1339 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1348 (cd `dirname $1`; echo $PWD/`basename $1`)
1352 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1353 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1358 export base=`basetest $1`
1359 [ "$CHECK_GRANT" == "no" ] && return 0
1361 testname=GCHECK_ONLY_${base}
1362 [ ${!testname}x == x ] && return 0
1364 echo -n "checking grant......"
1366 # write some data to sync client lost_grant
1367 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1368 for i in `seq $OSTCOUNT`; do
1369 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1370 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1371 count=1 > /dev/null 2>&1
1373 # sync all the data and make sure no pending data on server
1376 #get client grant and server grant
1378 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1379 client_grant=$((client_grant + `cat $d`))
1382 for d in ${LPROC}/obdfilter/*/tot_granted; do
1383 server_grant=$((server_grant + `cat $d`))
1386 # cleanup the check_grant file
1387 for i in `seq $OSTCOUNT`; do
1388 rm $DIR1/${tfile}_check_grant_$i
1391 #check whether client grant == server grant
1392 if [ $client_grant != $server_grant ]; then
1393 echo "failed: client:${client_grant} server: ${server_grant}"
1400 ########################
1406 ost=`echo $1 | awk -F_ '{print $3}'`
1407 if [ -z $ost ]; then
1408 ost=`echo $1 | sed 's/-osc.*//'`
1415 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1420 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1424 local MDSNODES=$(facet_host $SINGLEMDS)
1427 # FIXME: Currenly we use only $SINGLEMDS,
1428 # should be fixed when we will start to test cmd.
1432 for num in `seq $MDSCOUNT`; do
1433 local myMDS=$(facet_host mds$num)
1434 MDSNODES="$MDSNODES $myMDS"
1436 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1442 local OSTNODES=$(facet_host ost1)
1445 for num in `seq $OSTCOUNT`; do
1446 local myOST=$(facet_host ost$num)
1447 OSTNODES="$OSTNODES $myOST"
1449 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1455 # FIXME. We need a list of clients
1456 local myNODES=`hostname`
1459 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1460 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1467 grep -q patchless $LPROC/version
1474 mkdir $DIR/d0_runas_test
1476 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1477 $myRUNAS touch $DIR/d0_runas_test/f$$ || \
1478 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1479 Please set RUNAS_ID to some UID which exists on MDS and client or
1480 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1481 rm -rf $DIR/d0_runas_test