[sheepdog] [PATCH 2/2] tests: use wait instead of _wait_for_collie

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Sep 11 10:03:04 CEST 2012


When we use -valgrind option, there is a delay before collie starts
up.  In the worst case, we could call _wait_for_collie before collie
starts.  To solve the problem, this simply waits for background
processes to finish rather than iterating pgrep and sleep.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 tests/008       |    2 +-
 tests/015       |    8 ++++----
 tests/026       |    3 ++-
 tests/035       |    3 ++-
 tests/037       |    3 ++-
 tests/038       |    3 ++-
 tests/common.rc |   12 ------------
 7 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/tests/008 b/tests/008
index fa18d20..b2ecc43 100755
--- a/tests/008
+++ b/tests/008
@@ -45,7 +45,7 @@ for i in `seq 1 5`; do
 done
 
 echo wait for object recovery to finish
-_wait_for_collie
+wait
 
 for i in `seq 0 4`; do
     for port in `seq 0 7`; do
diff --git a/tests/015 b/tests/015
index b6cc1a9..9c980cb 100755
--- a/tests/015
+++ b/tests/015
@@ -27,7 +27,7 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-_wait_for_collie
+wait
 echo "there should be 3 setattr errors"
 
 $COLLIE vdi setattr test lock 1 -x &
@@ -38,7 +38,7 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-_wait_for_collie
+wait
 echo "there should be 8 setattr errors"
 
 $COLLIE vdi setattr test lock 1 -x &
@@ -47,7 +47,7 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-_wait_for_collie
+wait
 echo "there should be 6 setattr errors"
 
 $COLLIE vdi setattr test lock 1 -x &
@@ -55,5 +55,5 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-_wait_for_collie
+wait
 echo "there should be 5 setattr errors"
diff --git a/tests/026 b/tests/026
index 0a3bbb5..128cf09 100755
--- a/tests/026
+++ b/tests/026
@@ -39,7 +39,8 @@ for i in 5; do _kill_sheep $i;done
 _wait_for_sheep_recovery 0
 for i in `seq 1 5`; do _start_sheep $i;done
 
-_wait_for_collie
+# wait for collie to finish
+wait
 
 # wait vdi create to completion
 while true; do
diff --git a/tests/035 b/tests/035
index 7e2ef98..76573ad 100755
--- a/tests/035
+++ b/tests/035
@@ -40,7 +40,8 @@ for i in `seq 1 4`; do
 	_simulate_machine_down $i
 done
 
-_wait_for_collie
+# wait for collie to finish
+wait
 
 for i in `seq 0 9`; do
 	$COLLIE vdi object -i $i test
diff --git a/tests/037 b/tests/037
index 859cd8c..2d715bb 100755
--- a/tests/037
+++ b/tests/037
@@ -27,7 +27,8 @@ for i in `seq 4 7`; do
     _kill_sheep $i
 done
 
-_wait_for_collie
+# wait for collie to finish
+wait
 
 for i in `seq 4 7`; do
     _start_sheep $i
diff --git a/tests/038 b/tests/038
index 224d136..3f99ae1 100755
--- a/tests/038
+++ b/tests/038
@@ -31,7 +31,8 @@ for i in `seq 4 7`; do
     _kill_sheep $i
 done
 
-_wait_for_collie
+# wait for collie to finish
+wait
 
 for i in `seq 4 7`; do
     _start_sheep $i
diff --git a/tests/common.rc b/tests/common.rc
index 9c6005c..4f29bbc 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -132,18 +132,6 @@ _cleanup()
     done
 }
 
-# wait collie command to execute to completion
-_wait_for_collie()
-{
-    for ((;;)); do
-        if [ "$(pgrep -f "$COLLIE_PROG (cluster|vdi|node|debug)")" ]; then
-            sleep 1
-        else
-            break
-        fi
-    done
-}
-
 _count_sheep_processes()
 {
     pgrep -f "$SHEEP_PROG $STORE/" -l | awk '{ $1=""; print }' | sort | uniq | wc -l
-- 
1.7.2.5




More information about the sheepdog mailing list