2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
9 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
11 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
15 if [ -z "${!name}" ]; then
16 echo "$0: $name must be set"
20 [ $failed ] && exit 1 || true
24 echo "usage: $0 [-r] [-f cfgfile]"
31 export LUSTRE=`absolute_path $LUSTRE`
32 export TESTSUITE=`basename $0 .sh`
33 export XMLCONFIG=${XMLCONFIG:-${TESTSUITE}.xml}
34 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
36 [ -d /r ] && export ROOT=${ROOT:-/r}
37 export TMP=${TMP:-$ROOT/tmp}
39 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
40 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
41 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
42 export CHECKSTAT="${CHECKSTAT:-checkstat} "
43 export FSYTPE=${FSTYPE:-"ext3"}
45 if [ "$ACCEPTOR_PORT" ]; then
46 export PORT_OPT="--port $ACCEPTOR_PORT"
49 # Paths on remote nodes, if different
50 export RLUSTRE=${RLUSTRE:-$LUSTRE}
51 export RPWD=${RPWD:-$PWD}
55 while getopts "rvf:" opt $*; do
58 r) REFORMAT=--reformat;;
67 # save the name of the config file for the upcall
68 echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG" > $LUSTRE/tests/XMLCONFIG
69 # echo "CONFIG=`canonical_path $CONFIG`" > $LUSTRE/tests/CONFIG
73 # start facet device options
79 active=`facet_active $facet`
80 echo "mount active=${active}, facet=${facet}"
81 mkdir -p /mnt/${facet}
82 do_facet ${facet} mount -t lustre $@ ${device} /mnt/${facet}
83 #do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
84 # --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
87 if [ $RC -ne 0 ]; then
88 echo Start of ${device} on ${facet} failed ${RC}
90 label=`do_facet ${facet} e2label ${device}`
91 eval export ${facet}_svc=${label}
99 active=`facet_active $facet`
100 echo "umount active=${active}, facet=${facet}"
101 do_facet ${facet} umount -d $@ /mnt/${facet}
102 #do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
103 # --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
104 # $@ --cleanup $XMLCONFIG
113 do_node $client mkdir $mnt 2> /dev/null || :
115 # Only supply -o to mount if we have options
116 if [ -n "$MOUNTOPT" ]; then
117 OPTIONS="-o $MOUNTOPT"
120 do_node $client mount -t lustre $OPTIONS \
121 `facet_nid mgs`:/lustre $mnt || return 1
123 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }"
125 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
133 do_node $client umount $force $mnt
138 if [ "$FAILURE_MODE" = HARD ]; then
139 $POWER_DOWN `facet_active_host $facet`
141 elif [ "$FAILURE_MODE" = SOFT ]; then
148 if [ "$FAILURE_MODE" = HARD ]; then
149 $POWER_UP `facet_active_host $facet`
157 check_network "$HOST" 900
158 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
163 HOST=`facet_active_host $facet`
168 # not every config has many clients
169 if [ ! -z "$CLIENTS" ]; then
170 $PDSH $CLIENTS "df $MOUNT" > /dev/null
175 uname -n >> $MOUNT/recon
176 if [ ! -z "$CLIENTS" ]; then
177 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
179 echo Connected clients:
181 ls -l $MOUNT/recon > /dev/null
187 echo "Failing $facet node `facet_active_host $facet`"
188 shutdown_facet $facet
192 echo "df pid is $DFPID"
194 TO=`facet_active_host $facet`
195 echo "Failover $facet to $TO"
208 local svc=${facet}_svc
209 do_facet $facet $LCTL --device %${!svc} readonly
210 do_facet $facet $LCTL --device %${!svc} notransno
211 do_facet $facet $LCTL mark "$facet REPLAY BARRIER"
212 $LCTL mark "local REPLAY BARRIER on ${!svc}"
215 replay_barrier_nodf() {
218 local svc=${facet}_svc
219 echo Replay barrier on ${!svc}
220 do_facet $facet $LCTL --device %${!svc} readonly
221 do_facet $facet $LCTL --device %${!svc} notransno
222 do_facet $facet $LCTL mark "$facet REPLAY BARRIER"
223 $LCTL mark "local REPLAY BARRIER on ${!svc}"
227 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
228 do_facet mds "echo $UUID > /proc/fs/lustre/mds/${mds_svc}/evict_client"
234 df $MOUNT || error "post-failover df: $?"
242 local svc=${facet}_svc
243 do_facet $facet lctl --device %${!svc} abort_recovery
244 df $MOUNT || echo "first df failed: $?"
246 df $MOUNT || error "post-failover df: $?"
250 echo There is no lmc. This is mountconf, baby.
255 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
256 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
262 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
269 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
270 ID=`echo $1 | sed 's/[^0-9]*//g'`
277 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
278 ID=`echo $1 | sed 's/[^0-9]*//g'`
286 varname=${facet}_HOST
292 HOST=`facet_host $facet`
293 if [ -z "$HOST" ]; then
294 echo "The env variable ${facet}_HOST must be set."
297 if [ -z "$NETTYPE" ]; then
298 echo "The env variable NETTYPE must be set."
301 echo `h2$NETTYPE $HOST`
306 local activevar=${facet}active
308 if [ -f ./${facet}active ] ; then
309 source ./${facet}active
313 if [ -z "$active" ] ; then
320 facet_active_host() {
322 local active=`facet_active $facet`
323 if [ "$facet" == client ]; then
326 echo `facet_host $active`
332 failover=${facet}failover
333 host=`facet_host $failover`
334 [ -z "$host" ] && return
335 curactive=`facet_active $facet`
336 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
337 eval export ${facet}active=$facet
339 eval export ${facet}active=$failover
341 # save the active host for this facet
342 activevar=${facet}active
343 echo "$activevar=${!activevar}" > ./$activevar
350 if [ "$HOST" = "$(hostname)" ]; then
355 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
357 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
363 HOST=`facet_active_host $facet`
370 echo "add facet $facet: `facet_host $facet`"
371 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
372 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
373 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
374 --nettype lnet $PORT_OPT
381 umount -d -f /mnt/${facet} || true
391 [ "x$CLIENTOPT" != "x" ] && MOUNT_OPTS="--clientoptions $CLIENTOPT"
392 add_facet $facet --lustre_upcall $UPCALL
393 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $* $MOUNT_OPTS
404 while [ $NETWORK -eq 0 ]; do
405 ping -c 1 -w 3 $1 > /dev/null
406 if [ $? -eq 0 ]; then
410 echo "waiting for $1, $((MAX - WAIT)) secs left"
413 if [ $WAIT -gt $MAX ]; then
414 echo "Network not available"
420 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
431 # the sed converts spaces to commas, but leaves the last space
432 # alone, so the line doesn't end with a comma.
433 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
437 (cd `dirname $1`; echo $PWD/`basename $1`)
440 ##################################
444 # OBD_FAIL_MDS_ALL_REQUEST_NET
446 do_facet mds sysctl -w lustre.fail_loc=0x123
447 do_facet client "$1" || RC=$?
448 do_facet mds sysctl -w lustre.fail_loc=0
453 # OBD_FAIL_MDS_ALL_REPLY_NET
455 do_facet mds sysctl -w lustre.fail_loc=0x122
456 do_facet client "$@" || RC=$?
457 do_facet mds sysctl -w lustre.fail_loc=0
462 # OBD_FAIL_MDS_REINT_NET_REP
464 do_facet mds sysctl -w lustre.fail_loc=0x119
465 do_facet client "$@" || RC=$?
466 do_facet mds sysctl -w lustre.fail_loc=0
471 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
473 do_facet ost sysctl -w lustre.fail_loc=0x214
474 do_facet client "$1" || RC=$?
475 do_facet client "sync"
476 do_facet ost sysctl -w lustre.fail_loc=0
481 #define OBD_FAIL_LDLM_CANCEL 0x304
483 do_facet client sysctl -w lustre.fail_loc=0x304
484 do_facet client "$@" || RC=$?
485 do_facet client sysctl -w lustre.fail_loc=0
490 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
492 do_facet client sysctl -w lustre.fail_loc=0x305
493 do_facet client "$@" || RC=$?
494 do_facet client sysctl -w lustre.fail_loc=0
502 echo "clearing fail_loc on $facet"
503 do_facet $facet "sysctl -w lustre.fail_loc=0"
507 $LCTL mark "cancel_lru_locks start"
508 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
509 if [ -f $d/lru_size ]; then
510 echo clear > $d/lru_size
511 grep "[0-9]" $d/lock_unused_count
514 $LCTL mark "cancel_lru_locks stop"
519 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
520 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
521 echo there is still data in page cache $a ?
529 ##################################
532 sysctl -w lustre.fail_loc=0 || true
533 echo "${TESTSUITE}: **** FAIL:" $@
538 build_test_filter() {
539 [ "$ONLY" ] && log "only running test `echo $ONLY`"
543 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
544 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
545 for E in $EXCEPT $ALWAYS_EXCEPT; do
546 eval EXCEPT_${E}=true
555 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
559 export base=`basetest $1`
560 if [ ! -z "$ONLY" ]; then
562 if [ ${!testname}x != x ]; then
567 if [ ${!testname}x != x ]; then
575 if [ ${!testname}x != x ]; then
576 echo "skipping excluded test $1"
579 testname=EXCEPT_$base
580 if [ ${!testname}x != x ]; then
581 echo "skipping excluded test $1 (base $base)"
589 EQUALS="======================================================================"
593 local suffixlen=$((${#EQUALS} - ${#msg}))
594 [ $suffixlen -lt 5 ] && suffixlen=5
595 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
600 $LCTL mark "$*" 2> /dev/null || true
608 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
609 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
610 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
619 # Pretty tests run faster.
620 equals_msg $testnum: $message
623 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
625 test_${testnum} || error "test_$testnum failed with $?"
627 pass "($((`date +%s` - $BEFORE))s)"
631 (cd `dirname $1`; echo $PWD/`basename $1`)