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="${TESTSUITE}.xml"
31 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
33 [ -d /r ] && export ROOT=/r
35 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
36 export LCONF=${LCONF:-"lconf"}
37 export LMC=${LMC:-"lmc"}
38 export LCTL=${LCTL:-"lctl"}
39 export CHECKSTAT="${CHECKSTAT:-checkstat} "
41 # Paths on remote nodes, if different
42 export RLUSTRE=${RLUSTRE:-$LUSTRE}
43 export RPWD=${RPWD:-$PWD}
47 while getopts "rvf:" opt $*; do
50 r) REFORMAT=--reformat;;
56 # save the name of the config file for the upcall
57 echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG" > $LUSTRE/tests/XMLCONFIG
64 active=`facet_active $facet`
65 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
66 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
72 active=`facet_active $facet`
74 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
75 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
76 $@ --cleanup $XMLCONFIG
82 [ -d $mnt ] || mkdir $mnt
84 if [ -x /sbin/mount.lustre ] ; then
85 mount -t lustre -o nettype=$NETTYPE \
86 `facet_host mds`:/mds_svc/client_facet $mnt
89 $LCONF --nosetup --node client_facet $XMLCONFIG
90 $LUSTRE/utils/llmount `facet_host mds`:/mds_svc/client_facet $mnt \
91 -o nettype=$NETTYPE || return $?
94 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
101 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG || :
106 if [ "$FAILURE_MODE" = HARD ]; then
107 $POWER_DOWN `facet_active_host $facet`
109 elif [ "$FAILURE_MODE" = SOFT ]; then
110 stop $facet --force --failover --nomod
116 if [ "$FAILURE_MODE" = HARD ]; then
117 $POWER_UP `facet_active_host $facet`
123 check_network $HOST 900
124 while ! do_node $HOST "$CHECKSTAT -t dir $LUSTRE"; do sleep 5; done
129 HOST=`facet_active_host $facet`
134 # not every config has many clients
135 if [ ! -z "$CLIENTS" ]; then
136 $PDSH $CLIENTS "df $MOUNT" > /dev/null
142 echo "Failing $facet node `facet_active_host $facet`"
143 shutdown_facet $facet
148 TO=`facet_active_host $facet`
149 echo "Failover MDS to $TO"
158 do_facet $facet $LCTL --device %${facet}_svc readonly
159 do_facet $facet $LCTL --device %${facet}_svc notransno
160 do_facet $facet $LCTL mark "REPLAY BARRIER"
161 $LCTL mark "REPLAY BARRIER"
165 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
166 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
171 facet_failover $facet
172 df $MOUNT || error "post-failover df: $?"
177 stop $facet --force --failover --nomod
180 do_facet $facet lctl --device %${facet}_svc abort_recovery
181 df $MOUNT || echo "first df failed: $?"
182 df $MOUNT || error "post-failover df: $?"
186 $LMC -m ${XMLCONFIG} $@
190 if [ "$1" = "client" ]; then echo \'*\'; else
197 if [ "$1" = "client" ]; then echo \'*\'; else
198 echo $1 | sed 's/[^0-9]*//g'
205 varname=${facet}_HOST
211 HOST=`facet_host $facet`
212 if [ -z "$HOST" ]; then
213 echo "The env variable ${facet}_HOST must be set."
216 echo `h2$NETTYPE $HOST`
221 local activevar=${facet}active
223 if [ -z "$active" ] ; then
230 facet_active_host() {
232 local active=`facet_active $facet`
233 echo `facet_host $active`
238 failover=${facet}failover
239 host=`facet_host $failover`
240 [ -z "$host" ] && return
241 curactive=`facet_active $facet`
242 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
243 eval export ${facet}active=$facet
245 eval export ${facet}active=$failover
247 # save the active host for this facet
248 activevar=${facet}active
249 echo "$activevar=${!activevar}" > ./$activevar
258 $PDSH $HOST $LCTL mark "$@" || :
260 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
265 HOST=`facet_active_host $facet`
272 echo "add facet $facet: `facet_host $facet`"
273 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
274 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
275 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
284 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc $*
290 add_facet ${facet}failover --lustre_upcall $UPCALL
291 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc $*
299 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc $*
305 add_facet ${facet}failover
306 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc $*
313 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
321 add_facet $facet --lustre_upcall $UPCALL
322 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
334 while [ $NETWORK -eq 0 ]; do
335 ping -c 1 -w 3 $1 > /dev/null
336 if [ $? -eq 0 ]; then
340 echo "waiting for $1, $((MAX - WAIT)) secs left"
343 if [ $WAIT -gt $MAX ]; then
344 echo "Network not available"
350 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
361 # the sed converts spaces to commas, but leaves the last space
362 # alone, so the line doesn't end with a comma.
363 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
367 (cd `dirname $1`; echo $PWD/`basename $1`)
370 ##################################
374 # OBD_FAIL_MDS_ALL_REQUEST_NET
376 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
377 do_facet client "$1" || RC=$?
378 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
383 # OBD_FAIL_MDS_ALL_REPLY_NET
385 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
386 do_facet client "$@" || RC=$?
387 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
392 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
394 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
395 do_facet client "$1" || RC=$?
396 do_facet client "sync"
397 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
402 #define OBD_FAIL_LDLM_CANCEL 0x304
404 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
405 do_facet client "$@" || RC=$?
406 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
411 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
413 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
414 do_facet client "$@" || RC=$?
415 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
420 $LCTL mark cancel_lru_locks
421 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
422 if [ -f $d/lru_size ]; then
423 echo clear > $d/lru_size
424 grep [0-9] $d/lock_unused_count
429 ##################################
432 echo "${TESTSUITE}: **** FAIL:" $@
436 build_test_filter() {
440 for E in $EXCEPT $ALWAYS_EXCEPT; do
441 eval EXCEPT_${E}=true
450 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
454 export base=`basetest $1`
455 if [ ! -z "$ONLY" ]; then
457 if [ ${!testname}x != x ]; then
462 if [ ${!testname}x != x ]; then
470 if [ ${!testname}x != x ]; then
471 echo "skipping excluded test $1"
474 testname=EXCEPT_$base
475 if [ ${!testname}x != x ]; then
476 echo "skipping excluded test $1 (base $base)"
484 EQUALS="======================================================================"
488 local suffixlen=$((${#EQUALS} - ${#msg}))
489 [ $suffixlen -lt 5 ] && suffixlen=5
490 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
499 # Pretty tests run faster.
500 equals_msg $testnum: $message
502 test_${testnum} || error "test_$testnum failed with $?"