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}
13 #export PDSH="pdsh -S -Rssh -w"
15 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
19 if [ -z "${!name}" ]; then
20 echo "$0: $name must be set"
24 [ $failed ] && exit 1 || true
28 echo "usage: $0 [-r] [-f cfgfile]"
35 [ "$TESTSUITE" == "lfscktest" ] && return 0
36 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
37 local form="%-13s %-17s %s\n"
38 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
39 echo "------------------------------------------------------------------------------------"
40 for O in $TESTSUITE_LIST; do
43 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
46 local log=${TMP}/${o}.log
47 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
48 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
49 [ "${!O}" = "done" ] && \
50 printf "$form" "Done" "$O" "E=$skipped" && \
51 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
55 for O in $TESTSUITE_LIST; do
56 [ "${!O}" = "no" ] && \
57 printf "$form" "Skipped" "$O" ""
60 for O in $TESTSUITE_LIST; do
61 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
62 printf "$form" "UNFINISHED" "$O" ""
67 export LUSTRE=`absolute_path $LUSTRE`
68 export TESTSUITE=`basename $0 .sh`
69 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
71 [ -d /r ] && export ROOT=${ROOT:-/r}
72 export TMP=${TMP:-$ROOT/tmp}
73 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
75 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
76 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
77 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
78 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
79 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
80 [ ! -f "$LFS" ] && export LFS=$(which lfs)
81 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
82 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
83 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
84 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
85 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
86 export FSYTPE=${FSTYPE:-"ldiskfs"}
87 export NAME=${NAME:-local}
88 export LPROC=/proc/fs/lustre
91 if [ "$ACCEPTOR_PORT" ]; then
92 export PORT_OPT="--port $ACCEPTOR_PORT"
95 # Paths on remote nodes, if different
96 export RLUSTRE=${RLUSTRE:-$LUSTRE}
97 export RPWD=${RPWD:-$PWD}
98 export I_MOUNTED=${I_MOUNTED:-"no"}
102 while getopts "rvf:" opt $*; do
105 r) REFORMAT=--reformat;;
111 shift $((OPTIND - 1))
114 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
119 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
120 *) EXT=".ko"; USE_QUOTA=yes;;
130 BASE=`basename $module $EXT`
131 lsmod | grep -q ${BASE} || \
132 if [ -f ${LUSTRE}/${module}${EXT} ]; then
133 insmod ${LUSTRE}/${module}${EXT} $@
135 # must be testing a "make install" or "rpm" installation
141 if [ -n "$MODPROBE" ]; then
145 # we already loaded ?
146 have_modules && return 0
148 echo Loading modules from $LUSTRE
149 load_module ../lnet/libcfs/libcfs
150 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
151 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
152 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
153 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
154 echo "lnet options: '$LNETOPTS'"
155 # note that insmod will ignore anything in modprobe.conf
156 load_module ../lnet/lnet/lnet $LNETOPTS
157 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
158 load_module ../lnet/klnds/$LNETLND
159 load_module lvfs/lvfs
160 load_module obdclass/obdclass
161 load_module ptlrpc/ptlrpc
162 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
167 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
170 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
171 load_module lvfs/fsfilt_$FSTYPE
173 load_module obdfilter/obdfilter
176 load_module llite/lustre
177 load_module llite/llite_lloop
178 rm -f $TMP/ogdb-`hostname`
180 [ -d /r ] && OGDB="/r/tmp"
181 $LCTL modules > $OGDB/ogdb-`hostname`
182 # 'mount' doesn't look in $PATH, just sbin
183 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
187 if [ `uname -r | cut -c 3` -eq 4 ]; then
195 MODULES=$($LCTL modules | awk '{ print $2 }')
196 while [ -n "$MODULES" ]; do
198 $RMMOD $MODULES >/dev/null 2>&1 || true
199 MODULES=$($LCTL modules | awk '{ print $2 }')
200 if [ -z "$MODULES" ]; then
204 echo "waiting, $((MAX - WAIT)) secs left"
206 if [ $WAIT -eq $MAX ]; then
207 echo "LNET modules $MODULES will not unload"
215 wait_exit_ST client # bug 12845
217 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
218 local MODULES=$($LCTL modules | awk '{ print $2 }')
219 $RMMOD $MODULES > /dev/null 2>&1 || true
220 # do it again, in case we tried to unload ksocklnd too early
221 MODULES=$($LCTL modules | awk '{ print $2 }')
222 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
223 MODULES=$($LCTL modules | awk '{ print $2 }')
224 if [ -n "$MODULES" ]; then
225 echo "Modules still loaded: "
227 if [ -e $LPROC ]; then
228 echo "Lustre still loaded"
229 cat $LPROC/devices || true
233 echo "Lustre stopped but LNET is still loaded, waiting..."
234 wait_for_lnet || return 3
238 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
239 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
240 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
241 echo "$LEAK_LUSTRE" 1>&2
242 echo "$LEAK_PORTALS" 1>&2
243 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
244 echo "Memory leaks detected"
245 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
248 echo "modules unloaded."
253 # start facet device options
259 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
260 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
261 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
263 if [ $RC -ne 0 ]; then
264 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
265 echo "Start of ${device} on ${facet} failed ${RC}"
267 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
268 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
269 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
271 do_facet ${facet} sync
272 label=$(do_facet ${facet} "e2label ${device}")
273 [ -z "$label" ] && echo no label for ${device} && exit 1
274 eval export ${facet}_svc=${label}
275 eval export ${facet}_dev=${device}
276 eval export ${facet}_opt=\"$@\"
277 echo Started ${label}
286 HOST=`facet_active_host $facet`
287 [ -z $HOST ] && echo stop: no host for $facet && return 0
289 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
290 if [ ${running} -ne 0 ]; then
291 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
292 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
295 # umount should block, but we should wait for unrelated obd's
296 # like the MGS or MGC to also stop.
298 wait_exit_ST ${facet}
305 # Only supply -o to mount if we have options
306 if [ -n "$MOUNTOPT" ]; then
307 OPTIONS="-o $MOUNTOPT"
309 local device=$MGSNID:/$FSNAME
310 if [ -z "$mnt" -o -z "$FSNAME" ]; then
311 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
315 echo "Starting client: $OPTIONS $device $mnt"
316 do_node $client mkdir -p $mnt
317 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
319 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
320 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
321 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
322 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
330 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
331 if [ $running -ne 0 ]; then
332 echo "Stopping client $mnt (opts:$force)"
333 do_node $client umount $force $mnt
339 if [ "$FAILURE_MODE" = HARD ]; then
340 $POWER_DOWN `facet_active_host $facet`
342 elif [ "$FAILURE_MODE" = SOFT ]; then
349 if [ "$FAILURE_MODE" = HARD ]; then
350 $POWER_UP `facet_active_host $facet`
356 # verify that lustre actually cleaned up properly
358 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
359 error "LBUG/LASSERT detected"
360 BUSY=`dmesg | grep -i destruct || true`
363 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
366 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
367 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
368 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
369 echo "$0: $LEAK_LUSTRE" 1>&2
370 echo "$0: $LEAK_PORTALS" 1>&2
371 echo "$0: Memory leak(s) detected..." 1>&2
372 mv $TMP/debug $TMP/debug-leak.`date +%s`
376 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
377 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
379 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
380 echo "$0: modules still loaded..." 1>&2
387 wait_delete_completed () {
388 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
389 $LPROC/osc/*/kbytesavail`
393 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
395 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
396 $LPROC/osc/*/kbytesavail`
397 [ "$TOTAL" -eq "$TOTALPREV" ] && break
398 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
402 echo "Delete completed."
407 check_network "$HOST" 900
408 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
413 HOST=`facet_active_host $facet`
417 wait_mds_recovery_done () {
418 local timeout=`do_facet mds cat /proc/sys/lustre/timeout`
419 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
420 # as we are in process of changing obd_timeout in different ways
421 # let's set MAX longer than that
422 MAX=$(( timeout * 4 ))
424 while [ $WAIT -lt $MAX ]; do
425 STATUS=`do_facet mds grep status /proc/fs/lustre/mds/*-MDT*/recovery_status`
426 echo $STATUS | grep COMPLETE && return 0
429 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
431 echo "MDS recovery not done in $MAX sec"
440 # conf-sanity 31 takes a long time cleanup
441 while [ $WAIT -lt 300 ]; do
442 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
443 [ -z "${running}" ] && return 0
444 echo "waited $WAIT for${running}"
445 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
447 WAIT=$((WAIT + INTERVAL))
449 echo "service didn't stop after $WAIT seconds. Still running:"
455 # not every config has many clients
456 if [ -n "$CLIENTS" ]; then
457 $PDSH $CLIENTS "df $MOUNT" > /dev/null
459 df $MOUNT > /dev/null
464 uname -n >> $MOUNT/recon
465 if [ ! -z "$CLIENTS" ]; then
466 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
468 echo Connected clients:
470 ls -l $MOUNT/recon > /dev/null
476 echo "Failing $facet on node `facet_active_host $facet`"
477 shutdown_facet $facet
481 echo "df pid is $DFPID"
483 TO=`facet_active_host $facet`
484 echo "Failover $facet to $TO"
486 local dev=${facet}_dev
487 local opt=${facet}_opt
488 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
499 local svc=${facet}_svc
500 do_facet $facet $LCTL --device %${!svc} readonly
501 do_facet $facet $LCTL --device %${!svc} notransno
502 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
503 $LCTL mark "local REPLAY BARRIER on ${!svc}"
506 replay_barrier_nodf() {
507 local facet=$1 echo running=${running}
509 local svc=${facet}_svc
510 echo Replay barrier on ${!svc}
511 do_facet $facet $LCTL --device %${!svc} readonly
512 do_facet $facet $LCTL --device %${!svc} notransno
513 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
514 $LCTL mark "local REPLAY BARRIER on ${!svc}"
518 UUID=`cat /proc/fs/lustre/mdc/${mds_svc}-mdc-*/uuid`
519 do_facet mds "echo $UUID > /proc/fs/lustre/mds/${mds_svc}/evict_client"
523 UUID=`cat /proc/fs/lustre/osc/${ost1_svc}-osc-*/uuid`
524 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
528 facet_failover $* || error "failover: $?"
529 df $MOUNT || error "post-failover df: $?"
534 facet_failover $facet
541 local svc=${facet}_svc
542 local dev=${facet}_dev
543 local opt=${facet}_opt
544 start $facet ${!dev} ${!opt}
545 do_facet $facet lctl --device %${!svc} abort_recovery
546 df $MOUNT || echo "first df failed: $?"
548 df $MOUNT || error "post-failover df: $?"
552 echo There is no lmc. This is mountconf, baby.
557 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
558 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
564 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
565 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
566 if [ -z "$ID" ]; then
567 echo "Could not get a ptl id for $1..."
576 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
583 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
584 if type __h2elan >/dev/null 2>&1; then
587 ID=`echo $1 | sed 's/[^0-9]*//g'`
595 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
596 ID=`echo $1 | sed 's/[^0-9]*//g'`
604 varname=${facet}_HOST
605 if [ -z "${!varname}" ]; then
606 if [ "${facet:0:3}" == "ost" ]; then
607 eval ${facet}_HOST=${ost_HOST}
615 local activevar=${facet}active
617 if [ -f ./${facet}active ] ; then
618 source ./${facet}active
622 if [ -z "$active" ] ; then
629 facet_active_host() {
631 local active=`facet_active $facet`
632 if [ "$facet" == client ]; then
635 echo `facet_host $active`
641 failover=${facet}failover
642 host=`facet_host $failover`
643 [ -z "$host" ] && return
644 curactive=`facet_active $facet`
645 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
646 eval export ${facet}active=$facet
648 eval export ${facet}active=$failover
650 # save the active host for this facet
651 activevar=${facet}active
652 echo "$activevar=${!activevar}" > ./$activevar
659 if [ "$HOST" = "$(hostname)" ]; then
663 echo "CMD: $HOST $@" >&2
664 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
666 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
667 return ${PIPESTATUS[0]}
673 HOST=`facet_active_host $facet`
674 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
681 # make sure its not already running
684 do_facet ${facet} $MKFS $*
690 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
691 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
699 # make sure we are using the primary server, so test-framework will
700 # be able to clean up properly.
701 activemds=`facet_active mds`
702 if [ $activemds != "mds" ]; then
706 # assume client mount is local
707 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
708 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
709 [ "$CLIENTONLY" ] && return
711 for num in `seq $OSTCOUNT`; do
723 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
726 # We need ldiskfs here, may as well load them all
728 [ "$CLIENTONLY" ] && return
729 echo Formatting mds, osts
731 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
733 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
736 for num in `seq $OSTCOUNT`; do
738 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
740 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
746 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
751 if [ -z "$CLIENTONLY" ]; then
753 echo $REFORMAT | grep -q "reformat" \
754 || do_facet mds "$TUNEFS --writeconf $MDSDEV"
755 start mds $MDSDEV $MDS_MOUNT_OPTS
756 for num in `seq $OSTCOUNT`; do
757 DEVNAME=`ostdevname $num`
758 start ost$num $DEVNAME $OST_MOUNT_OPTS
761 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
763 if [ "$MOUNT_2" ]; then
769 mounted_lustre_filesystems() {
770 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
773 check_and_setup_lustre() {
774 MOUNTED="`mounted_lustre_filesystems`"
775 if [ -z "$MOUNTED" ]; then
776 [ "$REFORMAT" ] && formatall
778 MOUNTED="`mounted_lustre_filesystems`"
779 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
782 if [ "$ONLY" == "setup" ]; then
787 cleanup_and_setup_lustre() {
788 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
789 sysctl -w lnet.debug=0 || true
791 if [ "$ONLY" == "cleanup" ]; then
795 check_and_setup_lustre
798 check_and_cleanup_lustre() {
799 if [ "`mount | grep $MOUNT`" ]; then
800 rm -f $DIR/${TESTSUITE}/[Rdfs][0-9]*
802 if [ "$I_MOUNTED" = "yes" ]; then
803 cleanupall -f || error "cleanup failed"
815 while [ $NETWORK -eq 0 ]; do
816 ping -c 1 -w 3 $1 > /dev/null
817 if [ $? -eq 0 ]; then
821 echo "waiting for $1, $((MAX - WAIT)) secs left"
824 if [ $WAIT -gt $MAX ]; then
825 echo "Network not available"
831 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
842 # the sed converts spaces to commas, but leaves the last space
843 # alone, so the line doesn't end with a comma.
844 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
848 (cd `dirname $1`; echo $PWD/`basename $1`)
851 ##################################
855 # OBD_FAIL_MDS_ALL_REQUEST_NET
857 do_facet mds sysctl -w lustre.fail_loc=0x123
858 do_facet client "$1" || RC=$?
859 do_facet mds sysctl -w lustre.fail_loc=0
864 # OBD_FAIL_MDS_ALL_REPLY_NET
866 do_facet mds sysctl -w lustre.fail_loc=0x122
867 do_facet client "$@" || RC=$?
868 do_facet mds sysctl -w lustre.fail_loc=0
873 # OBD_FAIL_MDS_REINT_NET_REP
875 do_facet mds sysctl -w lustre.fail_loc=0x119
876 do_facet client "$@" || RC=$?
877 do_facet mds sysctl -w lustre.fail_loc=0
882 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
884 do_facet ost1 sysctl -w lustre.fail_loc=0x214
885 do_facet client "$1" || RC=$?
886 do_facet client "sync"
887 do_facet ost1 sysctl -w lustre.fail_loc=0
892 #define OBD_FAIL_LDLM_CANCEL 0x304
894 do_facet client sysctl -w lustre.fail_loc=0x304
895 do_facet client "$@" || RC=$?
896 do_facet client sysctl -w lustre.fail_loc=0
901 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
903 do_facet client sysctl -w lustre.fail_loc=0x305
904 do_facet client "$@" || RC=$?
905 do_facet client sysctl -w lustre.fail_loc=0
910 #define OBD_FAIL_LDLM_REPLY 0x30c
912 do_facet mds sysctl -w lustre.fail_loc=0x30c
913 do_facet client "$@" || RC=$?
914 do_facet mds sysctl -w lustre.fail_loc=0
922 echo "clearing fail_loc on $facet"
923 do_facet $facet "sysctl -w lustre.fail_loc=0"
927 $LCTL mark "cancel_lru_locks $1 start"
928 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
929 [ -f $d/lru_size ] && echo clear > $d/lru_size
930 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
932 $LCTL mark "cancel_lru_locks $1 stop"
937 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
938 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
939 echo there is still data in page cache $a ?
948 DEBUGSAVE="$(sysctl -n lnet.debug)"
952 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
956 ##################################
958 ##################################
961 local FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
962 local TYPE=${TYPE:-"FAIL"}
964 sysctl -w lustre.fail_loc=0 2> /dev/null || true
965 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
966 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
967 echo "Dumping lctl log to $ERRLOG"
968 # We need to dump the logs on all nodes
969 local NODES=$(nodes_list)
970 for NODE in $NODES; do
971 do_node $NODE $LCTL dk $ERRLOG
974 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
975 if $FAIL_ON_ERROR; then
980 # use only if we are ignoring failures for this test, bugno required.
981 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
982 # e.g. error_ignore 5494 "your message"
984 FAIL_ON_ERROR=false TYPE="IGNORE (bz$1)" error $2
988 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
989 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
992 build_test_filter() {
993 [ "$ONLY" ] && log "only running test `echo $ONLY`"
997 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
998 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
999 [ "$EXCEPT_SLOW" ] && \
1000 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1001 for E in $EXCEPT $ALWAYS_EXCEPT; do
1002 eval EXCEPT_${E}=true
1004 for E in $EXCEPT_SLOW; do
1005 eval EXCEPT_SLOW_${E}=true
1007 for G in $GRANT_CHECK_LIST; do
1008 eval GCHECK_ONLY_${G}=true
1017 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1021 export base=`basetest $1`
1022 if [ ! -z "$ONLY" ]; then
1024 if [ ${!testname}x != x ]; then
1029 if [ ${!testname}x != x ]; then
1037 if [ ${!testname}x != x ]; then
1038 TESTNAME=test_$1 skip "skipping excluded test $1"
1041 testname=EXCEPT_$base
1042 if [ ${!testname}x != x ]; then
1043 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1046 testname=EXCEPT_SLOW_$1
1047 if [ ${!testname}x != x ]; then
1048 TESTNAME=test_$1 skip "skipping SLOW test $1"
1051 testname=EXCEPT_SLOW_$base
1052 if [ ${!testname}x != x ]; then
1053 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1062 EQUALS="======================================================================"
1066 local suffixlen=$((${#EQUALS} - ${#msg}))
1067 [ $suffixlen -lt 5 ] && suffixlen=5
1068 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1074 local HAVE_MODULES=""
1075 lsmod | grep lnet > /dev/null || { load_modules && HAVE_MODULES="yes"; }
1086 local NODES=$(nodes_list)
1087 for NODE in $NODES; do
1088 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1091 [ -z "$HAVE_MODULES" ] || unload_modules
1096 strace -o $TMP/$1.strace -ttt $*
1098 log "FINISHED: $*: rc $RC"
1107 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1108 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1109 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1113 local myNODES=$(nodes_list)
1116 for NODE in $myNODES; do
1117 do_node $NODE sysctl -w lustre.fail_loc=0 || true
1125 export tdir=d${TESTSUITE}/d${base}
1126 local SAVE_UMASK=`umask`
1131 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1133 export TESTNAME=test_$testnum
1134 test_${testnum} || error "test_$testnum failed with $?"
1137 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1138 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1139 error "LBUG/LASSERT detected"
1140 pass "($((`date +%s` - $BEFORE))s)"
1141 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1150 (cd `dirname $1`; echo $PWD/`basename $1`)
1154 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1155 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1160 export base=`basetest $1`
1161 [ "$CHECK_GRANT" == "no" ] && return 0
1163 testname=GCHECK_ONLY_${base}
1164 [ ${!testname}x == x ] && return 0
1166 echo -n "checking grant......"
1168 # write some data to sync client lost_grant
1169 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1170 for i in `seq $OSTCOUNT`; do
1171 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1172 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1173 count=1 > /dev/null 2>&1
1175 # sync all the data and make sure no pending data on server
1178 #get client grant and server grant
1180 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1181 client_grant=$((client_grant + `cat $d`))
1184 for d in ${LPROC}/obdfilter/*/tot_granted; do
1185 server_grant=$((server_grant + `cat $d`))
1188 # cleanup the check_grant file
1189 for i in `seq $OSTCOUNT`; do
1190 rm $DIR1/${tfile}_check_grant_$i
1193 #check whether client grant == server grant
1194 if [ $client_grant != $server_grant ]; then
1195 echo "failed: client:${client_grant} server: ${server_grant}"
1202 ########################
1208 ost=`echo $1 | awk -F_ '{print $3}'`
1209 if [ -z $ost ]; then
1210 ost=`echo $1 | sed 's/-osc.*//'`
1217 [ ! -e /proc/fs/lustre/mds/*MDT* ]
1222 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1226 local OSTNODES=$(facet_host ost1)
1229 for num in `seq $OSTCOUNT`; do
1230 local myOST=$(facet_host ost$num)
1231 OSTNODES="$OSTNODES $myOST"
1233 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1239 # FIXME. We need a list of clients
1240 local myNODES=`hostname`
1243 myNODES="$myNODES $(osts_nodes) $mds_HOST"
1244 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1251 grep -q patchless $LPROC/version
1254 check_runas_id_ret() {
1259 if [ -z "$myRUNAS" ]; then
1260 FAIL_ON_ERROR="true"
1261 error "myRUNAS command must be specified for check_runas_id"
1263 mkdir $DIR/d0_runas_test
1265 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1266 $myRUNAS touch $DIR/d0_runas_test/f$$ || RC=1
1267 rm -rf $DIR/d0_runas_test
1275 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1276 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1277 Please set RUNAS_ID to some UID which exists on MDS and client or
1278 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."