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 `facet_active_host mds1`:/mds1_svc/client_facet $mnt || return 1
96 do_node $client $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null || return 2
97 $LCONF --nosetup --node client_facet $XMLCONFIG
98 do_node $client $LLMOUNT `facet_active_host mds1`:/mds1_svc/client_facet $mnt -o nettype=$NETTYPE|| return 4
101 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
109 do_node $client umount $force $mnt || :
110 do_node $client $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null || :
115 if [ "$FAILURE_MODE" = HARD ]; then
116 $POWER_DOWN `facet_active_host $facet`
118 elif [ "$FAILURE_MODE" = SOFT ]; then
119 stop $facet --force --failover --nomod
125 if [ "$FAILURE_MODE" = HARD ]; then
126 $POWER_UP `facet_active_host $facet`
132 check_network $HOST 900
133 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
138 HOST=`facet_active_host $facet`
143 # not every config has many clients
144 if [ ! -z "$CLIENTS" ]; then
145 $PDSH $CLIENTS "df $MOUNT" > /dev/null
151 echo "Failing $facet node `facet_active_host $facet`"
152 shutdown_facet $facet
156 echo "df pid is $DFPID"
158 TO=`facet_active_host $facet`
159 echo "Failover $facet to $TO"
168 do_facet $facet $LCTL --device %${facet}_svc readonly
169 do_facet $facet $LCTL --device %${facet}_svc notransno
170 do_facet $facet $LCTL mark "REPLAY BARRIER"
171 $LCTL mark "REPLAY BARRIER"
175 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
176 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds1_svc/evict_client"
181 facet_failover $facet
182 df $MOUNT || error "post-failover df: $?"
187 stop $facet --force --failover --nomod
190 do_facet $facet lctl --device %${facet}_svc abort_recovery
191 df $MOUNT || echo "first df failed: $?"
192 df $MOUNT || error "post-failover df: $?"
196 $LMC -m ${XMLCONFIG} $@
200 if [ "$1" = "client" ]; then echo \'*\'; else
201 $PDSH $1 $GMNALNID -l | cut -d\ -f2
206 if [ "$1" = "client" ]; then echo \'*\'; else
213 if [ "$1" = "client" ]; then echo \'*\'; else
214 echo $1 | sed 's/[^0-9]*//g'
221 varname=${facet}_HOST
227 HOST=`facet_host $facet`
228 if [ -z "$HOST" ]; then
229 echo "The env variable ${facet}_HOST must be set."
232 echo `h2$NETTYPE $HOST`
237 local activevar=${facet}active
239 if [ -z "$active" ] ; then
246 facet_active_host() {
248 local active=`facet_active $facet`
249 if [ "$facet" == client ]; then
252 echo `facet_host $active`
258 failover=${facet}failover
259 host=`facet_host $failover`
260 [ -z "$host" ] && return
261 curactive=`facet_active $facet`
262 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
263 eval export ${facet}active=$facet
265 eval export ${facet}active=$failover
267 # save the active host for this facet
268 activevar=${facet}active
269 echo "$activevar=${!activevar}" > ./$activevar
278 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
280 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
284 seq -f mds%g $MDSCOUNT
291 if [ "$facet" == "mds" ]; then
292 for mds in `mds_list`; do
293 HOST=`facet_active_host $mds`
297 HOST=`facet_active_host $facet`
305 echo "add facet $facet: `facet_host $facet`"
306 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
307 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
308 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
317 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc --fstype $FSTYPE $*
323 add_facet ${facet}failover --lustre_upcall $UPCALL
324 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc --fstype $FSTYPE $*
332 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc --fstype $FSTYPE $*
338 do_lmc --delete ost --node ${facet}_facet --ost ${facet}_svc $*
344 do_lmc --deactivate ost --node ${facet}_facet --ost ${facet}_svc $*
350 add_facet ${facet}failover
351 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc --fstype $FSTYPE $*
358 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
365 do_lmc --add lov --lmv $lmv --lov $lov $*
371 do_lmc --add lmv --lmv $lmv $*
377 add_facet $facet --lustre_upcall $UPCALL
378 do_lmc --add mtpt --node ${facet}_facet $*
392 while [ $NETWORK -eq 0 ]; do
393 ping -c 1 -w 3 $1 > /dev/null
394 if [ $? -eq 0 ]; then
398 echo "waiting for $1, $((MAX - WAIT)) secs left"
401 if [ $WAIT -gt $MAX ]; then
402 echo "Network not available"
408 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
419 # the sed converts spaces to commas, but leaves the last space
420 # alone, so the line doesn't end with a comma.
421 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
425 (cd `dirname $1`; echo $PWD/`basename $1`)
428 ##################################
432 # OBD_FAIL_MDS_ALL_REQUEST_NET
434 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
435 do_facet client "$1" || RC=$?
436 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
441 # OBD_FAIL_MDS_ALL_REPLY_NET
443 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
444 do_facet client "$@" || RC=$?
445 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
450 # OBD_FAIL_MDS_REINT_NET_REP
452 do_facet mds "echo 0x119 > /proc/sys/lustre/fail_loc"
453 do_facet client "$@" || RC=$?
454 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
459 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
461 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
462 do_facet client "$1" || RC=$?
463 do_facet client "sync"
464 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
469 #define OBD_FAIL_LDLM_CANCEL 0x304
471 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
472 do_facet client "$@" || RC=$?
473 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
478 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
480 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
481 do_facet client "$@" || RC=$?
482 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
490 echo "clearing fail_loc on $facet"
491 do_facet $facet "sysctl -w lustre.fail_loc=0"
495 $LCTL mark cancel_lru_locks
496 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
497 if [ -f $d/lru_size ]; then
498 echo clear > $d/lru_size
499 grep [0-9] $d/lock_unused_count
506 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
507 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
508 echo there is still data in page cache $a ?
516 ##################################
519 echo "${TESTSUITE}: **** FAIL:" $@
524 build_test_filter() {
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
592 # Pretty tests run faster.
593 equals_msg $testnum: $message
596 test_${testnum} || error "test_$testnum failed with $?"
600 (cd `dirname $1`; echo $PWD/`basename $1`)