Whamcloud - gitweb
b=22842 do not use bash variable to pass test setup state between sub-test
[fs/lustre-release.git] / lustre / tests / sanity.sh
index a2aec03..2832acd 100755 (executable)
@@ -2311,12 +2311,10 @@ stop_writeback() {
 
 # ensure that all stripes have some grant before we test client-side cache
 setup_test42() {
-       [ "$SETUP_TEST42" ] && return
        for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
                dd if=/dev/zero of=$i bs=4k count=1
                rm $i
        done
-       SETUP_TEST42=DONE
 }
 
 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
@@ -4284,9 +4282,7 @@ test_101() {
 }
 run_test 101 "check read-ahead for random reads ================"
 
-export SETUP_TEST101=no
 setup_test101() {
-       [ "$SETUP_TEST101" = "yes" ] && return
        mkdir -p $DIR/$tdir
        STRIPE_SIZE=1048576
        STRIPE_COUNT=$OSTCOUNT
@@ -4297,15 +4293,12 @@ setup_test101() {
        $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
 
        dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
-       SETUP_TEST101=yes
 }
 
 cleanup_test101() {
-       [ "$SETUP_TEST101" = "yes" ] || return
        trap 0
        rm -rf $DIR/$tdir
-        rm -f $DIR/$tfile
-       SETUP_TEST101=no
+       rm -f $DIR/$tfile
 }
 
 calc_total() {
@@ -4353,7 +4346,6 @@ test_101b() {
                cancel_lru_locks osc
                ra_check_101 $BSIZE
        done
-       cleanup_test101
        true
 }
 run_test 101b "check stride-io mode read-ahead ================="
@@ -4403,9 +4395,7 @@ test_101d() {
 }
 run_test 101d "file read with and without read-ahead enabled  ================="
 
-export SETUP_TEST102=no
 setup_test102() {
-       [ "$SETUP_TEST102" = "yes" ] && return
        mkdir -p $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
        STRIPE_SIZE=65536
@@ -4432,14 +4422,12 @@ setup_test102() {
 
        cd $DIR
        $1 $TAR cf $TMP/f102.tar $tdir --xattrs
-       SETUP_TEST102=yes
 }
 
 cleanup_test102() {
        trap 0
-       [ "$SETUP_TEST102" = "yes" ] || return 0
        rm -f $TMP/f102.tar
-       SETUP_TEST102=no
+       rm -rf $DIR/d0.sanity/d102
 }
 
 test_102a() {
@@ -5023,7 +5011,7 @@ test_116() {
        [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
        [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
 
-       rm -rf $DIR/$tdir/OST${MINI}
+       rm -rf $DIR/$tdir
 }
 run_test 116 "stripe QOS: free space balance ==================="
 
@@ -5381,16 +5369,17 @@ test_118k()
        set_nodes_failloc "$(osts_nodes)" 0x20e
        mkdir -p $DIR/$tdir
 
-        for ((i=0;i<10;i++)); do
-                (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
+       for ((i=0;i<10;i++)); do
+               (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
                        error "dd to $DIR/$tdir/$tfile-$i failed" )&
-               SLEEPPID=$!
-                sleep 0.500s
-               kill $SLEEPPID
-               wait $SLEEPPID
-        done
+               SLEEPPID=$!
+               sleep 0.500s
+               kill $SLEEPPID
+               wait $SLEEPPID
+       done
 
-        set_nodes_failloc "$(osts_nodes)" 0
+       set_nodes_failloc "$(osts_nodes)" 0
+       rm -rf $DIR/$tdir
 }
 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
 
@@ -6350,9 +6339,11 @@ som_mode_switch() {
 
         if [ x$som = x"enabled" ]; then
                 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
+                MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
                 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
         else
                 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
+                MOUNTOPT="$MOUNTOPT,som_preview"
                 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
         fi
 
@@ -6364,8 +6355,9 @@ som_mode_switch() {
 }
 
 test_132() { #1028, SOM
-       local num=$(get_mds_dir $DIR)
-       local mymds=mds${num}
+        local num=$(get_mds_dir $DIR)
+        local mymds=mds${num}
+        local MOUNTOPT_SAVE=$MOUNTOPT
 
         dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
         cancel_lru_locks osc
@@ -6395,8 +6387,9 @@ test_132() { #1028, SOM
         gl1=$(get_ost_param "ldlm_glimpse_enqueue")
         stat $DIR/$tfile >/dev/null
         gl2=$(get_ost_param "ldlm_glimpse_enqueue")
-        echo "SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
+        echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
         som_mode_switch $som2 $gl1 $gl2
+        MOUNTOPT=$MOUNTOPT_SAVE
 }
 run_test 132 "som avoids glimpse rpc"
 
@@ -6882,7 +6875,7 @@ test_161() {
     rm $DIR/$tdir/$tfile
     # rename
     mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
-    if [ "$($LFS fid2path $DIR --link 1 $FID)" != "/$tdir/foo2/maggie" ]
+    if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
        then
        $LFS fid2path $DIR $FID
        err17935 "bad link rename"
@@ -6929,20 +6922,20 @@ test_162() {
     mkdir -p $DIR/$tdir/d2/p/q/r
        # regular file
     FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[')
-    check_path "/$tdir/d2/$tfile" $DIR $FID --link 0
+    check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
 
        # softlink
     ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
     FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[')
-    check_path "/$tdir/d2/p/q/r/slink" $DIR $FID --link 0
+    check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
 
        # hardlink
     ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
     mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
     FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[')
     # fid2path dir/fsname should both work
-    check_path "/$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
-    check_path "/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
+    check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
+    check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
 
     # hardlink count: check that there are 2 links
     # Doesnt work with CMD yet: 17935
@@ -6951,7 +6944,7 @@ test_162() {
 
        # hardlink indexing: remove the first link
     rm $DIR/$tdir/d2/p/q/r/hlink
-    check_path "/$tdir/d2/a/b/c/new_file" $DIR $FID --link 0
+    check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
 
        return 0
 }
@@ -7140,7 +7133,8 @@ TGTPOOL_MAX=$(($TGT_COUNT - 1))
 TGTPOOL_STEP=2
 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
-POOL_DIR=$POOL_ROOT/dir_tst
+POOL_DIR_NAME=dir_tst
+POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
 POOL_FILE=$POOL_ROOT/file_tst
 
 check_file_in_pool()
@@ -7190,6 +7184,18 @@ test_200c() {
        mkdir -p $POOL_DIR
        $SETSTRIPE -c 2 -p $POOL $POOL_DIR
        [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
+       # b-19919 test relative path works well
+       mkdir -p $POOL_DIR/$POOL_DIR_NAME
+       cd $POOL_DIR
+       $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
+       [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
+       $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
+       [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
+       $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
+       [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
+       $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
+       [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
+       rm -rf $POOL_DIR_NAME; cd -
 }
 run_test 200c "Set pool on a directory ================================="