2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test:
12 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 if [ "x$GSS_PIPEFS" != "xy" ]; then
15 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 4"
18 [ "$SLOW" = "no" ] && EXCEPT="$EXCEPT"
20 # Tests that fail on uml, maybe elsewhere, FIXME
21 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
22 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT"
25 2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
26 *) error "unsupported kernel (gss only works with 2.6.x)" ;;
30 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$SRCDIR/../utils/gss:$PATH:/sbin
34 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
35 CREATETEST=${CREATETEST:-createtest}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 if [ $UID -ne 0 ]; then
44 echo "Warning: running as non-root uid $UID"
48 RUNAS_ID=${RUNAS_ID:-500}
49 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
51 # $RUNAS_ID may get set incorrectly somewhere else
52 if [ $RUNAS_ID -eq 0 ]; then
53 echo "Error: \$RUNAS_ID set to 0, but \$UID is also 0!"
58 SANITYLOG=${SANITYLOG:-/tmp/sanity-gss.log}
60 export NAME=${NAME:-local}
64 export SEC=${SEC:-krb5p}
65 export KRB5_CCACHE_DIR=/tmp
66 export KRB5_CRED=$KRB5_CCACHE_DIR/krb5cc_$RUNAS_ID
67 export KRB5_CRED_SAVE=$KRB5_CCACHE_DIR/krb5cc.sanity.save
74 echo "Using ptlrpc security flavor $SEC"
77 echo "SEC=$SEC is invalid, it has to be gss/krb5 flavor"
82 LUSTRE=${LUSTRE:-`dirname $0`/..}
83 . $LUSTRE/tests/test-framework.sh
85 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
87 prepare_krb5_creds() {
89 $RUNAS krb5_login.sh || exit 1
90 [ -f $KRB5_CRED ] || exit 2
91 cp $KRB5_CRED $KRB5_CRED_SAVE
96 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
110 strace -o $TMP/$1.strace -ttt $*
112 log "FINISHED: $*: rc $RC"
117 check_kernel_version() {
118 VERSION_FILE=$LPROC/kernel_version
120 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
121 GOT_VER=`cat $VERSION_FILE`
122 [ $GOT_VER -ge $WANT_VER ] && return 0
123 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
131 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
143 restore_krb5_cred() {
144 cp $KRB5_CRED_SAVE $KRB5_CRED
145 chown $RUNAS_ID:$RUNAS_ID $KRB5_CRED
146 chmod 0600 $KRB5_CRED
152 $RUNAS touch $MOUNT/f1 && error "unexpected success"
156 $RUNAS touch $MOUNT/f1 || error "should not fail"
157 [ -f $MOUNT/f1 ] || error "$MOUNT/f1 not found"
159 run_test 1 "access with or without krb5 credential"
162 # current access should be ok
163 $RUNAS touch $MOUNT/f2_1 || error "can't touch $MOUNT/f2_1"
164 [ -f $MOUNT/f2_1 ] || error "$MOUNT/f2_1 not found"
166 # cleanup all cred/ctx and touch
168 $RUNAS $LFS flushctx || error "can't flush ctx"
169 $RUNAS touch $MOUNT/f2_2 && error "unexpected success"
173 $RUNAS touch $MOUNT/f2_2 || error "should not fail"
174 [ -f $MOUNT/f2_2 ] || error "$MOUNT/f2_2 not found"
176 run_test 2 "lfs flushctx"
182 echo "aaaaaaaaaaaaaaaaa" > $file
184 $CHECKSTAT -p 0666 $file || error "$UID checkstat error"
185 $RUNAS $CHECKSTAT -p 0666 $file || error "$RUNAS_ID checkstat error"
186 $RUNAS cat $file > /dev/null || error "$RUNAS_ID cat error"
189 $RUNAS multiop $file o_r &
191 # wait multiop finish its open()
194 # cleanup all cred/ctx and check
195 # metadata check should fail, but file data check should success
196 # because we always use root credential to OSTs
199 echo "destroied credentials/contexs for $RUNAS_ID"
200 $RUNAS $CHECKSTAT -p 0666 $file && error "checkstat succeed"
202 wait $OPPID || error "read file data failed"
203 echo "read file data OK"
205 # restore and check again
207 echo "restored credentials for $RUNAS_ID"
208 $RUNAS $CHECKSTAT -p 0666 $file || error "$RUNAS_ID checkstat (2) error"
209 echo "$RUNAS_ID checkstat OK"
210 $CHECKSTAT -p 0666 $file || error "$UID checkstat (2) error"
211 echo "$UID checkstat OK"
212 $RUNAS cat $file > /dev/null || error "$RUNAS_ID cat (2) error"
213 echo "$RUNAS_ID read file data OK"
215 run_test 3 "local cache under DLM lock"
218 local file1=$MOUNT/f4_1
219 local file2=$MOUNT/f4_2
221 # current access should be ok
222 $RUNAS touch $file1 || error "can't touch $file1"
223 [ -f $file1 ] || error "$file1 not found"
226 send_sigint client lgssd
228 check_gss_daemon_facet client lgssd && error "lgssd still running"
230 # flush context, and touch
232 $RUNAS touch $file2 &
234 echo "waiting touch pid $TOUCHPID"
235 wait $TOUCHPID && error "touch should fail"
238 do_facet client "$LGSSD -v"
240 check_gss_daemon_facet client lgssd
242 # touch new should succeed
243 $RUNAS touch $file2 || error "can't touch $file2"
244 [ -f $file2 ] || error "$file2 not found"
246 run_test 4 "lgssd dead, operations should wait timeout and fail"
249 local file1=$MOUNT/f5_1
250 local file2=$MOUNT/f5_2
251 local wait_time=`expr $TIMEOUT + $TIMEOUT`
253 # current access should be ok
254 $RUNAS touch $file1 || error "can't touch $file1"
255 [ -f $file1 ] || error "$file1 not found"
258 send_sigint mds lsvcgssd
260 check_gss_daemon_facet mds lsvcgssd && error "lsvcgssd still running"
262 # flush context, and touch
264 $RUNAS touch $file2 &
268 echo "waiting $wait_time seconds for touch pid $TOUCHPID"
270 num=`ps --no-headers -p $TOUCHPID | wc -l`
271 [ $num -eq 1 ] || error "touch already ended ($num)"
272 echo "process $TOUCHPID still hanging there... OK"
274 # restart lsvcgssd, expect touch suceed
275 echo "restart lsvcgssd and recovering"
276 do_facet mds "$LSVCGSSD -v"
278 check_gss_daemon_facet mds lsvcgssd
279 wait $TOUCHPID || error "touch fail"
280 [ -f $file2 ] || error "$file2 not found"
282 run_test 5 "lsvcgssd dead, operations lead to recovery"
285 NPROC=`cat /proc/cpuinfo 2>/dev/null | grep ^processor | wc -l`
286 [ $NPROC -ne 0 ] || NPROC=2
288 echo "starting dbench $NPROC"
289 sh rundbench $NPROC &
294 num=`ps --no-headers -p $RUNPID | wc -l`
295 [ $num -ne 0 ] || break
299 wait $RUNPID || error "dbench detect error"
301 run_test 6 "recoverable from losing context"
304 local tdir=$MOUNT/dir7
308 # for open(), client only reserve space for default stripe count lovea,
309 # and server may return larger lovea in reply (because of larger stripe
310 # count), client need call enlarge_reqbuf() and save the replied lovea
311 # in request for future possible replay.
313 # Note: current script does NOT guarantee enlarge_reqbuf() will be in
314 # the path, however it does work in local test which has 2 OSTs and
315 # default stripe count is 1.
317 num_osts=`$LFS getstripe $MOUNT | egrep "^[0-9]*:.*ACTIVE" | wc -l`
318 echo "found $num_osts active OSTs"
319 [ $num_osts -lt 2 ] && echo "skipping $TESTNAME (must have >= 2 OSTs)" && return
322 $LFS setstripe $tdir 0 -1 -1 || error
325 for ((i=0;i<20;i++)); do
326 dd if=/dev/zero of=$tdir/f$i bs=4k count=16 2>/dev/null
329 for ((i=0;i<20;i++)); do
330 dd if=$tdir/f$i of=/dev/null bs=4k count=16 2>/dev/null
334 run_test 7 "exercise enlarge_reqbuf()"
336 check_multiple_gss_daemons() {
339 local gssd_name=`basename $gssd`
341 for ((i=0;i<10;i++)); do
342 do_facet $facet "$gssd -v &"
345 # wait daemons entering "stable" status
348 num=`do_facet $facet ps -o cmd -C $gssd_name | grep $gssd_name | wc -l`
349 echo "$num instance(s) of $gssd_name are running"
351 if [ $num -ne 1 ]; then
352 error "$gssd_name not unique"
359 # cleanup everything at first
362 echo "bring up gss daemons..."
365 echo "check with someone already running..."
366 check_multiple_gss_daemons $facet $LSVCGSSD
367 if [ "x$GSS_PIPEFS" == "xy" ]; then
368 check_multiple_gss_daemons $facet $LGSSD
371 echo "check with someone run & finished..."
372 do_facet $facet killall -q -2 lgssd lsvcgssd || true
373 sleep 5 # wait fully exit
374 check_multiple_gss_daemons $facet $LSVCGSSD
375 if [ "x$GSS_PIPEFS" == "xy" ]; then
376 check_multiple_gss_daemons $facet $LGSSD
379 echo "check refresh..."
380 do_facet $facet killall -q -2 lgssd lsvcgssd || true
381 sleep 5 # wait fully exit
382 do_facet $facet ipcrm -S 0x3b92d473
383 check_multiple_gss_daemons $facet $LSVCGSSD
384 if [ "x$GSS_PIPEFS" == "xy" ]; then
385 do_facet $facet ipcrm -S 0x3a92d473
386 check_multiple_gss_daemons $facet $LGSSD
391 run_test 100 "start multiple gss daemons"
397 log "cleanup: ======================================================"
398 if [ "`mount | grep ^$NAME`" ]; then
399 rm -rf $DIR/[Rdfs][1-9]*
402 cleanupall -f || error "cleanup failed"
405 echo '=========================== finished ==============================='
406 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true