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 mds`:/mds_svc/client_facet $mnt || return 1
96 do_node $client $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null || return 2
97 do_node $client $LLMOUNT `facet_active_host mds`:/mds_svc/client_facet $mnt -o nettype=$NETTYPE|| return 4
100 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
108 do_node $client umount $force $mnt || :
109 do_node $client $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null || :
114 if [ "$FAILURE_MODE" = HARD ]; then
115 $POWER_DOWN `facet_active_host $facet`
117 elif [ "$FAILURE_MODE" = SOFT ]; then
118 stop $facet --force --failover --nomod
124 if [ "$FAILURE_MODE" = HARD ]; then
125 $POWER_UP `facet_active_host $facet`
131 check_network $HOST 900
132 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
137 HOST=`facet_active_host $facet`
142 # not every config has many clients
143 if [ ! -z "$CLIENTS" ]; then
144 $PDSH $CLIENTS "df $MOUNT" > /dev/null
150 echo "Failing $facet node `facet_active_host $facet`"
151 shutdown_facet $facet
155 echo "df pid is $DFPID"
157 TO=`facet_active_host $facet`
158 echo "Failover $facet to $TO"
167 do_facet $facet $LCTL --device %${facet}_svc readonly
168 do_facet $facet $LCTL --device %${facet}_svc notransno
169 do_facet $facet $LCTL mark "REPLAY BARRIER"
170 $LCTL mark "REPLAY BARRIER"
174 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
175 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
180 facet_failover $facet
181 df $MOUNT || error "post-failover df: $?"
186 stop $facet --force --failover --nomod
189 do_facet $facet lctl --device %${facet}_svc abort_recovery
190 df $MOUNT || echo "first df failed: $?"
192 df $MOUNT || error "post-failover df: $?"
196 $LMC -m ${XMLCONFIG} $@
200 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
201 $PDSH $1 $GMNALNID -l | cut -d\ -f2
206 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
213 if [ "$1" = "client" -o "$1" = "'*'" ]; 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 [ -f ./${facet}active ] ; then
240 source ./${facet}active
244 if [ -z "$active" ] ; then
251 facet_active_host() {
253 local active=`facet_active $facet`
254 if [ "$facet" == client ]; then
257 echo `facet_host $active`
263 failover=${facet}failover
264 host=`facet_host $failover`
265 [ -z "$host" ] && return
266 curactive=`facet_active $facet`
267 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
268 eval export ${facet}active=$facet
270 eval export ${facet}active=$failover
272 # save the active host for this facet
273 activevar=${facet}active
274 echo "$activevar=${!activevar}" > ./$activevar
283 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
285 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
290 HOST=`facet_active_host $facet`
297 echo "add facet $facet: `facet_host $facet`"
298 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
299 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
300 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
309 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc --fstype $FSTYPE $*
315 add_facet ${facet}failover --lustre_upcall $UPCALL
316 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc --fstype $FSTYPE $*
324 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc --fstype $FSTYPE $*
330 add_facet ${facet}failover
331 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc --fstype $FSTYPE $*
338 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
346 add_facet $facet --lustre_upcall $UPCALL
347 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
359 while [ $NETWORK -eq 0 ]; do
360 ping -c 1 -w 3 $1 > /dev/null
361 if [ $? -eq 0 ]; then
365 echo "waiting for $1, $((MAX - WAIT)) secs left"
368 if [ $WAIT -gt $MAX ]; then
369 echo "Network not available"
375 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
386 # the sed converts spaces to commas, but leaves the last space
387 # alone, so the line doesn't end with a comma.
388 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
392 (cd `dirname $1`; echo $PWD/`basename $1`)
395 ##################################
399 # OBD_FAIL_MDS_ALL_REQUEST_NET
401 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
402 do_facet client "$1" || RC=$?
403 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
408 # OBD_FAIL_MDS_ALL_REPLY_NET
410 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
411 do_facet client "$@" || RC=$?
412 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
417 # OBD_FAIL_MDS_REINT_NET_REP
419 do_facet mds "echo 0x119 > /proc/sys/lustre/fail_loc"
420 do_facet client "$@" || RC=$?
421 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
426 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
428 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
429 do_facet client "$1" || RC=$?
430 do_facet client "sync"
431 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
436 #define OBD_FAIL_LDLM_CANCEL 0x304
438 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
439 do_facet client "$@" || RC=$?
440 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
445 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
447 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
448 do_facet client "$@" || RC=$?
449 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
457 echo "clearing fail_loc on $facet"
458 do_facet $facet "sysctl -w lustre.fail_loc=0"
462 $LCTL mark cancel_lru_locks
463 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
464 if [ -f $d/lru_size ]; then
465 echo clear > $d/lru_size
466 grep [0-9] $d/lock_unused_count
473 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
474 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
475 echo there is still data in page cache $a ?
483 ##################################
486 echo "${TESTSUITE}: **** FAIL:" $@
491 build_test_filter() {
495 for E in $EXCEPT $ALWAYS_EXCEPT; do
496 eval EXCEPT_${E}=true
505 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
509 export base=`basetest $1`
510 if [ ! -z "$ONLY" ]; then
512 if [ ${!testname}x != x ]; then
517 if [ ${!testname}x != x ]; then
525 if [ ${!testname}x != x ]; then
526 echo "skipping excluded test $1"
529 testname=EXCEPT_$base
530 if [ ${!testname}x != x ]; then
531 echo "skipping excluded test $1 (base $base)"
539 EQUALS="======================================================================"
543 local suffixlen=$((${#EQUALS} - ${#msg}))
544 [ $suffixlen -lt 5 ] && suffixlen=5
545 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
550 lctl mark "$*" 2> /dev/null || true
559 # Pretty tests run faster.
560 equals_msg $testnum: $message
562 log "== test $testnum: $message =========== `date +%H:%M:%S`"
563 test_${testnum} || error "test_$testnum failed with $?"
567 (cd `dirname $1`; echo $PWD/`basename $1`)