From f35318e6c80c75b3336abbd4e0828c9509498ce8 Mon Sep 17 00:00:00 2001
From: grev <grev>
Date: Mon, 22 Oct 2007 22:14:00 +0000
Subject: [PATCH] b=13572 i=Adilger

t-f wait_delete_complete() function; force test_79 to wait;
quiet test_65l output.
---
 lustre/tests/sanity.sh         |  5 ++++-
 lustre/tests/test-framework.sh | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index 27ceb15a0c..88779aeaf8 100644
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -2738,7 +2738,7 @@ run_test 65k "validate manual striping works properly with deactivated OSCs"
 test_65l() { # bug 12836
 	mkdir -p $DIR/$tdir
 	$LFS setstripe $DIR/$tdir 65536 -1 -1
-	$LFS find -mtime -1 $DIR
+	$LFS find -mtime -1 $DIR >/dev/null
 }
 run_test 65l "lfs find on -1 stripe dir ========================"
 
@@ -3262,6 +3262,9 @@ run_test 78 "handle large O_DIRECT writes correctly ============"
 test_79() { # bug 12743
 	[ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
 		skip "skipping test for remote OST" && return
+
+	wait_delete_completed
+
         BKTOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
                  $LPROC/obdfilter/*/kbytestotal`
         BKFREE=`awk 'BEGIN{free=0}; {free+=$1}; END{print free}' \
diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh
index 74333dd38b..88ec6f1cdd 100644
--- a/lustre/tests/test-framework.sh
+++ b/lustre/tests/test-framework.sh
@@ -360,6 +360,24 @@ cleanup_check() {
     return 0
 }
 
+wait_delete_completed () {
+    local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
+            $LPROC/osc/*/kbytesavail`
+
+    local WAIT=0
+    local MAX_WAIT=20
+    while [ "$WAIT" -ne "$MAX_WAIT" ]; do
+        sleep 1
+        TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
+            $LPROC/osc/*/kbytesavail`
+        [ "$TOTAL" -eq "$TOTALPREV" ] && break
+        echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
+        TOTALPREV=$TOTAL
+        WAIT=$(( WAIT + 1))
+    done
+    echo "Delete completed."
+}
+
 wait_for_host() {
     HOST=$1
     check_network "$HOST" 900
-- 
GitLab