7 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
11 if [ -z "${!name}" ]; then
12 echo "$0: $name must be set"
16 [ $failed ] && exit 1 || true
20 echo "usage: $0 [-r] [-f cfgfile]"
27 export LUSTRE=`absolute_path $LUSTRE`
28 export TESTSUITE=`basename $0 .sh`
29 export XMLCONFIG=${XMLCONFIG:-${TESTSUITE}.xml}
30 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
32 [ -d /r ] && test "x$ROOT" = "x" && export ROOT=/r
33 export TMP=${TMP:-$ROOT/tmp}
35 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
36 export LLMOUNT=${LLMOUNT:-"llmount"}
37 export LCONF=${LCONF:-"lconf"}
38 export LMC=${LMC:-"lmc"}
39 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
40 export CHECKSTAT="${CHECKSTAT:-checkstat} "
41 export FSYTPE=${FSTYPE:-"ext3"}
42 export SECURITY=${SECURITY:-"null"}
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
73 active=`facet_active $facet`
74 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
75 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
76 --sec $SECURITY $@ $XMLCONFIG
81 active=`facet_active $facet`
83 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
84 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
85 $@ --cleanup $XMLCONFIG
92 do_node $client mkdir $mnt 2> /dev/null || :
94 if [ -x /sbin/mount.lustre ] ; then
95 do_node $client mount -t lustre -o sec=$SECURITY,nettype=$NETTYPE \
96 `facet_active_host mds1`:/mds1_svc/client_facet $mnt || return 2
99 do_node $client $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null || return 2
100 do_node $client $LLMOUNT `facet_active_host mds1`:/mds1_svc/client_facet $mnt \
101 -o sec=$SECURITY,nettype=$NETTYPE|| return 4
104 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
112 do_node $client umount $force $mnt || :
113 do_node $client $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null || :
118 if [ "$FAILURE_MODE" = HARD ]; then
119 $POWER_DOWN `facet_active_host $facet`
121 elif [ "$FAILURE_MODE" = SOFT ]; then
122 stop $facet --force --failover --nomod
128 if [ "$FAILURE_MODE" = HARD ]; then
129 $POWER_UP `facet_active_host $facet`
135 check_network $HOST 900
136 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
141 HOST=`facet_active_host $facet`
146 # not every config has many clients
147 if [ ! -z "$CLIENTS" ]; then
148 $PDSH $CLIENTS "df $MOUNT" > /dev/null
154 echo "Failing $facet node `facet_active_host $facet`"
155 shutdown_facet $facet
159 echo "df pid is $DFPID"
161 TO=`facet_active_host $facet`
162 echo "Failover $facet to $TO"
171 do_facet $facet $LCTL --device %${facet}_svc readonly
172 do_facet $facet $LCTL --device %${facet}_svc notransno
173 do_facet $facet $LCTL mark "REPLAY BARRIER"
174 $LCTL mark "REPLAY BARRIER"
177 replay_barrier_nodf() {
180 do_facet $facet $LCTL --device %${facet}_svc readonly
181 do_facet $facet $LCTL --device %${facet}_svc notransno
182 do_facet $facet $LCTL mark "REPLAY BARRIER"
183 $LCTL mark "REPLAY BARRIER"
187 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
188 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds1_svc/evict_client"
193 facet_failover $facet
194 df $MOUNT || error "post-failover df: $?"
200 facet_failover $facet
201 do_facet mds "echo $failcode > /proc/sys/lustre/fail_loc"
202 cat /proc/sys/lustre/fail_loc
203 df $MOUNT || error "post-failover df: $?"
204 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
209 stop $facet --force --failover --nomod
212 do_facet $facet lctl --device %${facet}_svc abort_recovery
213 df $MOUNT || echo "first df failed: $?"
215 df $MOUNT || error "post-failover df: $?"
219 $LMC -m ${XMLCONFIG} $@
223 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
224 $PDSH $1 $GMNALNID -l | cut -d\ -f2
229 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
236 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
237 echo $1 | sed 's/[^0-9]*//g'
243 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
244 echo $1 | sed 's/[^0-9]*//g'
252 varname=${facet}_HOST
258 HOST=`facet_host $facet`
259 if [ -z "$HOST" ]; then
260 echo "The env variable ${facet}_HOST must be set."
263 echo `h2$NETTYPE $HOST`
268 local activevar=${facet}active
270 if [ -f ./${facet}active ] ; then
271 source ./${facet}active
275 if [ -z "$active" ] ; then
282 facet_active_host() {
284 local active=`facet_active $facet`
285 if [ "$facet" == client ]; then
288 echo `facet_host $active`
294 failover=${facet}failover
295 host=`facet_host $failover`
296 [ -z "$host" ] && return
297 curactive=`facet_active $facet`
298 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
299 eval export ${facet}active=$facet
301 eval export ${facet}active=$failover
303 # save the active host for this facet
304 activevar=${facet}active
305 echo "$activevar=${!activevar}" > ./$activevar
314 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
316 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
320 seq -f mds%g $MDSCOUNT
327 if [ "$facet" == "mds" ]; then
328 for mds in `mds_list`; do
329 HOST=`facet_active_host $mds`
333 HOST=`facet_active_host $facet`
341 echo "add facet $facet: `facet_host $facet`"
342 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
343 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
344 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
353 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc --fstype $FSTYPE $*
359 add_facet ${facet}failover --lustre_upcall $UPCALL
360 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc --fstype $FSTYPE $*
368 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc --fstype $FSTYPE $*
374 do_lmc --delete ost --node ${facet}_facet --ost ${facet}_svc $*
380 do_lmc --deactivate ost --node ${facet}_facet --ost ${facet}_svc $*
386 add_facet ${facet}failover
387 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc --fstype $FSTYPE $*
394 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
401 do_lmc --add lov --lmv $lmv --lov $lov $*
407 do_lmc --add lmv --lmv $lmv $*
414 add_facet $facet --lustre_upcall $UPCALL
415 do_lmc --add mtpt --node ${facet}_facet --clientoptions async --mds ${mds}_svc $*
429 while [ $NETWORK -eq 0 ]; do
430 ping -c 1 -w 3 $1 > /dev/null
431 if [ $? -eq 0 ]; then
435 echo "waiting for $1, $((MAX - WAIT)) secs left"
438 if [ $WAIT -gt $MAX ]; then
439 echo "Network not available"
445 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
456 # the sed converts spaces to commas, but leaves the last space
457 # alone, so the line doesn't end with a comma.
458 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
462 (cd `dirname $1`; echo $PWD/`basename $1`)
465 ##################################
469 # OBD_FAIL_MDS_ALL_REQUEST_NET
471 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
472 do_facet client "$1" || RC=$?
473 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
478 # OBD_FAIL_MDS_ALL_REPLY_NET
480 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
481 do_facet client "$@" || RC=$?
482 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
487 # OBD_FAIL_MDS_REINT_NET_REP
489 do_facet mds "echo 0x119 > /proc/sys/lustre/fail_loc"
490 do_facet client "$@" || RC=$?
491 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
496 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
498 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
499 do_facet client "$1" || RC=$?
500 do_facet client "sync"
501 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
506 #define OBD_FAIL_LDLM_CANCEL 0x304
508 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
509 do_facet client "$@" || RC=$?
510 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
515 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
517 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
518 do_facet client "$@" || RC=$?
519 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
527 echo "clearing fail_loc on $facet"
528 do_facet $facet "sysctl -w lustre.fail_loc=0"
532 $LCTL mark cancel_lru_locks
533 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
534 if [ -f $d/lru_size ]; then
535 echo clear > $d/lru_size
536 grep [0-9] $d/lock_unused_count
543 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
544 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
545 echo there is still data in page cache $a ?
553 ##################################
556 echo "${TESTSUITE}: **** FAIL:" $@
561 build_test_filter() {
562 [ "$ONLY" ] && log "only running $ONLY"
566 [ "$EXCEPT$ALWAYS_EXCEPT" ] && log "skipping $EXCEPT $ALWAYS_EXCEPT"
567 for E in $EXCEPT $ALWAYS_EXCEPT; do
568 eval EXCEPT_${E}=true
577 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
581 export base=`basetest $1`
582 if [ ! -z "$ONLY" ]; then
584 if [ ${!testname}x != x ]; then
589 if [ ${!testname}x != x ]; then
597 if [ ${!testname}x != x ]; then
598 echo "skipping excluded test $1"
601 testname=EXCEPT_$base
602 if [ ${!testname}x != x ]; then
603 echo "skipping excluded test $1 (base $base)"
611 EQUALS="======================================================================"
615 local suffixlen=$((${#EQUALS} - ${#msg}))
616 [ $suffixlen -lt 5 ] && suffixlen=5
617 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
622 lctl mark "$*" 2> /dev/null || true
635 # Pretty tests run faster.
636 equals_msg $testnum: $message
639 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
640 test_${testnum} || error "test_$testnum failed with $?"
641 pass "($((`date +%s` - $BEFORE))s)"
645 (cd `dirname $1`; echo $PWD/`basename $1`)