8 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
12 if [ -z "${!name}" ]; then
13 echo "$0: $name must be set"
17 [ $failed ] && exit 1 || true
21 echo "usage: $0 [-r] [-f cfgfile]"
28 export LUSTRE=`absolute_path $LUSTRE`
29 export TESTSUITE=`basename $0 .sh`
30 export XMLCONFIG=${XMLCONFIG:-${TESTSUITE}.xml}
31 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
33 [ -d /r ] && export ROOT=/r
34 export TMP=${TMP:-$ROOT/tmp}
36 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
37 export LLMOUNT=${LLMOUNT:-"llmount"}
38 export LCONF=${LCONF:-"lconf"}
39 export LMC=${LMC:-"lmc"}
40 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
41 export CHECKSTAT="${CHECKSTAT:-checkstat} "
42 export FSYTPE=${FSTYPE:-"ext3"}
44 # Paths on remote nodes, if different
45 export RLUSTRE=${RLUSTRE:-$LUSTRE}
46 export RPWD=${RPWD:-$PWD}
50 while getopts "rvf:" opt $*; do
53 r) REFORMAT=--reformat;;
62 # save the name of the config file for the upcall
63 echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG" > $LUSTRE/tests/XMLCONFIG
64 # echo "CONFIG=`canonical_path $CONFIG`" > $LUSTRE/tests/CONFIG
71 active=`facet_active $facet`
72 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
73 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
79 active=`facet_active $facet`
81 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
82 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
83 $@ --cleanup $XMLCONFIG
90 do_node $client mkdir $mnt 2> /dev/null || :
92 if [ -x /sbin/mount.lustre ] ; then
93 do_node $client mount -t lustre -o nettype=$NETTYPE,$MOUNTOPT \
94 `facet_active_host mds`:/mds_svc/client_facet $mnt || return 1
97 do_node $client $LCONF --nosetup --node client_facet $XMLCONFIG > \
99 do_node $client $LLMOUNT -o nettype=$NETTYPE,$MOUNTOPT \
100 `facet_active_host mds`:/mds_svc/client_facet $mnt || return 4
103 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
111 do_node $client umount $force $mnt || :
112 do_node $client $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null || :
117 if [ "$FAILURE_MODE" = HARD ]; then
118 $POWER_DOWN `facet_active_host $facet`
120 elif [ "$FAILURE_MODE" = SOFT ]; then
121 stop $facet --force --failover --nomod
127 if [ "$FAILURE_MODE" = HARD ]; then
128 $POWER_UP `facet_active_host $facet`
136 check_network "$HOST" 900
137 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
142 HOST=`facet_active_host $facet`
147 # not every config has many clients
148 if [ ! -z "$CLIENTS" ]; then
149 $PDSH $CLIENTS "df $MOUNT" > /dev/null
155 echo "Failing $facet node `facet_active_host $facet`"
156 shutdown_facet $facet
160 echo "df pid is $DFPID"
162 TO=`facet_active_host $facet`
163 echo "Failover $facet to $TO"
172 do_facet $facet $LCTL --device %${facet}_svc readonly
173 do_facet $facet $LCTL --device %${facet}_svc notransno
174 do_facet $facet $LCTL mark "REPLAY BARRIER"
175 $LCTL mark "REPLAY BARRIER"
178 replay_barrier_nodf() {
181 do_facet $facet $LCTL --device %${facet}_svc readonly
182 do_facet $facet $LCTL --device %${facet}_svc notransno
183 do_facet $facet $LCTL mark "REPLAY BARRIER"
184 $LCTL mark "REPLAY BARRIER"
188 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
189 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
194 facet_failover $facet
195 df $MOUNT || error "post-failover df: $?"
200 stop $facet --force --failover --nomod
203 do_facet $facet lctl --device %${facet}_svc abort_recovery
204 df $MOUNT || echo "first df failed: $?"
206 df $MOUNT || error "post-failover df: $?"
210 $LMC -m ${XMLCONFIG} $@
214 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
215 $PDSH $1 $GMNALNID -l | cut -d\ -f2
220 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
227 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
228 echo $1 | sed 's/[^0-9]*//g'
234 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
235 echo $1 | sed 's/[^0-9]*//g'
242 varname=${facet}_HOST
248 HOST=`facet_host $facet`
249 if [ -z "$HOST" ]; then
250 echo "The env variable ${facet}_HOST must be set."
253 echo `h2$NETTYPE $HOST`
258 local activevar=${facet}active
260 if [ -f ./${facet}active ] ; then
261 source ./${facet}active
265 if [ -z "$active" ] ; then
272 facet_active_host() {
274 local active=`facet_active $facet`
275 if [ "$facet" == client ]; then
278 echo `facet_host $active`
284 failover=${facet}failover
285 host=`facet_host $failover`
286 [ -z "$host" ] && return
287 curactive=`facet_active $facet`
288 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
289 eval export ${facet}active=$facet
291 eval export ${facet}active=$failover
293 # save the active host for this facet
294 activevar=${facet}active
295 echo "$activevar=${!activevar}" > ./$activevar
304 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
306 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
312 HOST=`facet_active_host $facet`
319 echo "add facet $facet: `facet_host $facet`"
320 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
321 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
322 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
331 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc \
332 --fstype $FSTYPE $* $MDSOPT
338 add_facet ${facet}failover --lustre_upcall $UPCALL
339 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc \
340 --fstype $FSTYPE $* $MDSOPT
348 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc \
349 --fstype $FSTYPE $* $OSTOPT
355 add_facet ${facet}failover
356 do_lmc --add ost --failover --node ${facet}failover_facet \
357 --ost ${facet}_svc --fstype $FSTYPE $* $OSTOPT
364 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $* $LOVOPT
371 add_facet $facet --lustre_upcall $UPCALL
372 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $* $CLIENTOPT
383 while [ $NETWORK -eq 0 ]; do
384 ping -c 1 -w 3 $1 > /dev/null
385 if [ $? -eq 0 ]; then
389 echo "waiting for $1, $((MAX - WAIT)) secs left"
392 if [ $WAIT -gt $MAX ]; then
393 echo "Network not available"
399 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
410 # the sed converts spaces to commas, but leaves the last space
411 # alone, so the line doesn't end with a comma.
412 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
416 (cd `dirname $1`; echo $PWD/`basename $1`)
419 ##################################
423 # OBD_FAIL_MDS_ALL_REQUEST_NET
425 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
426 do_facet client "$1" || RC=$?
427 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
432 # OBD_FAIL_MDS_ALL_REPLY_NET
434 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
435 do_facet client "$@" || RC=$?
436 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
441 # OBD_FAIL_MDS_REINT_NET_REP
443 do_facet mds "echo 0x119 > /proc/sys/lustre/fail_loc"
444 do_facet client "$@" || RC=$?
445 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
450 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
452 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
453 do_facet client "$1" || RC=$?
454 do_facet client "sync"
455 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
460 #define OBD_FAIL_LDLM_CANCEL 0x304
462 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
463 do_facet client "$@" || RC=$?
464 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
469 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
471 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
472 do_facet client "$@" || RC=$?
473 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
481 echo "clearing fail_loc on $facet"
482 do_facet $facet "sysctl -w lustre.fail_loc=0"
486 $LCTL mark "cancel_lru_locks start"
487 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
488 if [ -f $d/lru_size ]; then
489 echo clear > $d/lru_size
490 grep "[0-9]" $d/lock_unused_count
493 $LCTL mark "cancel_lru_locks stop"
498 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
499 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
500 echo there is still data in page cache $a ?
508 ##################################
511 echo "${TESTSUITE}: **** FAIL:" $@
516 build_test_filter() {
517 [ "$ONLY" ] && log "only running test `echo $ONLY`"
521 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
522 log "skipping `echo $EXCEPT $ALWAYS_EXCEPT`"
523 for E in $EXCEPT $ALWAYS_EXCEPT; do
524 eval EXCEPT_${E}=true
533 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
537 export base=`basetest $1`
538 if [ ! -z "$ONLY" ]; then
540 if [ ${!testname}x != x ]; then
545 if [ ${!testname}x != x ]; then
553 if [ ${!testname}x != x ]; then
554 echo "skipping excluded test $1"
557 testname=EXCEPT_$base
558 if [ ${!testname}x != x ]; then
559 echo "skipping excluded test $1 (base $base)"
567 EQUALS="======================================================================"
571 local suffixlen=$((${#EQUALS} - ${#msg}))
572 [ $suffixlen -lt 5 ] && suffixlen=5
573 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
578 $LCTL mark "$*" 2> /dev/null || true
591 # Pretty tests run faster.
592 equals_msg $testnum: $message
595 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
596 test_${testnum} || error "test_$testnum failed with $?"
597 pass "($((`date +%s` - $BEFORE))s)"
601 (cd `dirname $1`; echo $PWD/`basename $1`)