5 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
9 if [ -z "${!name}" ]; then
10 echo "$0: $name must be set"
14 [ $failed ] && exit 1 || true
18 echo "usage: $0 [-r] [-f cfgfile]"
25 export LUSTRE=`absolute_path $LUSTRE`
26 export TESTSUITE=`basename $0 .sh`
27 export XMLCONFIG="${TESTSUITE}.xml"
28 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
30 [ -d /r ] && export ROOT=/r
32 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
33 export LCONF=${LCONF:-"lconf"}
34 export LMC=${LMC:-"lmc"}
35 export LCTL=${LCTL:-"lctl"}
36 export CHECKSTAT="${CHECKSTAT:-checkstat} -v"
38 # Paths on remote nodes, if different
39 export RLUSTRE=${RLUSTRE:-$LUSTRE}
40 export RPWD=${RPWD:-$PWD}
44 while getopts "rf:" opt $*; do
47 r) REFORMAT=--reformat;;
52 # save the name of the config file for the upcall
53 echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG" > $LUSTRE/tests/XMLCONFIG
60 active=`facet_active $facet`
61 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet --node ${active}_facet --ptldebug $PTLDEBUG $@ $XMLCONFIG
66 active=`facet_active $facet`
68 do_facet $facet $LCONF --select ${facet}_svc=${active}_facet --node ${active}_facet --ptldebug $PTLDEBUG $@ --cleanup $XMLCONFIG
74 [ -d $mnt ] || mkdir $mnt
76 if [ -x /sbin/mount.lustre ] ; then
77 mount -t lustre -o nettype=$NETTYPE \
78 `facet_host mds`:/mds_svc/client_facet $mnt
81 $LCONF --nosetup --node client_facet $XMLCONFIG
82 $LUSTRE/utils/llmount `facet_host mds`:/mds_svc/client_facet $mnt \
86 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
93 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG || :
98 if [ "$FAILURE_MODE" = HARD ]; then
99 $POWER_DOWN `facet_active_host $facet`
100 elif [ "$FAILURE_MODE" = SOFT ]; then
101 stop $facet --force --failover --nomod
107 if [ "$FAILURE_MODE" = HARD ]; then
108 $POWER_UP `facet_active_host $facet`
114 check_network $HOST 900
115 while ! $PDSH $HOST "ls -ld $LUSTRE"; do sleep 5; done
120 HOST=`facet_active_host $facet`
125 # not every config has many clients
126 if [ ! -z "$CLIENTS" ]; then
127 $PDSH $CLIENTS "df $MOUNT" | dshbak -c
133 echo "Failing $facet node `facet_active_host $facet`"
134 shutdown_facet $facet
140 TO=`facet_active_host $facet`
141 echo "Failover MDS to $TO"
150 do_facet $facet $LCTL --device %${facet}_svc readonly
151 do_facet $facet $LCTL --device %${facet}_svc notransno
152 do_facet $facet $LCTL mark "REPLAY BARRIER"
153 $LCTL mark "REPLAY BARRIER"
157 UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
158 do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
163 facet_failover $facet
164 df $MOUNT || error "post-failover df: $?"
169 stop $facet --force --failover --nomod
172 do_facet $facet lctl --device %${facet}_svc abort_recovery
173 df $MOUNT || echo "first df failed: $?"
174 df $MOUNT || error "post-failover df: $?"
178 $LMC -m ${XMLCONFIG} $@
182 if [ "$1" = "client" ]; then echo \'*\'; else
189 if [ "$1" = "client" ]; then echo \'*\'; else
190 echo $1 | sed 's/[^0-9]*//g'
197 varname=${facet}_HOST
203 HOST=`facet_host $facet`
204 if [ -z "$HOST" ]; then
205 echo "The env variable ${facet}_HOST must be set."
208 echo `h2$NETTYPE $HOST`
213 local activevar=${facet}active
215 if [ -z "$active" ] ; then
222 facet_active_host() {
224 local active=`facet_active $facet`
225 echo `facet_host $active`
230 failover=${facet}failover
231 host=`facet_host $failover`
232 [ -z "$host" ] && return
233 curactive=`facet_active $facet`
234 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
235 eval export ${facet}active=$facet
237 eval export ${facet}active=$failover
239 # save the active host for this facet
240 activevar=${facet}active
241 echo "$activevar=${!activevar}" > ./$activevar
247 $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
252 HOST=`facet_active_host $facet`
259 echo "add facet $facet: `facet_host $facet`"
260 do_lmc --add node --node ${facet}_facet $@ --timeout $TIMEOUT
261 do_lmc --add net --node ${facet}_facet --nid `facet_nid $facet` \
269 add_facet $facet --lustre_upcall $UPCALL
270 do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc $*
276 add_facet ${facet}failover --lustre_upcall $UPCALL
277 do_lmc --add mds --node ${facet}failover_facet --mds ${facet}_svc $*
285 do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc $*
291 add_facet ${facet}failover
292 do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc $*
299 do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
307 add_facet $facet --lustre_upcall $UPCALL
308 do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
320 while [ $NETWORK -eq 0 ]; do
321 ping -c 1 -w 3 $1 > /dev/null
322 if [ $? -eq 0 ]; then
326 echo "waiting for $1, $((MAX - WAIT)) secs left"
329 if [ $WAIT -gt $MAX ]; then
330 echo "Network not available"
336 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
347 # the sed converts spaces to commas, but leaves the last space
348 # alone, so the line doesn't end with a comma.
349 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
353 (cd `dirname $1`; echo $PWD/`basename $1`)
356 ##################################
359 echo "${TESTSUITE}: **** FAIL:" $@
363 build_test_filter() {
367 for E in $EXCEPT $ALWAYS_EXCEPT; do
368 eval EXCEPT_${E}=true
377 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
381 export base=`basetest $1`
382 if [ ! -z "$ONLY" ]; then
384 if [ ${!testname}x != x ]; then
389 if [ ${!testname}x != x ]; then
397 if [ ${!testname}x != x ]; then
398 echo "skipping excluded test $1"
401 testname=EXCEPT_$base
402 if [ ${!testname}x != x ]; then
403 echo "skipping excluded test $1 (base $base)"
411 EQUALS="======================================================================"
415 local suffixlen=$((${#EQUALS} - ${#msg}))
416 [ $suffixlen -lt 5 ] && suffixlen=5
417 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
426 # Pretty tests run faster.
427 equals_msg $testnum: $message
429 test_${testnum} || error "test_$testnum failed with $?"