Whamcloud - gitweb
b=15230
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
index e1c0535..8dd9d9d 100755 (executable)
@@ -3,7 +3,9 @@
 set -e
 
 PTLDEBUG=${PTLDEBUG:--1}
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
@@ -19,55 +21,25 @@ CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
 # BUG NUMBER: 
 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
 
+#                                      
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
+
 # It is replay-ost-single, after all
 OSTCOUNT=1
 
-gen_config() {
-    formatall
-}
-
-cleanup() {
-    cleanupall
-}
-
-if [ "$ONLY" == "cleanup" ]; then
-    cleanup
-    exit
-fi
-
 build_test_filter
 
-SETUP=${SETUP:-"setup"}
-CLEANUP=${CLEANUP:-"cleanup"}
+REFORMAT=--reformat cleanup_and_setup_lustre
+rm -rf $DIR/[df][0-9]*
 
 test_0a() {
+    zconf_umount `hostname` $MOUNT -f
     # needs to run during initial client->OST connection
     #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
-    do_facet ost "sysctl -w lustre.fail_loc=0x80000211"
+    do_facet ost "lctl set_param fail_loc=0x80000211"
     zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
 }
-
-setup() {
-    gen_config
-    start mds1 `mdsdevname 1` $MDS_MOUNT_OPTS
-    start ost1 `ostdevname 1` $OST_MOUNT_OPTS
-    [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
-
-    # this might not mount if we aren't running test 0a
-    [ -z "`grep " $MOUNT " /proc/mounts`" ] && \
-       run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`" 
-
-    if [ -z "`grep " $MOUNT " /proc/mounts`" ]; then
-       zconf_mount `hostname` $MOUNT || error "mount fail"
-    fi
-    sleep 5
-
-    do_facet ost1 "sysctl -w lustre.fail_loc=0"
-}
-
-mkdir -p $DIR
-
-$SETUP
+run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
 
 test_0b() {
     fail ost1
@@ -114,9 +86,7 @@ test_4() {
     verify=$ROOT/tmp/verify-$$
     dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile
     # invalidate cache, so that we're reading over the wire
-    for i in /proc/fs/lustre/ldlm/namespaces/*-osc-*; do
-        echo -n clear > $i/lru_size
-    done
+    cancel_lru_locks osc
     cmp $verify $DIR/$tfile &
     cmppid=$!
     fail ost1
@@ -127,10 +97,11 @@ run_test 4 "Fail OST during read, with verification"
 
 test_5() {
     [ -z "`which iozone 2> /dev/null`" ] && log "iozone missing" && return
-    FREE=`df -P -h $DIR | tail -n 1 | awk '{ print $3 }'`
-    case $FREE in
-    *T|*G) FREE=1G;;
-    esac
+    FREE=`df -P $DIR | tail -n 1 | awk '{ print $4/2 }'`
+    GB=1048576  # 1048576KB == 1GB
+    if (( FREE > GB )); then
+        FREE=$GB
+    fi
     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
     iozone $IOZONE_OPTS -f $DIR/$tfile &
     PID=$!
@@ -146,7 +117,7 @@ test_5() {
 run_test 5 "Fail OST during iozone"
 
 kbytesfree() {
-   awk '{total+=$1} END {print total}' /proc/fs/lustre/osc/*-osc-*/kbytesfree
+   lctl get_param -n osc.*-osc-*.kbytesfree | awk '{total+=$1} END {print total}'
 }
 
 test_6() {
@@ -156,11 +127,11 @@ test_6() {
     before=`kbytesfree`
     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
     lfs getstripe $f
-#define OBD_FAIL_MDS_REINT_NET_REP       0x119
-    do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
     sync
-    sleep 1                                    # ensure we have a fresh statfs
+    sleep 2                                    # ensure we have a fresh statfs
     sync
+#define OBD_FAIL_MDS_REINT_NET_REP       0x119
+    do_facet mds "lctl set_param fail_loc=0x80000119"
     after_dd=`kbytesfree`
     log "before: $before after_dd: $after_dd"
     (( $before > $after_dd )) || return 1
@@ -183,7 +154,8 @@ test_7() {
     before=`kbytesfree`
     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
     sync
-    sleep 1                                    # ensure we have a fresh statfs
+    sleep 2                                    # ensure we have a fresh statfs
+    sync
     after_dd=`kbytesfree`
     log "before: $before after_dd: $after_dd"
     (( $before > $after_dd )) || return 1
@@ -200,5 +172,6 @@ test_7() {
 }
 run_test 7 "Fail OST before obd_destroy"
 
-equals_msg test complete, cleaning up
-$CLEANUP
+equals_msg `basename $0`: test complete, cleaning up
+check_and_cleanup_lustre
+[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true