Whamcloud - gitweb
LU-1285 tests: fix tar breakage in 102d/102f/102j
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 5 Apr 2012 23:37:09 +0000 (17:37 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Apr 2012 14:12:11 +0000 (10:12 -0400)
Due to changes in commit a5fed8233f4f5755d61909849e23d146a94d4396
to remove the use of ad-hoc "lfs getstripe" output parsing, the
sanity.sh tests 102d, 102f, and 102j were broken.  Fix the tests
to use "lfs getstripe [-c|-S|-i]" instead of "get_stripe_info()".

Allow the new files to have 3/4 stripes (per min_stripe_count())
of the originally backed up files in case there are not enough
OSC objects available.

Also clean up the formatting of test_102a to match the coding
style, avoid breaking the vim syntax highlighting due to the
use of excessive quoting, and add proper error messages on failure.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I2cd09c455f024882d94cf945a0e2f546d13ac27a
Reviewed-on: http://review.whamcloud.com/2458
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/replay-ost-single.sh
lustre/tests/sanity.sh

index d81acbf..7727f38 100755 (executable)
@@ -176,7 +176,7 @@ test_6() {
 
     f=$TDIR/$tfile
     rm -f $f
-    sync && sleep 2 && sync    # wait for delete thread
+    sync && sleep 2 && sync  # wait for delete thread
 
     # wait till space is returned, following
     # (( $before > $after_dd)) test counting on that
@@ -186,19 +186,21 @@ test_6() {
     before=`kbytesfree`
     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
     lfs getstripe $f
-    get_stripe_info client $f
+    stripe_index=$(lfs getstripe -i $f)
 
     sync
     sleep 2 # ensure we have a fresh statfs
     sync
-#define OBD_FAIL_MDS_REINT_NET_REP       0x119
+
+    #define OBD_FAIL_MDS_REINT_NET_REP       0x119
     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
     after_dd=`kbytesfree`
     log "before: $before after_dd: $after_dd"
     (( $before > $after_dd )) || return 1
     rm -f $f
     fail ost$((stripe_index + 1))
-    wait_recovery_complete ost$((stripe_index + 1)) || error "OST recovery not done"
+    wait_recovery_complete ost$((stripe_index + 1)) ||
+        error "OST$((stripe_index + 1)) recovery not completed"
     $CHECKSTAT -t file $f && return 2 || true
     sync
     # let the delete happen
@@ -206,7 +208,7 @@ test_6() {
     wait_destroy_complete || return 5
     after=`kbytesfree`
     log "before: $before after: $after"
-    (( $before <= $after + 40 )) || return 3   # take OST logs into account
+    (( $before <= $after + 40 )) || return 3   # take OST logs into account
 }
 run_test 6 "Fail OST before obd_destroy"
 
index 902fd1b..f1e2629 100644 (file)
@@ -5257,8 +5257,7 @@ cleanup_test102() {
 test_102a() {
        local testfile=$DIR/xattr_testfile
 
-       rm -f $testfile
-        touch $testfile
+       touch $testfile
 
        [ "$UID" != 0 ] && skip_env "must run as root" && return
        [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
@@ -5268,40 +5267,48 @@ test_102a() {
                skip_env "could not find setfattr" && return
 
        echo "set/get xattr..."
-        setfattr -n trusted.name1 -v value1 $testfile || error
-        [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
-        grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
+       setfattr -n trusted.name1 -v value1 $testfile || error
+       getfattr -n trusted.name1 $testfile 2> /dev/null |
+         grep "trusted.name1=.value1" ||
+               error "$testfile missing trusted.name1=value1"
 
-        setfattr -n user.author1 -v author1 $testfile || error
-        [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
-        grep "user.author1"`" == "user.author1=\"author1\"" ] || error
+       setfattr -n user.author1 -v author1 $testfile || error
+       getfattr -n user.author1 $testfile 2> /dev/null |
+         grep "user.author1=.author1" ||
+               error "$testfile missing trusted.author1=author1"
 
        echo "listxattr..."
-        setfattr -n trusted.name2 -v value2 $testfile || error
-        setfattr -n trusted.name3 -v value3 $testfile || error
-        [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
-        grep "trusted.name" | wc -l` -eq 3 ] || error
-
-
-        setfattr -n user.author2 -v author2 $testfile || error
-        setfattr -n user.author3 -v author3 $testfile || error
-        [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
-        grep "user" | wc -l` -eq 3 ] || error
+       setfattr -n trusted.name2 -v value2 $testfile ||
+               error "$testfile unable to set trusted.name2"
+       setfattr -n trusted.name3 -v value3 $testfile ||
+               error "$testfile unable to set trusted.name3"
+       [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
+           grep "trusted.name" | wc -l) -eq 3 ] ||
+               error "$testfile missing 3 trusted.name xattrs"
+
+       setfattr -n user.author2 -v author2 $testfile ||
+               error "$testfile unable to set user.author2"
+       setfattr -n user.author3 -v author3 $testfile ||
+               error "$testfile unable to set user.author3"
+       [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
+           grep "user.author" | wc -l) -eq 3 ] ||
+               error "$testfile missing 3 user.author xattrs"
 
        echo "remove xattr..."
-        setfattr -x trusted.name1 $testfile || error
-        getfattr -d -m trusted $testfile 2> /dev/null | \
-        grep "trusted.name1" && error || true
+       setfattr -x trusted.name1 $testfile ||
+               error "$testfile error deleting trusted.name1"
+       getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
+               error "$testfile did not delete trusted.name1 xattr"
 
-        setfattr -x user.author1 $testfile || error
-        getfattr -d -m user $testfile 2> /dev/null | \
-        grep "user.author1" && error || true
+       setfattr -x user.author1 $testfile ||
+               error "$testfile error deleting user.author1"
+       getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
+               error "$testfile did not delete trusted.name1 xattr"
 
        # b10667: setting lustre special xattr be silently discarded
        echo "set lustre special xattr ..."
-       setfattr -n "trusted.lov" -v "invalid value" $testfile || error
-
-       rm -f $testfile
+       setfattr -n "trusted.lov" -v "invalid value" $testfile ||
+               error "$testfile allowed setting trusted.lov"
 }
 run_test 102a "user xattr test =================================="
 
@@ -5361,59 +5368,34 @@ test_102c() {
 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
 
 compare_stripe_info1() {
-       local stripe_index_all_zero=1
+       local stripe_index_all_zero=true
 
-       for num in 1 2 3 4
-       do
-               for count in `seq 1 $STRIPE_COUNT`
-               do
-                       for offset in `seq 0 $[$STRIPE_COUNT - 1]`
-                       do
-                               local size=`expr $STRIPE_SIZE \* $num`
+       for num in 1 2 3 4; do
+               for count in $(seq 1 $STRIPE_COUNT); do
+                       for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
+                               local size=$((STRIPE_SIZE * num))
                                local file=file"$num-$offset-$count"
-                               get_stripe_info client $PWD/$file "$1"
-                               if [ $stripe_size -ne $size ]; then
-                                       error "$file: different stripe size $stripe_size, expected $size" && return
-                               fi
-                               if [ $stripe_count -ne $count ]; then
-                                       error "$file: different stripe count $stripe_count, expected $count" && return
-                               fi
-                               if [ $stripe_index -ne 0 ]; then
-                                      stripe_index_all_zero=0
-                               fi
+                               stripe_size=$(lfs getstripe -S $PWD/$file)
+                               [ $stripe_size -ne $size ] &&
+                                   error "$file: size $stripe_size != $size"
+                               stripe_count=$(lfs getstripe -c $PWD/$file)
+                               # allow fewer stripes to be created, ORI-601
+                               [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
+                                   error "$file: count $stripe_count != $count"
+                               stripe_index=$(lfs getstripe -i $PWD/$file)
+                               [ $stripe_index -ne 0 ] &&
+                                       stripe_index_all_zero=false
                        done
                done
        done
-       [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
+       $stripe_index_all_zero &&
+               error "all files are being extracted starting from OST index 0"
        return 0
 }
 
-compare_stripe_info2() {
-       for num in 1 2 3 4
-       do
-               for count in `seq 1 $STRIPE_COUNT`
-               do
-                       for offset in `seq 0 $[$STRIPE_COUNT - 1]`
-                       do
-                               local size=`expr $STRIPE_SIZE \* $num`
-                               local file=file"$num-$offset-$count"
-                               get_stripe_info client $PWD/$file
-                               if [ $stripe_size -ne $size ]; then
-                                       error "$file: different stripe size $stripe_size, expected $size" && return
-                               fi
-                               if [ $stripe_count -ne $count ]; then
-                                       error "$file: different stripe count $stripe_count, expected $count" && return
-                               fi
-                               if [ $stripe_index -ne $offset ]; then
-                                       error "$file: different stripe offset $stripe_index, expected $offset" && return
-                               fi
-                       done
-               done
-       done
-}
-
 find_lustre_tar() {
-       [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
+       [ -n "$(which tar 2>/dev/null)" ] &&
+               strings $(which tar) | grep -q "lustre" && echo tar
 }
 
 test_102d() {