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"
178 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
179 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds1_svc/evict_client"
184 facet_failover $facet
185 df $MOUNT || error "post-failover df: $?"
191 facet_failover $facet
192 do_facet mds "echo $failcode > /proc/sys/lustre/fail_loc"
193 cat /proc/sys/lustre/fail_loc
194 df $MOUNT || error "post-failover df: $?"
195 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
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'
243 varname=${facet}_HOST
249 HOST=`facet_host $facet`
250 if [ -z "$HOST" ]; then
251 echo "The env variable ${facet}_HOST must be set."
254 echo `h2$NETTYPE $HOST`
259 local activevar=${facet}active
261 if [ -f ./${facet}active ] ; then
262 source ./${facet}active
266 if [ -z "$active" ] ; then
273 facet_active_host() {
275 local active=`facet_active $facet`
276 if [ "$facet" == client ]; then
279 echo `facet_host $active`
285 failover=${facet}failover
286 host=`facet_host $failover`
287 [ -z "$host" ] && return
288 curactive=`facet_active $facet`
289 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
290 eval export ${facet}active=$facet
292 eval export ${facet}active=$failover
294 # save the active host for this facet
295 activevar=${facet}active
296 echo "$activevar=${!activevar}" > ./$activevar
305 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
307 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
311 seq -f mds%g $MDSCOUNT
318 if [ "$facet" == "mds" ]; then
319 for mds in `mds_list`; do
320 HOST=`facet_active_host $mds`
324 HOST=`facet_active_host $facet`
332 echo "add facet $facet: `facet_host $facet`"
333 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
334 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
335 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
344 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc --fstype $FSTYPE $*
350 add_facet ${facet}failover --lustre_upcall $UPCALL
351 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc --fstype $FSTYPE $*
359 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc --fstype $FSTYPE $*
365 do_lmc --delete ost --node ${facet}_facet --ost ${facet}_svc $*
371 do_lmc --deactivate ost --node ${facet}_facet --ost ${facet}_svc $*
377 add_facet ${facet}failover
378 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc --fstype $FSTYPE $*
385 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
392 do_lmc --add lov --lmv $lmv --lov $lov $*
398 do_lmc --add lmv --lmv $lmv $*
405 add_facet $facet --lustre_upcall $UPCALL
406 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
420 while [ $NETWORK -eq 0 ]; do
421 ping -c 1 -w 3 $1 > /dev/null
422 if [ $? -eq 0 ]; then
426 echo "waiting for $1, $((MAX - WAIT)) secs left"
429 if [ $WAIT -gt $MAX ]; then
430 echo "Network not available"
436 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
447 # the sed converts spaces to commas, but leaves the last space
448 # alone, so the line doesn't end with a comma.
449 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
453 (cd `dirname $1`; echo $PWD/`basename $1`)
456 ##################################
460 # OBD_FAIL_MDS_ALL_REQUEST_NET
462 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
463 do_facet client "$1" || RC=$?
464 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
469 # OBD_FAIL_MDS_ALL_REPLY_NET
471 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
472 do_facet client "$@" || RC=$?
473 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
478 # OBD_FAIL_MDS_REINT_NET_REP
480 do_facet mds "echo 0x119 > /proc/sys/lustre/fail_loc"
481 do_facet client "$@" || RC=$?
482 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
487 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
489 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
490 do_facet client "$1" || RC=$?
491 do_facet client "sync"
492 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
497 #define OBD_FAIL_LDLM_CANCEL 0x304
499 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
500 do_facet client "$@" || RC=$?
501 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
506 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
508 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
509 do_facet client "$@" || RC=$?
510 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
518 echo "clearing fail_loc on $facet"
519 do_facet $facet "sysctl -w lustre.fail_loc=0"
523 $LCTL mark cancel_lru_locks
524 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
525 if [ -f $d/lru_size ]; then
526 echo clear > $d/lru_size
527 grep [0-9] $d/lock_unused_count
534 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
535 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
536 echo there is still data in page cache $a ?
544 ##################################
547 echo "${TESTSUITE}: **** FAIL:" $@
552 build_test_filter() {
556 for E in $EXCEPT $ALWAYS_EXCEPT; do
557 eval EXCEPT_${E}=true
566 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
570 export base=`basetest $1`
571 if [ ! -z "$ONLY" ]; then
573 if [ ${!testname}x != x ]; then
578 if [ ${!testname}x != x ]; then
586 if [ ${!testname}x != x ]; then
587 echo "skipping excluded test $1"
590 testname=EXCEPT_$base
591 if [ ${!testname}x != x ]; then
592 echo "skipping excluded test $1 (base $base)"
600 EQUALS="======================================================================"
604 local suffixlen=$((${#EQUALS} - ${#msg}))
605 [ $suffixlen -lt 5 ] && suffixlen=5
606 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
611 lctl mark "$*" 2> /dev/null || true
620 # Pretty tests run faster.
621 equals_msg $testnum: $message
624 test_${testnum} || error "test_$testnum failed with $?"
628 (cd `dirname $1`; echo $PWD/`basename $1`)