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 PDSH="pdsh -S -Rssh -w"
18 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
22 if [ -z "${!name}" ]; then
23 echo "$0: $name must be set"
27 [ $failed ] && exit 1 || true
31 echo "usage: $0 [-r] [-f cfgfile]"
38 [ "$TESTSUITE" == "lfscktest" ] && return 0
39 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
40 local form="%-13s %-17s %s\n"
41 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
42 echo "------------------------------------------------------------------------------------"
43 for O in $TESTSUITE_LIST; do
46 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
49 local log=${TMP}/${o}.log
50 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
51 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
52 [ "${!O}" = "done" ] && \
53 printf "$form" "Done" "$O" "E=$skipped" && \
54 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
58 for O in $TESTSUITE_LIST; do
59 [ "${!O}" = "no" ] && \
60 printf "$form" "Skipped" "$O" ""
63 for O in $TESTSUITE_LIST; do
64 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
65 printf "$form" "UNFINISHED" "$O" ""
70 export LUSTRE=`absolute_path $LUSTRE`
71 export TESTSUITE=`basename $0 .sh`
72 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
74 [ -d /r ] && export ROOT=${ROOT:-/r}
75 export TMP=${TMP:-$ROOT/tmp}
76 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
78 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
79 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
80 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
81 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
82 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
83 [ ! -f "$LFS" ] && export LFS=$(which lfs)
84 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
85 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
86 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
87 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
88 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
89 export FSYTPE=${FSTYPE:-"ldiskfs"}
90 export NAME=${NAME:-local}
91 export LPROC=/proc/fs/lustre
92 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
93 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
94 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
97 if [ "$ACCEPTOR_PORT" ]; then
98 export PORT_OPT="--port $ACCEPTOR_PORT"
103 echo "Using GSS/krb5 ptlrpc security flavor"
109 # Paths on remote nodes, if different
110 export RLUSTRE=${RLUSTRE:-$LUSTRE}
111 export RPWD=${RPWD:-$PWD}
112 export I_MOUNTED=${I_MOUNTED:-"no"}
116 while getopts "rvf:" opt $*; do
119 r) REFORMAT=--reformat;;
125 shift $((OPTIND - 1))
128 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
136 BASE=`basename $module $EXT`
137 lsmod | grep -q ${BASE} || \
138 if [ -f ${LUSTRE}/${module}${EXT} ]; then
139 insmod ${LUSTRE}/${module}${EXT} $@
141 # must be testing a "make install" or "rpm" installation
142 # note failed to load ptlrpc_gss is considered not fatal
143 if [ "$BASE" == "ptlrpc_gss" ]; then
144 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
152 if [ -n "$MODPROBE" ]; then
156 if [ "$HAVE_MODULES" = true ]; then
162 echo Loading modules from $LUSTRE
163 load_module ../lnet/libcfs/libcfs
164 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
165 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
166 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
167 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
168 echo "lnet options: '$LNETOPTS'"
169 # note that insmod will ignore anything in modprobe.conf
170 load_module ../lnet/lnet/lnet $LNETOPTS
171 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
172 load_module ../lnet/klnds/$LNETLND
173 load_module lvfs/lvfs
174 load_module obdclass/obdclass
175 load_module ptlrpc/ptlrpc
176 load_module ptlrpc/gss/ptlrpc_gss
177 # Now, some modules depend on lquota without USE_QUOTA check,
178 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
179 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
180 load_module quota/lquota
188 if [ -z "$CLIENTONLY" ]; then
189 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
194 load_module lvfs/fsfilt_$FSTYPE
198 load_module obdfilter/obdfilter
201 load_module llite/lustre
202 load_module llite/llite_lloop
203 rm -f $TMP/ogdb-`hostname`
204 $LCTL modules > $TMP/ogdb-`hostname`
205 # 'mount' doesn't look in $PATH, just sbin
206 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
210 if [ `uname -r | cut -c 3` -eq 4 ]; then
218 MODULES=$($LCTL modules | awk '{ print $2 }')
219 while [ -n "$MODULES" ]; do
221 $RMMOD $MODULES > /dev/null 2>&1 || true
222 MODULES=$($LCTL modules | awk '{ print $2 }')
223 if [ -z "$MODULES" ]; then
227 echo "waiting, $((MAX - WAIT)) secs left"
229 if [ $WAIT -eq $MAX ]; then
230 echo "LNET modules $MODULES will not unload"
238 wait_exit_ST client # bug 12845
240 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
241 local MODULES=$($LCTL modules | awk '{ print $2 }')
242 $RMMOD $MODULES > /dev/null 2>&1 || true
243 # do it again, in case we tried to unload ksocklnd too early
244 MODULES=$($LCTL modules | awk '{ print $2 }')
245 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
246 MODULES=$($LCTL modules | awk '{ print $2 }')
247 if [ -n "$MODULES" ]; then
248 echo "Modules still loaded: "
250 if [ -e $LPROC ]; then
251 echo "Lustre still loaded"
252 cat $LPROC/devices || true
256 echo "Lustre stopped but LNET is still loaded, waiting..."
257 wait_for_lnet || return 3
262 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
263 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
264 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
265 echo "$LEAK_LUSTRE" 1>&2
266 echo "$LEAK_PORTALS" 1>&2
267 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
268 echo "Memory leaks detected"
269 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
272 echo "modules unloaded."
276 check_gss_daemon_facet() {
280 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
281 if [ $num -ne 1 ]; then
282 echo "$num instance of $dname on $facet"
291 do_facet $facet "killall -2 $@ 2>/dev/null || true"
294 start_gss_daemons() {
296 for num in `seq $MDSCOUNT`; do
297 do_facet mds$num "$LSVCGSSD -v"
299 do_facet mds$num "$LGSSD -v"
303 for num in `seq $OSTCOUNT`; do
304 do_facet ost$num "$LSVCGSSD -v"
307 # FIXME: is "client" the right facet name?
309 do_facet client "$LGSSD -v"
312 # wait daemons entering "stable" status
316 # check daemons are running
318 for num in `seq $MDSCOUNT`; do
319 check_gss_daemon_facet mds$num lsvcgssd
321 check_gss_daemon_facet mds$num lgssd
324 for num in `seq $OSTCOUNT`; do
325 check_gss_daemon_facet ost$num lsvcgssd
328 check_gss_daemon_facet client lgssd
333 for num in `seq $MDSCOUNT`; do
334 send_sigint mds$num lsvcgssd lgssd
336 for num in `seq $OSTCOUNT`; do
337 send_sigint ost$num lsvcgssd
339 send_sigint client lgssd
343 if [ ! -z $SEC ]; then
344 MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
345 OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
356 # maybe cleanup credential cache?
362 local device=`mdsdevname $num`
363 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
369 local device=`ostdevname $num`
370 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
375 # start facet device options
381 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
382 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
383 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
385 if [ $RC -ne 0 ]; then
386 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
387 echo Start of ${device} on ${facet} failed ${RC}
389 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
390 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
391 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
393 do_facet ${facet} sync
394 label=$(do_facet ${facet} "e2label ${device}")
395 [ -z "$label" ] && echo no label for ${device} && exit 1
396 eval export ${facet}_svc=${label}
397 eval export ${facet}_dev=${device}
398 eval export ${facet}_opt=\"$@\"
399 echo Started ${label}
408 HOST=`facet_active_host $facet`
409 [ -z $HOST ] && echo stop: no host for $facet && return 0
411 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
412 if [ ${running} -ne 0 ]; then
413 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
414 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
417 # umount should block, but we should wait for unrelated obd's
418 # like the MGS or MGC to also stop.
419 wait_exit_ST ${facet}
426 # Only supply -o to mount if we have options
427 if [ -n "$MOUNTOPT" ]; then
428 OPTIONS="-o $MOUNTOPT"
430 local device=$MGSNID:/$FSNAME
431 if [ -z "$mnt" -o -z "$FSNAME" ]; then
432 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
436 echo "Starting client: $OPTIONS $device $mnt"
437 do_node $client mkdir -p $mnt
438 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
440 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
441 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
442 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
443 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
451 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
452 if [ $running -ne 0 ]; then
453 echo "Stopping client $mnt (opts:$force)"
454 do_node $client umount $force $mnt
460 if [ "$FAILURE_MODE" = HARD ]; then
461 $POWER_DOWN `facet_active_host $facet`
463 elif [ "$FAILURE_MODE" = SOFT ]; then
470 if [ "$FAILURE_MODE" = HARD ]; then
471 $POWER_UP `facet_active_host $facet`
477 # verify that lustre actually cleaned up properly
479 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
480 error "LBUG/LASSERT detected"
481 BUSY=`dmesg | grep -i destruct || true`
484 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
487 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
488 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
489 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
490 echo "$0: $LEAK_LUSTRE" 1>&2
491 echo "$0: $LEAK_PORTALS" 1>&2
492 echo "$0: Memory leak(s) detected..." 1>&2
493 mv $TMP/debug $TMP/debug-leak.`date +%s`
497 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
498 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
500 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
501 echo "$0: modules still loaded..." 1>&2
508 wait_delete_completed () {
509 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
510 $LPROC/osc/*/kbytesavail`
514 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
516 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
517 $LPROC/osc/*/kbytesavail`
518 [ "$TOTAL" -eq "$TOTALPREV" ] && break
519 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
523 echo "Delete completed."
528 check_network "$HOST" 900
529 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
534 HOST=`facet_active_host $facet`
538 wait_mds_recovery_done () {
539 local timeout=`do_facet mds cat /proc/sys/lustre/timeout`
540 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
541 # as we are in process of changing obd_timeout in different ways
542 # let's set MAX longer than that
543 MAX=$(( timeout * 4 ))
545 while [ $WAIT -lt $MAX ]; do
546 STATUS=`do_facet mds grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
547 echo $STATUS | grep COMPLETE && return 0
550 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
552 echo "MDS recovery not done in $MAX sec"
561 # conf-sanity 31 takes a long time cleanup
562 while [ $WAIT -lt 300 ]; do
563 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
564 [ -z "${running}" ] && return 0
565 echo "waited $WAIT for${running}"
566 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
568 WAIT=$((WAIT + INTERVAL))
570 echo "service didn't stop after $WAIT seconds. Still running:"
576 # not every config has many clients
577 if [ ! -z "$CLIENTS" ]; then
578 $PDSH $CLIENTS "df $MOUNT" > /dev/null
583 uname -n >> $MOUNT/recon
584 if [ ! -z "$CLIENTS" ]; then
585 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
587 echo Connected clients:
589 ls -l $MOUNT/recon > /dev/null
595 echo "Failing $facet on node `facet_active_host $facet`"
596 shutdown_facet $facet
600 echo "df pid is $DFPID"
602 TO=`facet_active_host $facet`
603 echo "Failover $facet to $TO"
605 local dev=${facet}_dev
606 local opt=${facet}_opt
607 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
618 local svc=${facet}_svc
619 do_facet $facet $LCTL --device %${!svc} readonly
620 do_facet $facet $LCTL --device %${!svc} notransno
621 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
622 $LCTL mark "local REPLAY BARRIER on ${!svc}"
625 replay_barrier_nodf() {
626 local facet=$1 echo running=${running}
628 local svc=${facet}_svc
629 echo Replay barrier on ${!svc}
630 do_facet $facet $LCTL --device %${!svc} readonly
631 do_facet $facet $LCTL --device %${!svc} notransno
632 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
633 $LCTL mark "local REPLAY BARRIER on ${!svc}"
637 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
638 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
642 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
643 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
647 facet_failover $* || error "failover: $?"
648 df $MOUNT || error "post-failover df: $?"
655 local svc=${facet}_svc
656 local dev=${facet}_dev
657 local opt=${facet}_opt
658 start $facet ${!dev} ${!opt}
659 do_facet $facet lctl --device %${!svc} abort_recovery
660 df $MOUNT || echo "first df failed: $?"
662 df $MOUNT || error "post-failover df: $?"
666 echo There is no lmc. This is mountconf, baby.
671 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
672 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
678 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
684 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
685 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
686 if [ -z "$ID" ]; then
687 echo "Could not get a ptl id for $1..."
696 h2name_or_ip "$1" "tcp"
701 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
702 if type __h2elan >/dev/null 2>&1; then
705 ID=`echo $1 | sed 's/[^0-9]*//g'`
713 h2name_or_ip "$1" "openib"
718 h2name_or_ip "$1" "o2ib"
724 varname=${facet}_HOST
725 if [ -z "${!varname}" ]; then
726 if [ "${facet:0:3}" == "ost" ]; then
727 eval ${facet}_HOST=${ost_HOST}
735 local activevar=${facet}active
737 if [ -f ./${facet}active ] ; then
738 source ./${facet}active
742 if [ -z "$active" ] ; then
749 facet_active_host() {
751 local active=`facet_active $facet`
752 if [ "$facet" == client ]; then
755 echo `facet_host $active`
761 failover=${facet}failover
762 host=`facet_host $failover`
763 [ -z "$host" ] && return
764 curactive=`facet_active $facet`
765 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
766 eval export ${facet}active=$facet
768 eval export ${facet}active=$failover
770 # save the active host for this facet
771 activevar=${facet}active
772 echo "$activevar=${!activevar}" > ./$activevar
779 if [ "$HOST" = "$(hostname)" ]; then
783 echo "CMD: $HOST $@" >&2
784 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
786 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
787 return ${PIPESTATUS[0]}
793 HOST=`facet_active_host $facet`
794 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
801 # make sure its not already running
804 do_facet ${facet} $MKFS $*
810 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
811 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
818 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
819 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
827 # make sure we are using the primary server, so test-framework will
828 # be able to clean up properly.
829 activemds=`facet_active mds1`
830 if [ $activemds != "mds1" ]; then
834 # assume client mount is local
835 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
836 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
837 [ "$CLIENTONLY" ] && return
838 for num in `seq $MDSCOUNT`; do
841 for num in `seq $OSTCOUNT`; do
856 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
860 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
863 # We need ldiskfs here, may as well load them all
865 [ "$CLIENTONLY" ] && return
866 echo "Formatting mdts, osts"
867 for num in `seq $MDSCOUNT`; do
868 echo "Format mds$num: $(mdsdevname $num)"
870 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
872 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
876 for num in `seq $OSTCOUNT`; do
877 echo "Format ost$num: $(ostdevname $num)"
879 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
881 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
887 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
893 if [ -z "$CLIENTONLY" ]; then
894 echo "Setup mdts, osts"
895 for num in `seq $MDSCOUNT`; do
896 DEVNAME=$(mdsdevname $num)
897 echo $REFORMAT | grep -q "reformat" \
898 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
899 start mds$num $DEVNAME $MDS_MOUNT_OPTS
901 for num in `seq $OSTCOUNT`; do
902 DEVNAME=$(ostdevname $num)
903 start ost$num $DEVNAME $OST_MOUNT_OPTS
906 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
908 if [ "$MOUNT_2" ]; then
914 mounted_lustre_filesystems() {
915 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
918 check_and_setup_lustre() {
919 MOUNTED="`mounted_lustre_filesystems`"
920 if [ -z "$MOUNTED" ]; then
921 [ "$REFORMAT" ] && formatall
923 MOUNTED="`mounted_lustre_filesystems`"
924 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
927 if [ "$ONLY" == "setup" ]; then
932 cleanup_and_setup_lustre() {
933 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
934 sysctl -w lnet.debug=0 || true
936 if [ "$ONLY" == "cleanup" ]; then
940 check_and_setup_lustre
943 check_and_cleanup_lustre() {
944 if [ "`mount | grep $MOUNT`" ]; then
945 rm -rf $DIR/[Rdfs][0-9]*
946 rm -f $DIR/${TESTSUITE}/[Rdfs][1-9]*
948 if [ "$I_MOUNTED" = "yes" ]; then
949 cleanupall -f || error "cleanup failed"
961 while [ $NETWORK -eq 0 ]; do
962 ping -c 1 -w 3 $1 > /dev/null
963 if [ $? -eq 0 ]; then
967 echo "waiting for $1, $((MAX - WAIT)) secs left"
970 if [ $WAIT -gt $MAX ]; then
971 echo "Network not available"
977 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
988 # the sed converts spaces to commas, but leaves the last space
989 # alone, so the line doesn't end with a comma.
990 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
994 (cd `dirname $1`; echo $PWD/`basename $1`)
997 ##################################
1001 # OBD_FAIL_MDS_ALL_REQUEST_NET
1003 do_facet mds sysctl -w lustre.fail_loc=0x123
1004 do_facet client "$1" || RC=$?
1005 do_facet mds sysctl -w lustre.fail_loc=0
1010 # OBD_FAIL_MDS_ALL_REPLY_NET
1012 do_facet mds sysctl -w lustre.fail_loc=0x122
1013 do_facet client "$@" || RC=$?
1014 do_facet mds sysctl -w lustre.fail_loc=0
1018 drop_reint_reply() {
1019 # OBD_FAIL_MDS_REINT_NET_REP
1021 do_facet mds sysctl -w lustre.fail_loc=0x119
1022 do_facet client "$@" || RC=$?
1023 do_facet mds sysctl -w lustre.fail_loc=0
1028 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1030 do_facet ost1 sysctl -w lustre.fail_loc=0x214
1031 do_facet client "$1" || RC=$?
1032 do_facet client "sync"
1033 do_facet ost1 sysctl -w lustre.fail_loc=0
1037 drop_ldlm_cancel() {
1038 #define OBD_FAIL_LDLM_CANCEL 0x304
1040 do_facet client sysctl -w lustre.fail_loc=0x304
1041 do_facet client "$@" || RC=$?
1042 do_facet client sysctl -w lustre.fail_loc=0
1046 drop_bl_callback() {
1047 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1049 do_facet client sysctl -w lustre.fail_loc=0x305
1050 do_facet client "$@" || RC=$?
1051 do_facet client sysctl -w lustre.fail_loc=0
1056 #define OBD_FAIL_LDLM_REPLY 0x30c
1058 do_facet mds sysctl -w lustre.fail_loc=0x30c
1059 do_facet client "$@" || RC=$?
1060 do_facet mds sysctl -w lustre.fail_loc=0
1068 echo "clearing fail_loc on $facet"
1069 do_facet $facet "sysctl -w lustre.fail_loc=0"
1072 cancel_lru_locks() {
1073 $LCTL mark "cancel_lru_locks $1 start"
1074 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1075 [ -f $d/lru_size ] && echo clear > $d/lru_size
1076 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1078 $LCTL mark "cancel_lru_locks $1 stop"
1083 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1084 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1085 echo there is still data in page cache $a ?
1094 DEBUGSAVE="$(sysctl -n lnet.debug)"
1098 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1102 ##################################
1104 ##################################
1107 local FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
1108 local TYPE=${TYPE:-"FAIL"}
1110 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1111 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1112 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1113 echo "Dumping lctl log to $ERRLOG"
1114 # We need to dump the logs on all nodes
1115 local NODES=$(nodes_list)
1116 for NODE in $NODES; do
1117 do_node $NODE $LCTL dk $ERRLOG
1120 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1121 if $FAIL_ON_ERROR; then
1126 # use only if we are ignoring failures for this test, bugno required.
1127 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1128 # e.g. error_ignore 5494 "your message"
1130 FAIL_ON_ERROR=false TYPE="IGNORE (bz$1)" error $2
1134 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1135 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1138 build_test_filter() {
1139 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1143 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1144 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1145 [ "$EXCEPT_SLOW" ] && \
1146 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1147 for E in $EXCEPT $ALWAYS_EXCEPT; do
1148 eval EXCEPT_${E}=true
1150 for E in $EXCEPT_SLOW; do
1151 eval EXCEPT_SLOW_${E}=true
1153 for G in $GRANT_CHECK_LIST; do
1154 eval GCHECK_ONLY_${G}=true
1163 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1167 export base=`basetest $1`
1168 if [ ! -z "$ONLY" ]; then
1170 if [ ${!testname}x != x ]; then
1175 if [ ${!testname}x != x ]; then
1183 if [ ${!testname}x != x ]; then
1184 TESTNAME=test_$1 skip "skipping excluded test $1"
1187 testname=EXCEPT_$base
1188 if [ ${!testname}x != x ]; then
1189 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1192 testname=EXCEPT_SLOW_$1
1193 if [ ${!testname}x != x ]; then
1194 TESTNAME=test_$1 skip "skipping SLOW test $1"
1197 testname=EXCEPT_SLOW_$base
1198 if [ ${!testname}x != x ]; then
1199 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1208 EQUALS="======================================================================"
1212 local suffixlen=$((${#EQUALS} - ${#msg}))
1213 [ $suffixlen -lt 5 ] && suffixlen=5
1214 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1219 lsmod | grep lnet > /dev/null || load_modules
1228 local NODES=$(nodes_list)
1229 for NODE in $NODES; do
1230 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1236 strace -o $TMP/$1.strace -ttt $*
1238 log "FINISHED: $*: rc $RC"
1247 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1248 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1249 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1253 local myNODES=$(nodes_list)
1256 for NODE in $myNODES; do
1257 do_node $NODE sysctl -w lustre.fail_loc=0 || true
1265 export tdir=d${TESTSUITE}/d${base}
1266 local SAVE_UMASK=`umask`
1271 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1273 export TESTNAME=test_$testnum
1274 test_${testnum} || error "test_$testnum failed with $?"
1277 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1278 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1279 error "LBUG/LASSERT detected"
1280 pass "($((`date +%s` - $BEFORE))s)"
1281 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1290 (cd `dirname $1`; echo $PWD/`basename $1`)
1294 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1295 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1300 export base=`basetest $1`
1301 [ "$CHECK_GRANT" == "no" ] && return 0
1303 testname=GCHECK_ONLY_${base}
1304 [ ${!testname}x == x ] && return 0
1306 echo -n "checking grant......"
1308 # write some data to sync client lost_grant
1309 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1310 for i in `seq $OSTCOUNT`; do
1311 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1312 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1313 count=1 > /dev/null 2>&1
1315 # sync all the data and make sure no pending data on server
1318 #get client grant and server grant
1320 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1321 client_grant=$((client_grant + `cat $d`))
1324 for d in ${LPROC}/obdfilter/*/tot_granted; do
1325 server_grant=$((server_grant + `cat $d`))
1328 # cleanup the check_grant file
1329 for i in `seq $OSTCOUNT`; do
1330 rm $DIR1/${tfile}_check_grant_$i
1333 #check whether client grant == server grant
1334 if [ $client_grant != $server_grant ]; then
1335 echo "failed: client:${client_grant} server: ${server_grant}"
1342 ########################
1348 ost=`echo $1 | awk -F_ '{print $3}'`
1349 if [ -z $ost ]; then
1350 ost=`echo $1 | sed 's/-osc.*//'`
1357 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1362 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1366 local MDSNODES=$(facet_host $SINGLEMDS)
1369 # FIXME: Currenly we use only $SINGLEMDS,
1370 # should be fixed when we will start to test cmd.
1374 for num in `seq $MDSCOUNT`; do
1375 local myMDS=$(facet_host mds$num)
1376 MDSNODES="$MDSNODES $myMDS"
1378 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1384 local OSTNODES=$(facet_host ost1)
1387 for num in `seq $OSTCOUNT`; do
1388 local myOST=$(facet_host ost$num)
1389 OSTNODES="$OSTNODES $myOST"
1391 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1397 # FIXME. We need a list of clients
1398 local myNODES=`hostname`
1401 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1402 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1409 grep -q patchless $LPROC/version
1416 mkdir $DIR/d0_runas_test
1418 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1419 $myRUNAS touch $DIR/d0_runas_test/f$$ || \
1420 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1421 Please set RUNAS_ID to some UID which exists on MDS and client or
1422 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1423 rm -rf $DIR/d0_runas_test