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 CHECKSTAT="${CHECKSTAT:-checkstat} "
42 export FSYTPE=${FSTYPE:-"ext3"}
44 if [ "$ACCEPTOR_PORT" ]; then
45 export PORT_OPT="--port $ACCEPTOR_PORT"
48 # Paths on remote nodes, if different
49 export RLUSTRE=${RLUSTRE:-$LUSTRE}
50 export RPWD=${RPWD:-$PWD}
54 while getopts "rvf:" opt $*; do
57 r) REFORMAT=--reformat;;
66 # save the name of the config file for the upcall
67 echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG" > $LUSTRE/tests/XMLCONFIG
68 # echo "CONFIG=`canonical_path $CONFIG`" > $LUSTRE/tests/CONFIG
72 # start facet device options
78 active=`facet_active $facet`
79 echo "mount active=${active}, facet=${facet}"
80 mkdir -p /mnt/${facet}
81 do_facet ${facet} mount -t lustre $@ ${device} /mnt/${facet}
82 #do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
83 # --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
86 if [ $RC -ne 0 ]; then
87 # maybe acceptor error, dump tcp port usage
96 active=`facet_active $facet`
97 echo "umount active=${active}, facet=${facet}"
98 do_facet ${facet} umount -d $@ /mnt/${facet}
99 #do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
100 # --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
101 # $@ --cleanup $XMLCONFIG
110 do_node $client mkdir $mnt 2> /dev/null || :
112 # Only supply -o to mount if we have options
113 if [ -n "$MOUNTOPT" ]; then
114 OPTIONS="-o $MOUNTOPT"
117 do_node $client mount -t lustre $OPTIONS \
118 `facet_nid mgs`:/lustre-client $mnt || return 1
120 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
128 do_node $client umount $force $mnt
133 if [ "$FAILURE_MODE" = HARD ]; then
134 $POWER_DOWN `facet_active_host $facet`
136 elif [ "$FAILURE_MODE" = SOFT ]; then
143 if [ "$FAILURE_MODE" = HARD ]; then
144 $POWER_UP `facet_active_host $facet`
152 check_network "$HOST" 900
153 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
158 HOST=`facet_active_host $facet`
163 # not every config has many clients
164 if [ ! -z "$CLIENTS" ]; then
165 $PDSH $CLIENTS "df $MOUNT" > /dev/null
170 uname -n >> $MOUNT/recon
171 if [ ! -z "$CLIENTS" ]; then
172 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
174 echo Connected clients:
176 ls -l $MOUNT/recon > /dev/null
182 echo "Failing $facet node `facet_active_host $facet`"
183 shutdown_facet $facet
187 echo "df pid is $DFPID"
189 TO=`facet_active_host $facet`
190 echo "Failover $facet to $TO"
199 do_facet $facet $LCTL --device %${facet}_svc readonly
200 do_facet $facet $LCTL --device %${facet}_svc notransno
201 do_facet $facet $LCTL mark "$facet REPLAY BARRIER"
202 $LCTL mark "local REPLAY BARRIER"
205 replay_barrier_nodf() {
208 do_facet $facet $LCTL --device %${facet}_svc readonly
209 do_facet $facet $LCTL --device %${facet}_svc notransno
210 do_facet $facet $LCTL mark "$facet REPLAY BARRIER"
211 $LCTL mark "local REPLAY BARRIER"
215 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
216 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
222 df $MOUNT || error "post-failover df: $?"
230 do_facet $facet lctl --device %${facet}_svc abort_recovery
231 df $MOUNT || echo "first df failed: $?"
233 df $MOUNT || error "post-failover df: $?"
237 echo There is no lmc. This is mountconf, baby.
242 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
243 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
249 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
256 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
257 ID=`echo $1 | sed 's/[^0-9]*//g'`
264 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
265 ID=`echo $1 | sed 's/[^0-9]*//g'`
273 varname=${facet}_HOST
279 HOST=`facet_host $facet`
280 if [ -z "$HOST" ]; then
281 echo "The env variable ${facet}_HOST must be set."
284 if [ -z "$NETTYPE" ]; then
285 echo "The env variable NETTYPE must be set."
288 echo `h2$NETTYPE $HOST`
293 local activevar=${facet}active
295 if [ -f ./${facet}active ] ; then
296 source ./${facet}active
300 if [ -z "$active" ] ; then
307 facet_active_host() {
309 local active=`facet_active $facet`
310 if [ "$facet" == client ]; then
313 echo `facet_host $active`
319 failover=${facet}failover
320 host=`facet_host $failover`
321 [ -z "$host" ] && return
322 curactive=`facet_active $facet`
323 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
324 eval export ${facet}active=$facet
326 eval export ${facet}active=$failover
328 # save the active host for this facet
329 activevar=${facet}active
330 echo "$activevar=${!activevar}" > ./$activevar
338 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
340 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
346 HOST=`facet_active_host $facet`
353 echo "add facet $facet: `facet_host $facet`"
354 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
355 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
356 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
357 --nettype lnet $PORT_OPT
364 umount -d -f /mnt/${facet} || true
374 [ "x$CLIENTOPT" != "x" ] && MOUNT_OPTS="--clientoptions $CLIENTOPT"
375 add_facet $facet --lustre_upcall $UPCALL
376 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $* $MOUNT_OPTS
387 while [ $NETWORK -eq 0 ]; do
388 ping -c 1 -w 3 $1 > /dev/null
389 if [ $? -eq 0 ]; then
393 echo "waiting for $1, $((MAX - WAIT)) secs left"
396 if [ $WAIT -gt $MAX ]; then
397 echo "Network not available"
403 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
414 # the sed converts spaces to commas, but leaves the last space
415 # alone, so the line doesn't end with a comma.
416 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
420 (cd `dirname $1`; echo $PWD/`basename $1`)
423 ##################################
427 # OBD_FAIL_MDS_ALL_REQUEST_NET
429 do_facet mds sysctl -w lustre.fail_loc=0x123
430 do_facet client "$1" || RC=$?
431 do_facet mds sysctl -w lustre.fail_loc=0
436 # OBD_FAIL_MDS_ALL_REPLY_NET
438 do_facet mds sysctl -w lustre.fail_loc=0x122
439 do_facet client "$@" || RC=$?
440 do_facet mds sysctl -w lustre.fail_loc=0
445 # OBD_FAIL_MDS_REINT_NET_REP
447 do_facet mds sysctl -w lustre.fail_loc=0x119
448 do_facet client "$@" || RC=$?
449 do_facet mds sysctl -w lustre.fail_loc=0
454 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
456 do_facet ost sysctl -w lustre.fail_loc=0x214
457 do_facet client "$1" || RC=$?
458 do_facet client "sync"
459 do_facet ost sysctl -w lustre.fail_loc=0
464 #define OBD_FAIL_LDLM_CANCEL 0x304
466 do_facet client sysctl -w lustre.fail_loc=0x304
467 do_facet client "$@" || RC=$?
468 do_facet client sysctl -w lustre.fail_loc=0
473 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
475 do_facet client sysctl -w lustre.fail_loc=0x305
476 do_facet client "$@" || RC=$?
477 do_facet client sysctl -w lustre.fail_loc=0
485 echo "clearing fail_loc on $facet"
486 do_facet $facet "sysctl -w lustre.fail_loc=0"
490 $LCTL mark "cancel_lru_locks start"
491 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
492 if [ -f $d/lru_size ]; then
493 echo clear > $d/lru_size
494 grep "[0-9]" $d/lock_unused_count
497 $LCTL mark "cancel_lru_locks stop"
502 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
503 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
504 echo there is still data in page cache $a ?
512 ##################################
515 sysctl -w lustre.fail_loc=0
516 echo "${TESTSUITE}: **** FAIL:" $@
521 build_test_filter() {
522 [ "$ONLY" ] && log "only running test `echo $ONLY`"
526 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
527 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
528 for E in $EXCEPT $ALWAYS_EXCEPT; do
529 eval EXCEPT_${E}=true
538 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
542 export base=`basetest $1`
543 if [ ! -z "$ONLY" ]; then
545 if [ ${!testname}x != x ]; then
550 if [ ${!testname}x != x ]; then
558 if [ ${!testname}x != x ]; then
559 echo "skipping excluded test $1"
562 testname=EXCEPT_$base
563 if [ ${!testname}x != x ]; then
564 echo "skipping excluded test $1 (base $base)"
572 EQUALS="======================================================================"
576 local suffixlen=$((${#EQUALS} - ${#msg}))
577 [ $suffixlen -lt 5 ] && suffixlen=5
578 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
583 $LCTL mark "$*" 2> /dev/null || true
591 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
592 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
593 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
602 # Pretty tests run faster.
603 equals_msg $testnum: $message
606 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
608 test_${testnum} || error "test_$testnum failed with $?"
610 pass "($((`date +%s` - $BEFORE))s)"
614 (cd `dirname $1`; echo $PWD/`basename $1`)