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 --node ${active}_facet --ptldebug $PTLDEBUG $@ $XMLCONFIG
70 active=`facet_active $facet`
72 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet --node ${active}_facet --ptldebug $PTLDEBUG $@ --cleanup $XMLCONFIG
78 [ -d $mnt ] || mkdir $mnt
80 if [ -x /sbin/mount.lustre ] ; then
81 mount -t lustre -o nettype=$NETTYPE \
82 `facet_host mds`:/mds_svc/client_facet $mnt
85 $LCONF --nosetup --node client_facet $XMLCONFIG
86 $LUSTRE/utils/llmount `facet_host mds`:/mds_svc/client_facet $mnt \
90 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
97 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG || :
102 if [ "$FAILURE_MODE" = HARD ]; then
103 $POWER_DOWN `facet_active_host $facet`
105 elif [ "$FAILURE_MODE" = SOFT ]; then
106 stop $facet --force --failover --nomod
112 if [ "$FAILURE_MODE" = HARD ]; then
113 $POWER_UP `facet_active_host $facet`
119 check_network $HOST 900
120 while ! do_node $HOST "$CHECKSTAT -t dir $LUSTRE"; do sleep 5; done
125 HOST=`facet_active_host $facet`
130 # not every config has many clients
131 if [ ! -z "$CLIENTS" ]; then
132 $PDSH $CLIENTS "df $MOUNT" > /dev/null
138 echo "Failing $facet node `facet_active_host $facet`"
139 shutdown_facet $facet
144 TO=`facet_active_host $facet`
145 echo "Failover MDS to $TO"
154 do_facet $facet $LCTL --device %${facet}_svc readonly
155 do_facet $facet $LCTL --device %${facet}_svc notransno
156 do_facet $facet $LCTL mark "REPLAY BARRIER"
157 $LCTL mark "REPLAY BARRIER"
161 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
162 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
167 facet_failover $facet
168 df $MOUNT || error "post-failover df: $?"
173 stop $facet --force --failover --nomod
176 do_facet $facet lctl --device %${facet}_svc abort_recovery
177 df $MOUNT || echo "first df failed: $?"
178 df $MOUNT || error "post-failover df: $?"
182 $LMC -m ${XMLCONFIG} $@
186 if [ "$1" = "client" ]; then echo \'*\'; else
193 if [ "$1" = "client" ]; then echo \'*\'; else
194 echo $1 | sed 's/[^0-9]*//g'
201 varname=${facet}_HOST
207 HOST=`facet_host $facet`
208 if [ -z "$HOST" ]; then
209 echo "The env variable ${facet}_HOST must be set."
212 echo `h2$NETTYPE $HOST`
217 local activevar=${facet}active
219 if [ -z "$active" ] ; then
226 facet_active_host() {
228 local active=`facet_active $facet`
229 echo `facet_host $active`
234 failover=${facet}failover
235 host=`facet_host $failover`
236 [ -z "$host" ] && return
237 curactive=`facet_active $facet`
238 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
239 eval export ${facet}active=$facet
241 eval export ${facet}active=$failover
243 # save the active host for this facet
244 activevar=${facet}active
245 echo "$activevar=${!activevar}" > ./$activevar
255 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
260 HOST=`facet_active_host $facet`
267 echo "add facet $facet: `facet_host $facet`"
268 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT
269 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
277 add_facet $facet --lustre_upcall $UPCALL
278 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc $*
284 add_facet ${facet}failover --lustre_upcall $UPCALL
285 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc $*
293 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc $*
299 add_facet ${facet}failover
300 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc $*
307 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
315 add_facet $facet --lustre_upcall $UPCALL
316 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
328 while [ $NETWORK -eq 0 ]; do
329 ping -c 1 -w 3 $1 > /dev/null
330 if [ $? -eq 0 ]; then
334 echo "waiting for $1, $((MAX - WAIT)) secs left"
337 if [ $WAIT -gt $MAX ]; then
338 echo "Network not available"
344 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
355 # the sed converts spaces to commas, but leaves the last space
356 # alone, so the line doesn't end with a comma.
357 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
361 (cd `dirname $1`; echo $PWD/`basename $1`)
364 ##################################
368 # OBD_FAIL_MDS_ALL_REQUEST_NET
370 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
371 do_facet client "$1" || RC=$?
372 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
377 # OBD_FAIL_MDS_ALL_REPLY_NET
379 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
380 do_facet client "$@" || RC=$?
381 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
386 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
388 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
389 do_facet client "$1" || RC=$?
390 do_facet client "sync"
391 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
396 #define OBD_FAIL_LDLM_CANCEL 0x304
398 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
399 do_facet client "$@" || RC=$?
400 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
405 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
407 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
408 do_facet client "$@" || RC=$?
409 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
414 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
415 if [ -f $d/lru_size ]; then
416 echo clear > $d/lru_size
417 grep [0-9] $d/lock_unused_count
422 ##################################
425 echo "${TESTSUITE}: **** FAIL:" $@
429 build_test_filter() {
433 for E in $EXCEPT $ALWAYS_EXCEPT; do
434 eval EXCEPT_${E}=true
443 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
447 export base=`basetest $1`
448 if [ ! -z "$ONLY" ]; then
450 if [ ${!testname}x != x ]; then
455 if [ ${!testname}x != x ]; then
463 if [ ${!testname}x != x ]; then
464 echo "skipping excluded test $1"
467 testname=EXCEPT_$base
468 if [ ${!testname}x != x ]; then
469 echo "skipping excluded test $1 (base $base)"
477 EQUALS="======================================================================"
481 local suffixlen=$((${#EQUALS} - ${#msg}))
482 [ $suffixlen -lt 5 ] && suffixlen=5
483 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
492 # Pretty tests run faster.
493 equals_msg $testnum: $message
495 test_${testnum} || error "test_$testnum failed with $?"