Whamcloud - gitweb
LU-774 test: wait till space from previous tests is released
[fs/lustre-release.git] / lustre / tests / replay-ost-single.sh
index 512bfe6..d81acbf 100755 (executable)
@@ -2,25 +2,20 @@
 
 set -e
 
-PTLDEBUG=${PTLDEBUG:--1}
 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}
+init_logging
 
 # While we do not use OSTCOUNT=1 setup anymore,
 # ost1failover_HOST is used
 #ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
 
-remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
-
-if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
-    skip "$0: Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
-    exit 0
-fi
+require_dsh_ost || exit 0
 
 # Tests that fail on uml
 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
@@ -125,7 +120,7 @@ iozone_bg () {
     # need to check iozone output  on "complete"
     local iozonelog=$TMP/${TESTSUITE}.iozone.log
     rm -f $iozonelog
-    cat $tmppipe | while read line ; do 
+    cat $tmppipe | while read line ; do
         echo "$line"
         echo "$line" >>$iozonelog
     done;
@@ -139,11 +134,11 @@ iozone_bg () {
     fi
     rm -f $tmppipe
     rm -f $iozonelog
-    return $rc 
+    return $rc
 }
 
 test_5() {
-    [ -z "`which iozone 2> /dev/null`" ] && skip "iozone missing" && return 0
+    [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
 
     # striping is -c 1, get min of available
     local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
@@ -159,7 +154,7 @@ test_5() {
     local pid=$!
 
     echo iozone bg pid=$pid
-    
+
     sleep 8
     fail ost1
     local rc=0
@@ -182,25 +177,33 @@ test_6() {
     f=$TDIR/$tfile
     rm -f $f
     sync && sleep 2 && sync    # wait for delete thread
+
+    # wait till space is returned, following
+    # (( $before > $after_dd)) test counting on that
+    wait_mds_ost_sync || return 4
+    wait_destroy_complete || return 5
+
     before=`kbytesfree`
     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
     lfs getstripe $f
     get_stripe_info client $f
 
     sync
-    sleep 2                                    # 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"
+    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"
     $CHECKSTAT -t file $f && return 2 || true
     sync
     # let the delete happen
-    sleep 5
+    wait_mds_ost_sync || return 4
+    wait_destroy_complete || return 5
     after=`kbytesfree`
     log "before: $before after: $after"
     (( $before <= $after + 40 )) || return 3   # take OST logs into account
@@ -211,10 +214,16 @@ test_7() {
     f=$TDIR/$tfile
     rm -f $f
     sync && sleep 5 && sync    # wait for delete thread
+
+    # wait till space is returned, following
+    # (( $before > $after_dd)) test counting on that
+    wait_mds_ost_sync || return 4
+    wait_destroy_complete || return 5
+
     before=`kbytesfree`
     dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
     sync
-    sleep 2                                    # 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"
@@ -222,16 +231,18 @@ test_7() {
     replay_barrier ost1
     rm -f $f
     fail ost1
+    wait_recovery_complete ost1 || error "OST recovery not done"
     $CHECKSTAT -t file $f && return 2 || true
     sync
     # let the delete happen
-    sleep 5
+    wait_mds_ost_sync || return 4
+    wait_destroy_complete || return 5
     after=`kbytesfree`
     log "before: $before after: $after"
     (( $before <= $after + 40 )) || return 3   # take OST logs into account
 }
 run_test 7 "Fail OST before obd_destroy"
 
-equals_msg `basename $0`: test complete, cleaning up
+complete $(basename $0) $SECONDS
 check_and_cleanup_lustre
-[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true
+exit_status