Whamcloud - gitweb
b=14512
[fs/lustre-release.git] / lustre / tests / sanityN.sh
index 56e5271..752c336 100644 (file)
@@ -4,14 +4,18 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 # bug number for skipped test:  3192 9977
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"14b  28"}
+ALWAYS_EXCEPT="14b 28 $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-[ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 16"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16"
 
 # Tests that fail on uml
 [ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"
 
+# Join file feature is not supported currently.
+# It will be ported soon.
+EXCEPT="$EXCEPT 22"
+
 SRCDIR=`dirname $0`
 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
 
@@ -20,13 +24,15 @@ CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
 CREATETEST=${CREATETEST:-createtest}
 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
 SETSTRIPE=${SETSTRIPE:-lstripe}
-LCTL=${LCTL:-lctl}
 MCREATE=${MCREATE:-mcreate}
 OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
 TOEXCL=${TOEXCL:-toexcl}
 TRUNCATE=${TRUNCATE:-truncate}
 export TMP=${TMP:-/tmp}
+MOUNT_2=${MOUNT_2:-"yes"}
+CHECK_GRANT=${CHECK_GRANT:-"yes"}
+GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
 
 if [ $UID -ne 0 ]; then
        RUNAS_ID="$UID"
@@ -38,171 +44,39 @@ fi
 
 SAVE_PWD=$PWD
 
+export NAME=${NAME:-local}
+
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
+CLEANUP=${CLEANUP:-:}
+SETUP=${SETUP:-:}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 
-cleanup() {
-       echo -n "cln.."
-       grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 ${FORCE}
-       cleanupall ${FORCE} > /dev/null || { echo "FAILed to clean up"; exit 20; }
-}
-CLEANUP=${CLEANUP:-:}
-
-setup() {
-       echo -n "mnt.."
-       setupall || exit 10
-       echo "done"
-}
-SETUP=${SETUP:-:}
+SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
+FAIL_ON_ERROR=false
 
-log() {
-       echo "$*"
-       lctl mark "$*" 2> /dev/null || true
-}
+if $GSS_KRB5; then
+    $RUNAS krb5_login.sh || exit 1
+fi
 
-trace() {
-       log "STARTING: $*"
-       strace -o $TMP/$1.strace -ttt $*
-       RC=$?
-       log "FINISHED: $*: rc $RC"
-       return 1
-}
+SETUP=${SETUP:-:}
 TRACE=${TRACE:-""}
 
 LPROC=/proc/fs/lustre
 
-run_one() {
-       if ! grep -q $DIR /proc/mounts; then
-               $SETUP
-       fi
-       testnum=$1
-       message=$2
-       BEFORE=`date +%s`
-       log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
-       export TESTNAME=test_$testnum
-       export tfile=f${testnum}
-       export tdir=d${base}
-       test_$1 || error "exit with rc=$?"
-       unset TESTNAME
-       pass "($((`date +%s` - $BEFORE))s)"
-       cd $SAVE_PWD
-       $CLEANUP
-}
-
-build_test_filter() {
-       [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
-           echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
-
-        for O in $ONLY; do
-            eval ONLY_${O}=true
-        done
-        for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
-            eval EXCEPT_${E}=true
-        done
-}
-
-_basetest() {
-    echo $*
-}
-
-basetest() {
-    IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-build_test_filter() {
-       [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
-           echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
-
-        for O in $ONLY; do
-            eval ONLY_${O}=true
-        done
-        for E in $EXCEPT $ALWAYS_EXCEPT $SANITYN_EXCEPT; do
-            eval EXCEPT_${E}=true
-        done
-}
-
-_basetest() {
-    echo $*
-}
-
-basetest() {
-    IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-run_test() {
-         export base=`basetest $1`
-         if [ "$ONLY" ]; then
-                 testname=ONLY_$1
-                 if [ ${!testname}x != x ]; then
-                       run_one $1 "$2"
-                       return $?
-                 fi
-                 testname=ONLY_$base
-                 if [ ${!testname}x != x ]; then
-                         run_one $1 "$2"
-                         return $?
-                 fi
-                 echo -n "."
-                 return 0
-       fi
-        testname=EXCEPT_$1
-        if [ ${!testname}x != x ]; then
-                 echo "skipping excluded test $1"
-                 return 0
-        fi
-        testname=EXCEPT_$base
-        if [ ${!testname}x != x ]; then
-                 echo "skipping excluded test $1 (base $base)"
-                 return 0
-        fi
-        run_one $1 "$2"
-       return $?
-}
-
 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
 
-error () {
-       sysctl -w lustre.fail_loc=0 2> /dev/null || true
-       log "$0: FAIL: $TESTNAME $@"
-       if [ "$SANITYLOG" ]; then
-               echo "$0: FAIL: $TESTNAME $@" >> $SANITYLOG
-       else
-               exit 1
-       fi
-}
-
-pass() {
-       echo PASS $@
-}
+check_and_setup_lustre
 
-mounted_lustre_filesystems() {
-       awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
-}
-MOUNTED="`mounted_lustre_filesystems`"
-if [ -z "$MOUNTED" ]; then
-    formatall
-    setupall
-    mount_client $MOUNT2
-    MOUNTED="`mounted_lustre_filesystems`"
-    [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
-    I_MOUNTED=yes
-fi
-export MOUNT1=`mounted_lustre_filesystems | head -n 1`
-[ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
-export MOUNT2=`mounted_lustre_filesystems | tail -n 1`
-[ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
-[ `mounted_lustre_filesystems | wc -l` -ne 2 ] && \
-       error "NAME=$NAME mounted more than twice"
-
-export DIR1=${DIR1:-$MOUNT1}
-export DIR2=${DIR2:-$MOUNT2}
-[ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
-[ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
+LPROC=/proc/fs/lustre
+LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
+OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
 
 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
 
+check_runas_id $RUNAS_ID $RUNAS
+
 build_test_filter
 
 test_1a() {
@@ -294,6 +168,9 @@ test_6() {
 run_test 6 "remove of open file on other node =================="
 
 test_7() {
+       # run_one creates uniq $tdir (bug 13798)
+       # opendirunlink failes if it exists
+       rmdir $DIR1/$tdir || true
        opendirunlink $DIR1/$tdir $DIR2/$tdir || \
                error "opendirunlink $DIR1/$tdir $DIR2/$tdir"
 }
@@ -363,7 +240,7 @@ test_11() {
 run_test 11 "execution of file opened for write should return error ===="
 
 test_12() {
-       sh lockorder.sh
+       DIR=$DIR DIR2=$DIR2 sh lockorder.sh
 }
 run_test 12 "test lock ordering (link, stat, unlink) ==========="
 
@@ -402,7 +279,7 @@ test_14a() {
         multiop $DIR2/d14/multiop Oc && error "expected error, got success"
         kill -USR1 $MULTIPID || return 2
         wait $MULTIPID || return 3
-        rm $TMP/test14.junk
+        rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
 
@@ -412,11 +289,12 @@ test_14b() { # bug 3192, 7040
         $DIR1/d14/multiop $TMP/test14.junk O_c &
         MULTIPID=$!
         sleep 1
-        truncate $DIR2/d14/multiop 0 && error "expected error, got success"
+        truncate $DIR2/d14/multiop 0 && kill -9 $MULTIPID && \
+               error "expected truncate error, got success"
         kill -USR1 $MULTIPID || return 2
         wait $MULTIPID || return 3
        cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
-        rm $TMP/test14.junk
+       rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
 run_test 14b "truncate of executing file returns -ETXTBSY ======"
 
@@ -430,7 +308,7 @@ test_14c() { # bug 3430, 7040
        kill -USR1 $MULTIPID || return 2
        wait $MULTIPID || return 3
        cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
-       rm $TMP/test14.junk
+       rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
 
@@ -445,23 +323,27 @@ test_14d() { # bug 10921
        kill -USR1 $MULTIPID || return 2
        wait $MULTIPID || return 3
        cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
-       rm $TMP/test14.junk
+       rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
 run_test 14d "chmod of executing file is still possible ========"
 
 test_15() {    # bug 974 - ENOSPC
        echo "PATH=$PATH"
        sh oos2.sh $MOUNT1 $MOUNT2
+       grant_error=`dmesg | grep "> available"`
+       [ -z "$grant_error" ] || error "$grant_error"
 }
 run_test 15 "test out-of-space with multiple writers ==========="
 
 test_16() {
-       fsx -c 50 -p 100 -N 2500 -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
+       rm -f $MOUNT1/fsxfile
+       lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
+       fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
 }
 run_test 16 "2500 iterations of dual-mount fsx ================="
 
 test_17() { # bug 3513, 3667
-       [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
+       [ ! -d /proc/fs/lustre/ost ] && skip "remote OST, skipping OST-only test" && return
 
        cp /etc/termcap $DIR1/f17
        cancel_lru_locks osc > /dev/null
@@ -596,6 +478,7 @@ test_24() {
        lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
        
        OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
+#      OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
        lctl --device %$OSC deactivate
        lfs df -i || error "lfs df -i with deactivated OSC failed"
        lctl --device %$OSC recover
@@ -604,21 +487,21 @@ test_24() {
 run_test 24 "lfs df [-ih] [path] test ========================="
 
 test_25() {
-       [ `cat $LPROC/mdc/*-mdc-*/connect_flags | grep -c acl` -lt 2 ] && echo "skipping $TESTNAME (must have acl)" && return
+       [ `cat $LPROC/mdc/*-mdc-*/connect_flags | grep -c acl` -lt 2 ] && \
+           skip "must have acl, skipping" && return
 
-       mkdir $DIR1/$tdir || error "mkdir $DIR1/$tdir"
        touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
        chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
 
-       $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
+       $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
        setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
-       $RUNAS checkstat $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
+       $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
        setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
-       $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
+       $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
        setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
-       $RUNAS checkstat $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
+       $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
        setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
-       $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
+       $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
 
        rm -rf $DIR1/$tdir
 }
@@ -645,7 +528,7 @@ test_26b() {
 run_test 26b "sync mtime between ost and mds"
 
 test_27() {
-       cancel_lru_locks OSC
+       cancel_lru_locks osc
        lctl clear
        dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
        DD2_PID=$!
@@ -669,7 +552,7 @@ test_28() { # bug 9977
        ECHO_UUID="ECHO_osc1_UUID"
        tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
 
-       lfs setstripe $DIR1/$tfile 1048576 0 2
+       lfs setstripe $DIR1/$tfile -s 1048576 -i 0 -c 2
        tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
        dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
 
@@ -715,25 +598,20 @@ test_29() { # bug 10999
 #run_test 29 "lock put race between glimpse and enqueue ========="
 
 test_30() { #bug #11110
-    rm -rf $DIR1/$tdir
-    mkdir -p $DIR1/$tdir
     cp -f /bin/bash $DIR1/$tdir/bash
     /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
     err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
     wait
-    [ $err -ne 116 ] && error "return code ($err) != -ESTALE" && return
+    [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
     true
 }
 
 run_test 30 "recreate file race ========="
 
 log "cleanup: ======================================================"
-rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
-if [ "$I_MOUNTED" = "yes" ]; then
-    cleanup
-fi
+
+check_and_cleanup_lustre
 
 echo '=========================== finished ==============================='
-[ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
+[ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
 echo "$0: completed"
-