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 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} "
42 # Paths on remote nodes, if different
43 export RLUSTRE=${RLUSTRE:-$LUSTRE}
44 export RPWD=${RPWD:-$PWD}
48 while getopts "rvf:" opt $*; do
51 r) REFORMAT=--reformat;;
57 # save the name of the config file for the upcall
58 echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG" > $LUSTRE/tests/XMLCONFIG
59 # echo "CONFIG=`canonical_path $CONFIG`" > $LUSTRE/tests/CONFIG
66 active=`facet_active $facet`
67 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
68 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
74 active=`facet_active $facet`
76 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \
77 --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \
78 $@ --cleanup $XMLCONFIG
85 do_node $client mkdir $mnt 2> /dev/null || :
87 if [ -x /sbin/mount.lustre ] ; then
88 do_node $client mount -t lustre -o nettype=$NETTYPE `facet_active_host mds`:/mds_svc/client_facet $mnt || return 1
91 do_node $client $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null || return 2
92 $LCONF --nosetup --node client_facet $XMLCONFIG
93 do_node $client $LLMOUNT `facet_active_host mds`:/mds_svc/client_facet $mnt -o nettype=$NETTYPE|| return 4
96 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
104 do_node $client umount $force $mnt || :
105 do_node $client $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null || :
110 if [ "$FAILURE_MODE" = HARD ]; then
111 $POWER_DOWN `facet_active_host $facet`
113 elif [ "$FAILURE_MODE" = SOFT ]; then
114 stop $facet --force --failover --nomod
120 if [ "$FAILURE_MODE" = HARD ]; then
121 $POWER_UP `facet_active_host $facet`
127 check_network $HOST 900
128 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
133 HOST=`facet_active_host $facet`
138 # not every config has many clients
139 if [ ! -z "$CLIENTS" ]; then
140 $PDSH $CLIENTS "df $MOUNT" > /dev/null
146 echo "Failing $facet node `facet_active_host $facet`"
147 shutdown_facet $facet
151 echo "df pid is $DFPID"
153 TO=`facet_active_host $facet`
154 echo "Failover $facet to $TO"
163 do_facet $facet $LCTL --device %${facet}_svc readonly
164 do_facet $facet $LCTL --device %${facet}_svc notransno
165 do_facet $facet $LCTL mark "REPLAY BARRIER"
166 $LCTL mark "REPLAY BARRIER"
170 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
171 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
176 facet_failover $facet
177 df $MOUNT || error "post-failover df: $?"
182 stop $facet --force --failover --nomod
185 do_facet $facet lctl --device %${facet}_svc abort_recovery
186 df $MOUNT || echo "first df failed: $?"
187 df $MOUNT || error "post-failover df: $?"
191 $LMC -m ${XMLCONFIG} $@
195 if [ "$1" = "client" ]; then echo \'*\'; else
196 $PDSH $1 $GMNALNID -l | cut -d\ -f2
201 if [ "$1" = "client" ]; then echo \'*\'; else
208 if [ "$1" = "client" ]; then echo \'*\'; else
209 echo $1 | sed 's/[^0-9]*//g'
216 varname=${facet}_HOST
222 HOST=`facet_host $facet`
223 if [ -z "$HOST" ]; then
224 echo "The env variable ${facet}_HOST must be set."
227 echo `h2$NETTYPE $HOST`
232 local activevar=${facet}active
234 if [ -z "$active" ] ; then
241 facet_active_host() {
243 local active=`facet_active $facet`
244 if [ "$facet" == client ]; then
247 echo `facet_host $active`
253 failover=${facet}failover
254 host=`facet_host $failover`
255 [ -z "$host" ] && return
256 curactive=`facet_active $facet`
257 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
258 eval export ${facet}active=$facet
260 eval export ${facet}active=$failover
262 # save the active host for this facet
263 activevar=${facet}active
264 echo "$activevar=${!activevar}" > ./$activevar
273 $PDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
275 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
280 HOST=`facet_active_host $facet`
287 echo "add facet $facet: `facet_host $facet`"
288 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT \
289 --lustre_upcall $UPCALL --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM
290 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
299 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc $*
305 add_facet ${facet}failover --lustre_upcall $UPCALL
306 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc $*
314 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc $*
320 add_facet ${facet}failover
321 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc $*
328 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
336 add_facet $facet --lustre_upcall $UPCALL
337 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
349 while [ $NETWORK -eq 0 ]; do
350 ping -c 1 -w 3 $1 > /dev/null
351 if [ $? -eq 0 ]; then
355 echo "waiting for $1, $((MAX - WAIT)) secs left"
358 if [ $WAIT -gt $MAX ]; then
359 echo "Network not available"
365 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
376 # the sed converts spaces to commas, but leaves the last space
377 # alone, so the line doesn't end with a comma.
378 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
382 (cd `dirname $1`; echo $PWD/`basename $1`)
385 ##################################
389 # OBD_FAIL_MDS_ALL_REQUEST_NET
391 do_facet mds "echo 0x123 > /proc/sys/lustre/fail_loc"
392 do_facet client "$1" || RC=$?
393 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
398 # OBD_FAIL_MDS_ALL_REPLY_NET
400 do_facet mds "echo 0x122 > /proc/sys/lustre/fail_loc"
401 do_facet client "$@" || RC=$?
402 do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
407 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
409 do_facet ost "echo 0x214 > /proc/sys/lustre/fail_loc"
410 do_facet client "$1" || RC=$?
411 do_facet client "sync"
412 do_facet ost "echo 0 > /proc/sys/lustre/fail_loc"
417 #define OBD_FAIL_LDLM_CANCEL 0x304
419 do_facet client "echo 0x304 > /proc/sys/lustre/fail_loc"
420 do_facet client "$@" || RC=$?
421 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
426 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
428 do_facet client "echo 0x305 > /proc/sys/lustre/fail_loc"
429 do_facet client "$@" || RC=$?
430 do_facet client "echo 0 > /proc/sys/lustre/fail_loc"
438 echo "clearing fail_loc on $facet"
439 do_facet $facet "sysctl -w lustre.fail_loc=0"
443 $LCTL mark cancel_lru_locks
444 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
445 if [ -f $d/lru_size ]; then
446 echo clear > $d/lru_size
447 grep [0-9] $d/lock_unused_count
454 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
455 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
456 echo there is still data in page cache $a ?
464 ##################################
467 echo "${TESTSUITE}: **** FAIL:" $@
472 build_test_filter() {
476 for E in $EXCEPT $ALWAYS_EXCEPT; do
477 eval EXCEPT_${E}=true
486 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
490 export base=`basetest $1`
491 if [ ! -z "$ONLY" ]; then
493 if [ ${!testname}x != x ]; then
498 if [ ${!testname}x != x ]; then
506 if [ ${!testname}x != x ]; then
507 echo "skipping excluded test $1"
510 testname=EXCEPT_$base
511 if [ ${!testname}x != x ]; then
512 echo "skipping excluded test $1 (base $base)"
520 EQUALS="======================================================================"
524 local suffixlen=$((${#EQUALS} - ${#msg}))
525 [ $suffixlen -lt 5 ] && suffixlen=5
526 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
531 lctl mark "$*" 2> /dev/null || true
540 # Pretty tests run faster.
541 equals_msg $testnum: $message
544 test_${testnum} || error "test_$testnum failed with $?"
548 (cd `dirname $1`; echo $PWD/`basename $1`)