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!
15 [ "$SLOW" = "no" ] && EXCEPT="$EXCEPT"
17 # Tests that fail on uml, maybe elsewhere, FIXME
18 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT"
22 2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
23 *) error "unsupported kernel (gss only works with 2.6.x)" ;;
27 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$SRCDIR/../utils/gss:$PATH:/sbin
31 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
32 CREATETEST=${CREATETEST:-createtest}
35 MEMHOG=${MEMHOG:-memhog}
36 DIRECTIO=${DIRECTIO:-directio}
37 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
38 UMOUNT=${UMOUNT:-"umount -d"}
40 if [ $UID -ne 0 ]; then
41 echo "Warning: running as non-root uid $UID"
45 RUNAS_ID=${RUNAS_ID:-500}
46 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
48 # $RUNAS_ID may get set incorrectly somewhere else
49 if [ $RUNAS_ID -eq 0 ]; then
50 echo "Error: \$RUNAS_ID set to 0, but \$UID is also 0!"
55 SANITYLOG=${SANITYLOG:-/tmp/sanity-gss.log}
57 export NAME=${NAME:-local}
64 if [ ! -z $SEC ]; then
65 if [ "$SEC" != "krb5i" -a "$SEC" != "krb5p" ]; then
66 echo "SEC=$SEC is invalid, this script only run in gss mode (krb5i/krb5p)"
71 export SEC=${SEC:-krb5p}
72 export KRB5_CCACHE_DIR=/tmp
73 export KRB5_CRED=$KRB5_CCACHE_DIR/krb5cc_$RUNAS_ID
74 export KRB5_CRED_SAVE=$KRB5_CCACHE_DIR/krb5cc.sanity.save
76 echo "Using security flavor $SEC"
78 LUSTRE=${LUSTRE:-`dirname $0`/..}
79 . $LUSTRE/tests/test-framework.sh
81 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
83 prepare_krb5_creds() {
85 $RUNAS krb5_login.sh || exit 1
86 [ -f $KRB5_CRED ] || exit 2
87 cp $KRB5_CRED $KRB5_CRED_SAVE
92 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
106 strace -o $TMP/$1.strace -ttt $*
108 log "FINISHED: $*: rc $RC"
113 check_kernel_version() {
114 VERSION_FILE=$LPROC/kernel_version
116 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
117 GOT_VER=`cat $VERSION_FILE`
118 [ $GOT_VER -ge $WANT_VER ] && return 0
119 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
127 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
139 restore_krb5_cred() {
140 cp $KRB5_CRED_SAVE $KRB5_CRED
141 chown $RUNAS_ID:$RUNAS_ID $KRB5_CRED
142 chmod 0600 $KRB5_CRED
148 $RUNAS touch $MOUNT/f1 && error "unexpected success"
152 $RUNAS touch $MOUNT/f1 || error "should not fail"
153 [ -f $MOUNT/f1 ] || error "$MOUNT/f1 not found"
155 run_test 1 "access with or without krb5 credential"
158 # current access should be ok
159 $RUNAS touch $MOUNT/f2_1 || error "can't touch $MOUNT/f2_1"
160 [ -f $MOUNT/f2_1 ] || error "$MOUNT/f2_1 not found"
162 # cleanup all cred/ctx and touch
165 $RUNAS touch $MOUNT/f2_2 && error "unexpected success"
169 $RUNAS touch $MOUNT/f2_2 || error "should not fail"
170 [ -f $MOUNT/f2_2 ] || error "$MOUNT/f2_2 not found"
172 run_test 2 "lfs flushctx"
178 echo "aaaaaaaaaaaaaaaaa" > $file
180 $CHECKSTAT -p 0666 $file || error "$UID checkstat error"
181 $RUNAS $CHECKSTAT -p 0666 $file || error "$RUNAS_ID checkstat error"
182 $RUNAS cat $file > /dev/null || error "$RUNAS_ID cat error"
185 $RUNAS multiop $file o_r &
187 # wait multiop finish its open()
190 # cleanup all cred/ctx and check
191 # metadata check should fail, but file data check should success
192 # because we always use root credential to OSTs
195 $RUNAS $CHECKSTAT -p 0666 $file && error "checkstat succeed"
197 wait $OPPID || error "read file data failed"
198 echo "read file data OK"
200 # restore and check again
202 $RUNAS $CHECKSTAT -p 0666 $file || error "$RUNAS_ID checkstat (2) error"
203 $CHECKSTAT -p 0666 $file || error "$UID checkstat (2) error"
204 $RUNAS cat $file > /dev/null || error "$RUNAS_ID cat (2) error"
206 run_test 3 "local cache under DLM lock"
209 local file1=$MOUNT/f4_1
210 local file2=$MOUNT/f4_2
212 # current access should be ok
213 $RUNAS touch $file1 || error "can't touch $file1"
214 [ -f $file1 ] || error "$file1 not found"
217 send_sigint client lgssd
219 check_gss_daemon_facet client lgssd && error "lgssd still running"
221 # flush context, and touch
223 $RUNAS touch $file2 &
225 echo "waiting touch pid $TOUCHPID"
226 wait $TOUCHPID && error "touch should fail"
229 do_facet client "$LGSSD -v"
231 check_gss_daemon_facet client lgssd
233 # touch new should succeed
234 $RUNAS touch $file2 || error "can't touch $file2"
235 [ -f $file2 ] || error "$file2 not found"
237 run_test 4 "lgssd dead, operations should wait timeout and fail"
240 local file1=$MOUNT/f5_1
241 local file2=$MOUNT/f5_2
244 # current access should be ok
245 $RUNAS touch $file1 || error "can't touch $file1"
246 [ -f $file1 ] || error "$file1 not found"
249 send_sigint mds lsvcgssd
251 check_gss_daemon_facet mds lsvcgssd && error "lsvcgssd still running"
253 # flush context, and touch
255 $RUNAS touch $file2 &
259 echo "waiting $wait_time seconds for touch pid $TOUCHPID"
261 num=`ps --no-headers -p $TOUCHPID | wc -l`
262 [ $num -eq 1 ] || error "touch already ended ($num)"
263 echo "process $TOUCHPID still hanging there... OK"
265 # restart lsvcgssd, expect touch suceed
266 echo "restart lsvcgssd and recovering"
267 do_facet mds "$LSVCGSSD -v"
269 check_gss_daemon_facet mds lsvcgssd
270 wait $TOUCHPID || error "touch fail"
271 [ -f $file2 ] || error "$file2 not found"
273 run_test 5 "lsvcgssd dead, operations lead to recovery"
276 NPROC=`cat /proc/cpuinfo 2>/dev/null | grep ^processor | wc -l`
277 [ $NPROC -ne 0 ] || NPROC=2
279 echo "starting dbench $NPROC"
280 sh rundbench $NPROC &
285 num=`ps --no-headers -p $RUNPID | wc -l`
286 [ $num -ne 0 ] || break
290 wait $RUNPID || error "dbench detect error"
292 run_test 6 "recoverable from losing context"
295 local tdir=$MOUNT/dir7
299 # for open(), client only reserve space for default stripe count lovea,
300 # and server may return larger lovea in reply (because of larger stripe
301 # count), client need call enlarge_reqbuf() and save the replied lovea
302 # in request for future possible replay.
304 # Note: current script does NOT guarantee enlarge_reqbuf() will be in
305 # the path, however it does work in local test which has 2 OSTs and
306 # default stripe count is 1.
308 num_osts=`$LFS getstripe $MOUNT | egrep "^[0-9]*:.*ACTIVE" | wc -l`
309 echo "found $num_osts active OSTs"
310 [ $num_osts -lt 2 ] && echo "skipping $TESTNAME (must have >= 2 OSTs)" && return
313 $LFS setstripe $tdir 0 -1 -1 || error
316 for ((i=0;i<20;i++)); do
317 dd if=/dev/zero of=$tdir/f$i bs=4k count=16 2>/dev/null
320 for ((i=0;i<20;i++)); do
321 dd if=$tdir/f$i of=/dev/null bs=4k count=16 2>/dev/null
325 run_test 7 "exercise enlarge_reqbuf()"
327 check_multiple_gss_daemons() {
330 for ((i=0;i<10;i++)); do
331 do_facet $facet "$LSVCGSSD -v &"
333 for ((i=0;i<10;i++)); do
334 do_facet $facet "$LGSSD -v &"
337 # wait daemons entering "stable" status
340 numc=`do_facet $facet ps -o cmd -C lgssd | grep lgssd | wc -l`
341 nums=`do_facet $facet ps -o cmd -C lgssd | grep lgssd | wc -l`
342 echo "$numc lgssd and $nums lsvcgssd are running"
344 if [ $numc -ne 1 -o $nums -ne 1 ]; then
345 error "lgssd/lsvcgssd not unique"
352 # cleanup everything at first
355 echo "bring up gss daemons..."
358 echo "check with someone already running..."
359 check_multiple_gss_daemons $facet
361 echo "check with someone run & finished..."
362 do_facet $facet killall -q -2 lgssd lsvcgssd || true
363 sleep 5 # wait fully exit
364 check_multiple_gss_daemons $facet
366 echo "check refresh..."
367 do_facet $facet killall -q -2 lgssd lsvcgssd || true
368 sleep 5 # wait fully exit
369 do_facet $facet ipcrm -S 0x3b92d473
370 do_facet $facet ipcrm -S 0x3a92d473
371 check_multiple_gss_daemons $facet
375 run_test 100 "start more multiple gss daemons"
381 log "cleanup: ======================================================"
382 if [ "`mount | grep ^$NAME`" ]; then
383 rm -rf $DIR/[Rdfs][1-9]*
386 cleanupall -f || error "cleanup failed"
389 echo '=========================== finished ==============================='
390 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true