Whamcloud - gitweb
Branch b1_4_mountconf
[fs/lustre-release.git] / lustre / tests / sanityN.sh
index 7a333af..0de58a6 100644 (file)
@@ -3,15 +3,17 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 1557
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"8"}
+# bug number for skipped test:  3192 4035
+ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"14b  14c"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-[ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
+[ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
+       echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
 
 SRCDIR=`dirname $0`
 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
 
+SIZE=${SIZE:-40960}
 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
 CREATETEST=${CREATETEST:-createtest}
 LFIND=${LFIND:-lfind}
@@ -22,6 +24,7 @@ OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
 TOEXCL=${TOEXCL:-toexcl}
 TRUNCATE=${TRUNCATE:-truncate}
+export TMP=${TMP:-/tmp}
 
 if [ $UID -ne 0 ]; then
        RUNAS_ID="$UID"
@@ -31,37 +34,47 @@ else
        RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
 fi
 
-export NAME=${NAME:-mount2}
-
 SAVE_PWD=$PWD
 
 clean() {
        echo -n "cln.."
-       sh llmountcleanup.sh > /dev/null || exit 20
+       sh llmountcleanup.sh ${FORCE} > /dev/null || exit 20
 }
-CLEAN=${CLEAN:-clean}
+CLEAN=${CLEAN:-}
 
 start() {
        echo -n "mnt.."
-       sh llrmount.sh > /dev/null || exit 10
+       sh llmount.sh > /dev/null || exit 10
        echo "done"
 }
-START=${START:-start}
+START=${START:-}
 
 log() {
        echo "$*"
        lctl mark "$*" 2> /dev/null || true
 }
 
+trace() {
+       log "STARTING: $*"
+       strace -o $TMP/$1.strace -ttt $*
+       RC=$?
+       log "FINISHED: $*: rc $RC"
+       return 1
+}
+TRACE=${TRACE:-""}
+
 run_one() {
        if ! mount | grep -q $DIR1; then
                $START
        fi
-       log "== test $1: $2"
+       BEFORE=`date +%s`
+       log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
        export TESTNAME=test_$1
+       export tfile=f${testnum}
+       export tdir=d${base}
        test_$1 || error "test_$1: exit with rc=$?"
        unset TESTNAME
-       pass
+       pass "($((`date +%s` - $BEFORE))s)"
        cd $SAVE_PWD
        $CLEAN
 }
@@ -76,7 +89,7 @@ run_test() {
                        echo -n "."
                fi
        done
-       for X in $EXCEPT $ALWAYS_EXCEPT; do
+       for X in $EXCEPT $ALWAYS_EXCEPT $SANITYN_EXCEPT; do
                if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
                        echo "skipping excluded test $1"
                        return 0
@@ -100,11 +113,11 @@ error () {
 }
 
 pass() {
-       echo PASS
+       echo PASS $@
 }
 
-export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -1`
-export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -1`
+export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -1`
+export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -1`
 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
@@ -178,7 +191,7 @@ test_3() {
 run_test 3 "symlink on one mtpt, readlink on another ==========="
 
 test_4() {
-       ./multifstat $DIR1/f4 $DIR2/f4
+       multifstat $DIR1/f4 $DIR2/f4
 }
 run_test 4 "fstat validation on multiple mount points =========="
 
@@ -191,17 +204,17 @@ test_5() {
 run_test 5 "create a file on one mount, truncate it on the other"
 
 test_6() {
-       ./openunlink $DIR1/f6 $DIR2/f6 || error
+       openunlink $DIR1/f6 $DIR2/f6 || error
 }
 run_test 6 "remove of open file on other node =================="
 
 test_7() {
-       ./opendirunlink $DIR1/d7 $DIR2/d7 || error
+       opendirunlink $DIR1/d7 $DIR2/d7 || error
 }
 run_test 7 "remove of open directory on other node ============="
 
 test_8() {
-       ./opendevunlink $DIR1/dev8 $DIR2/dev8 || error
+       opendevunlink $DIR1/dev8 $DIR2/dev8 || error
 }
 run_test 8 "remove of open special file on other node =========="
 
@@ -234,7 +247,6 @@ test_10a() {
 run_test 10a "write of file with sub-page size on multiple mounts "
 
 test_10b() {
-       set -vx
        yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
 
        truncate $DIR1/f10b 4096 || error "truncate 4096"
@@ -245,6 +257,7 @@ test_10b() {
        yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
        truncate $TMP/f10b 4096 || error "truncate 4096"
        cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
+       rm $TMP/f10b $TMP/f10b-lustre
 }
 run_test 10b "write of file with sub-page size on multiple mounts "
 
@@ -291,38 +304,166 @@ test_14() {
        $DIR2/d14/ls && error || true
        exec 100<&-
 }
-run_test 14 "execution of file opened for write should return -ETXTBSY=="
+run_test 14 "execution of file open for write returns -ETXTBSY ="
 
 test_14a() {
         mkdir -p $DIR1/d14
-       cp -p `which multiop` $DIR1/d14/multiop
+       cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
         $DIR1/d14/multiop $TMP/test14.junk O_c &
         MULTIPID=$!
         sleep 1
         multiop $DIR2/d14/multiop Oc && error "expected error, got success"
         kill -USR1 $MULTIPID || return 2
         wait $MULTIPID || return 3
+        rm $TMP/test14.junk
 }
-run_test 14a "open(RDWR) of file being executed should return -ETXTBSY"
+run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
 
-test_14b() {
+test_14b() { # bug 3192
         mkdir -p $DIR1/d14
-       cp -p `which multiop` $DIR1/d14/multiop
+       cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
         $DIR1/d14/multiop $TMP/test14.junk O_c &
         MULTIPID=$!
         sleep 1
         truncate $DIR2/d14/multiop 0 && error "expected error, got success"
         kill -USR1 $MULTIPID || return 2
         wait $MULTIPID || return 3
+        rm $TMP/test14.junk
 }
-run_test 14b "truncate of file being executed should return -ETXTBSY"
+run_test 14b "truncate of executing file returns -ETXTBSY ======"
+
+test_14c() { # bug 3430
+       mkdir -p $DIR1/d14
+       cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
+       $DIR1/d14/multiop $TMP/test14.junk O_c &
+       MULTIPID=$!
+       sleep 1
+       cp /etc/hosts $DIR2/d14/multiop && error "expected 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
+}
+run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
 
 test_15() {    # bug 974 - ENOSPC
-       env
+       echo $PATH
        sh oos2.sh $MOUNT1 $MOUNT2
 }
 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
+}
+run_test 16 "2500 iterations of dual-mount fsx ================="
+
+cancel_lru_locks() {
+       for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
+               echo clear > $d/lru_size
+       done
+       grep "[0-9]" /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
+}
+
+test_17() { # bug 3513, 3667
+       [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
+
+       cp /etc/termcap $DIR1/f17
+       cancel_lru_locks OSC > /dev/null
+       #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE    0x30a
+       echo 0x8000030a > /proc/sys/lustre/fail_loc
+       ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
+       ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
+       wait
+       diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
+}
+run_test 17 "resource creation/LVB creation race ==============="
+
+test_18() {
+       ./mmap_sanity -d $MOUNT1 -m $MOUNT2
+       sync; sleep 1; sync
+}
+run_test 18 "mmap sanity check ================================="
+
+test_19() { # bug3811
+       [ -d /proc/fs/lustre/obdfilter ] || return 0
+
+       MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
+       for O in /proc/fs/lustre/obdfilter/OST*; do
+               echo 4096 > $O/readcache_max_filesize
+       done
+       dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
+       SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
+       cp $TMP/f19b $DIR1/f19b
+       for i in `seq 1 20`; do
+               [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
+               cancel_lru_locks OSC > /dev/null
+               cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
+               cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
+               wait
+               [ "`cat $TMP/sum1`" = "$SUM" ] || \
+                       error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
+               [ "`cat $TMP/sum2`" = "$SUM" ] || \
+                       error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
+       done
+       for O in /proc/fs/lustre/obdfilter/OST*; do
+               echo $MAX > $O/readcache_max_filesize
+       done
+       rm $DIR1/f19b
+}
+#run_test 19 "test concurrent uncached read races ==============="
+
+test_20() {
+       mkdir $DIR1/d20
+       cancel_lru_locks OSC
+       CNT=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l`))
+       multiop $DIR1/f20 Ow8190c
+       multiop $DIR2/f20 Oz8194w8190c
+       multiop $DIR1/f20 Oz0r8190c
+       cancel_lru_locks OSC
+       CNTD=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l` - $CNT))
+       [ $CNTD -gt 0 ] && \
+           error $CNTD" page left in cache after lock cancel" || true
+}
+run_test 20 "test extra readahead page left in cache ===="
+
+cleanup_21() {
+       trap 0
+       umount $DIR1/d21
+}
+
+test_21() { # Bug 5907
+       mkdir $DIR1/d21
+       mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
+       trap cleanup_21 EXIT
+       rmdir -v $DIR1/d21 && error "Removed mounted directory"
+       rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
+       test -d $DIR1/d21 || error "Mounted directory disappeared"
+       cleanup_21
+       test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
+       true
+}
+run_test 21 " Try to remove mountpoint on another dir ===="
+
+JOIN=${JOIN:-"lfs join"}
+
+test_22() { # Bug 9926
+       mkdir $DIR1/d21
+       dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
+       cp -p $DIR1/d21/128k $DIR1/d21/f_head
+       for ((i=0;i<10;i++)); do
+               cp -p $DIR1/d21/128k $DIR1/d21/f_tail
+               $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
+               $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
+       done
+       echo aaaaaaaaaaa >> $DIR1/d21/no_joined
+
+       mv $DIR2/d21/f_head $DIR2/
+       munlink $DIR2/f_head || error "unlink joined file error"
+       cat $DIR2/d21/no_joined || error "cat error"
+       rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
+}
+run_test 22 " After joining in one dir,  open/close unlink file in anther dir" 
+
 log "cleanup: ======================================================"
 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true