[sheepdog] [PATCH] tests: add wrapper _cluster_format

MORITA Kazutaka morita.kazutaka at gmail.com
Mon Jun 17 19:27:20 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

This introduces a helper _cluster_format to wait for all the sheeps to
be running.  This removes sleep after 'collie cluster format' and
reduces the possibility of causing a false alarm.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 tests/001       |    3 +--
 tests/002       |    3 +--
 tests/003       |    3 +--
 tests/004       |    2 +-
 tests/005       |    3 +--
 tests/006       |    3 +--
 tests/007       |    4 ++--
 tests/008       |    3 +--
 tests/009       |    2 +-
 tests/010       |    2 +-
 tests/013       |    2 +-
 tests/014       |    2 +-
 tests/015       |    4 ++--
 tests/016       |    2 +-
 tests/017       |    2 +-
 tests/018       |    2 +-
 tests/019       |    2 +-
 tests/020       |    2 +-
 tests/021       |    2 +-
 tests/022       |    2 +-
 tests/024       |    3 +--
 tests/025       |    2 +-
 tests/026       |    2 +-
 tests/027       |    2 +-
 tests/028       |    2 +-
 tests/029       |    2 +-
 tests/030       |    4 ++--
 tests/031       |    2 +-
 tests/032       |    2 +-
 tests/033       |    2 +-
 tests/034       |    3 +--
 tests/035       |    2 +-
 tests/039       |    2 +-
 tests/040       |    2 +-
 tests/041       |    2 +-
 tests/042       |    2 +-
 tests/043       |    2 +-
 tests/044       |    2 +-
 tests/045       |    2 +-
 tests/046       |    2 +-
 tests/047       |    3 +--
 tests/048       |    3 +--
 tests/049       |    3 +--
 tests/050       |    2 +-
 tests/051       |    3 +--
 tests/052       |    3 +--
 tests/053       |    3 +--
 tests/054       |    3 +--
 tests/055       |    3 +--
 tests/056       |    3 +--
 tests/057       |    3 +--
 tests/058       |    3 +--
 tests/059       |    2 +-
 tests/060       |    2 +-
 tests/061       |    3 +--
 tests/062       |    3 +--
 tests/063       |    3 +--
 tests/064       |    3 +--
 tests/common.rc |   26 ++++++++++++++++++++++++++
 59 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/tests/001 b/tests/001
index 3f61d95..6cd0010 100755
--- a/tests/001
+++ b/tests/001
@@ -22,8 +22,7 @@ done
 _wait_for_sheep 2
 
 # start Sheepdog with two nodes
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 # kill the master node
 _kill_sheep 0
diff --git a/tests/002 b/tests/002
index 13c48eb..572ab5b 100755
--- a/tests/002
+++ b/tests/002
@@ -22,8 +22,7 @@ done
 _wait_for_sheep 3
 
 # start Sheepdog with three nodes
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 # kill all sheeps
 for i in 0 1 2; do
diff --git a/tests/003 b/tests/003
index 52c5e5f..5b3bdf5 100755
--- a/tests/003
+++ b/tests/003
@@ -21,9 +21,8 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format
+_cluster_format
 
-sleep 1
 # kill all sheeps
 for i in 0 1 2; do
     _kill_sheep $i
diff --git a/tests/004 b/tests/004
index 28e2f24..fa540f3 100755
--- a/tests/004
+++ b/tests/004
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 2
 # start Sheepdog with two nodes
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 for i in 2 3 4; do
     # add one node after killing existing one node
diff --git a/tests/005 b/tests/005
index 3ed013d..a7786e9 100755
--- a/tests/005
+++ b/tests/005
@@ -21,8 +21,7 @@ done
 
 _wait_for_sheep 2
 # start Sheepdog with two nodes
-$COLLIE cluster format -c 1
-sleep 1
+_cluster_format -c 1
 
 for i in 2 3 4; do
     _kill_sheep $((i - 2))
diff --git a/tests/006 b/tests/006
index c89676b..b670a44 100755
--- a/tests/006
+++ b/tests/006
@@ -19,8 +19,7 @@ _start_sheep 0
 _wait_for_sheep 1
 
 # start Sheepdog with one node
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 # launch sheeps simultaneously
 for i in `seq 1 9`; do
diff --git a/tests/007 b/tests/007
index 2af9254..16555e6 100755
--- a/tests/007
+++ b/tests/007
@@ -19,14 +19,14 @@ _cleanup
 # create a node who has wrong epoch
 _start_sheep 1
 _wait_for_sheep 1 1
-$COLLIE cluster format -p 7001 -c 1
+_cluster_format -p 7001 -c 1
 $COLLIE cluster shutdown -p 7001
 _wait_for_sheep_stop
 
 # start Sheepdog with one node
 _start_sheep 0
 _wait_for_sheep 1
-$COLLIE cluster format -p 7000 -c 1
+_cluster_format -p 7000 -c 1
 
 for i in `seq 0 5`; do
     _start_sheep 1  # should fail
diff --git a/tests/008 b/tests/008
index 1b78ecd..36078ce 100755
--- a/tests/008
+++ b/tests/008
@@ -25,8 +25,7 @@ done
 
 _wait_for_sheep "8"
 
-$COLLIE cluster format -c 3
-sleep 1
+_cluster_format -c 3
 
 for i in `seq 0 4`; do
     $COLLIE vdi create test$i 100M
diff --git a/tests/009 b/tests/009
index c76bb5e..3d3142e 100755
--- a/tests/009
+++ b/tests/009
@@ -22,7 +22,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 # create a pre-allocated vdi
 $COLLIE vdi create test 80M -P
diff --git a/tests/010 b/tests/010
index 6800c2e..25591f1 100755
--- a/tests/010
+++ b/tests/010
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 5
 
-$COLLIE cluster format
+_cluster_format
 $COLLIE cluster recover disable
 
 $COLLIE vdi create test 4G
diff --git a/tests/013 b/tests/013
index 27c4bac..76f62a8 100755
--- a/tests/013
+++ b/tests/013
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 1
+_cluster_format -c 1
 
 qemu-img create sheepdog:test 4G
 for i in `seq 1 9`; do
diff --git a/tests/014 b/tests/014
index 9f8b625..28167b7 100755
--- a/tests/014
+++ b/tests/014
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 2
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 $COLLIE vdi create test 4G
 
 echo -n value > $STORE/tmp.dat
diff --git a/tests/015 b/tests/015
index d3bd1e3..d1de9d2 100755
--- a/tests/015
+++ b/tests/015
@@ -21,8 +21,8 @@ done
 
 _wait_for_sheep 2
 
-$COLLIE cluster format -c 2
-sleep 1
+_cluster_format -c 2
+
 $COLLIE vdi create test 539545600
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
diff --git a/tests/016 b/tests/016
index c10d9e1..378a82a 100755
--- a/tests/016
+++ b/tests/016
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
 $COLLIE vdi create base 100M -P
 
 qemu-img snapshot -c tag sheepdog:base
diff --git a/tests/017 b/tests/017
index 2858e22..9093c63 100755
--- a/tests/017
+++ b/tests/017
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 1
+_cluster_format -c 1
 
 qemu-img create sheepdog:test 4G
 qemu-img snapshot -c tag1 sheepdog:test
diff --git a/tests/018 b/tests/018
index 7ab4536..5f3310f 100755
--- a/tests/018
+++ b/tests/018
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep "3"
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 $COLLIE vdi create test 4M
 
diff --git a/tests/019 b/tests/019
index 351a1e9..8fbd8de 100755
--- a/tests/019
+++ b/tests/019
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep "3"
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 $COLLIE vdi create test 4M
 
diff --git a/tests/020 b/tests/020
index c5993f8..3b66b5f 100755
--- a/tests/020
+++ b/tests/020
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep "3"
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 $COLLIE vdi create test 40M
 
diff --git a/tests/021 b/tests/021
index f7c86c3..a23b353 100755
--- a/tests/021
+++ b/tests/021
@@ -21,4 +21,4 @@ done
 
 _wait_for_sheep "3"
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
diff --git a/tests/022 b/tests/022
index d7b4bfe..0084ac0 100755
--- a/tests/022
+++ b/tests/022
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep "3"
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
 
 echo "creating a VDI should fail without data nodes available"
 $COLLIE vdi create test 100M
diff --git a/tests/024 b/tests/024
index f8668f0..a8b03bc 100755
--- a/tests/024
+++ b/tests/024
@@ -27,8 +27,7 @@ _start_sheep 0
 _wait_for_sheep 1
 
 echo "formatting cluster"
-$COLLIE cluster format -c 1
-sleep 1
+_cluster_format -c 1
 
 echo "creating vdi ${NAME}"
 $COLLIE vdi create ${VDI_NAME} ${VDI_SIZE}
diff --git a/tests/025 b/tests/025
index 5f4259a..a7f7f4c 100755
--- a/tests/025
+++ b/tests/025
@@ -31,7 +31,7 @@ done
 _wait_for_sheep "3"
 
 echo "formatting cluster"
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 echo "creating vdi ${NAME}"
 $COLLIE vdi create ${VDI_NAME} ${VDI_SIZE}
diff --git a/tests/026 b/tests/026
index 9843e22..7cf5ad6 100755
--- a/tests/026
+++ b/tests/026
@@ -25,7 +25,7 @@ done
 
 _wait_for_sheep "8"
 
-$COLLIE cluster format
+_cluster_format
 
 # create new vdis
 (
diff --git a/tests/027 b/tests/027
index 05f4ab9..55dcda9 100755
--- a/tests/027
+++ b/tests/027
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep "4"
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 $COLLIE vdi create test0 40M
 $COLLIE vdi create test1 40M
diff --git a/tests/028 b/tests/028
index 53d4ecf..c704972 100755
--- a/tests/028
+++ b/tests/028
@@ -19,7 +19,7 @@ for i in `seq 0 1`; do _start_sheep $i; done
 
 _wait_for_sheep 2
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 $COLLIE vdi create test 100M
 
diff --git a/tests/029 b/tests/029
index 3bec2ec..4d1e6ff 100755
--- a/tests/029
+++ b/tests/029
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 7
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
 
 for i in `seq 2 4`; do
 	$COLLIE vdi create test$i 20M -c $i -P
diff --git a/tests/030 b/tests/030
index 62e78ec..5a34ba2 100755
--- a/tests/030
+++ b/tests/030
@@ -23,7 +23,7 @@ _wait_for_sheep 4
 TMPDIR="$STORE/tmp"
 rm -rf $TMPDIR
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
 
 $COLLIE vdi create test1 10M
 $COLLIE vdi create test2 10M
@@ -54,7 +54,7 @@ for i in `seq 0 3`; do
 done
 _wait_for_sheep 4
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
 $COLLIE cluster snapshot load s1 $TMPDIR
 $COLLIE vdi list | _filter_short_date
 
diff --git a/tests/031 b/tests/031
index 61fde5b..467f468 100755
--- a/tests/031
+++ b/tests/031
@@ -18,7 +18,7 @@ _cleanup
 _start_sheep 0
 _wait_for_sheep 1
 
-$COLLIE cluster format -c 1
+_cluster_format -c 1
 
 for i in 1 2 3; do
     $COLLIE vdi create test$i ${i}00MB
diff --git a/tests/032 b/tests/032
index 7887a1c..c2915dd 100755
--- a/tests/032
+++ b/tests/032
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 8
 
-$COLLIE cluster format
+_cluster_format
 
 $COLLIE vdi create test 100MB
 # create 25 objects
diff --git a/tests/033 b/tests/033
index 28a5da6..e796d3e 100755
--- a/tests/033
+++ b/tests/033
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 8
 
-$COLLIE cluster format
+_cluster_format
 
 $COLLIE vdi create test 100MB
 # create 25 objects
diff --git a/tests/034 b/tests/034
index be80633..9c5fb99 100755
--- a/tests/034
+++ b/tests/034
@@ -26,8 +26,7 @@ done
 
 _wait_for_sheep 8
 
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 $COLLIE vdi create test 100MB
 # create 25 objects
diff --git a/tests/035 b/tests/035
index 090bd2f..bcc044a 100755
--- a/tests/035
+++ b/tests/035
@@ -32,7 +32,7 @@ done
 
 _wait_for_sheep 6
 
-$COLLIE cluster format -c 3 -m unsafe
+_cluster_format -c 3 -m unsafe
 
 $COLLIE vdi create test 40M
 _random | $COLLIE vdi write test &
diff --git a/tests/039 b/tests/039
index 55bd65d..d88ea70 100755
--- a/tests/039
+++ b/tests/039
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 5
 
-$COLLIE cluster format
+_cluster_format
 $COLLIE vdi create test 4G
 
 qemu-io -c "write 0 512 -P 1" sheepdog:test | _filter_qemu_io
diff --git a/tests/040 b/tests/040
index f471500..9eb9351 100755
--- a/tests/040
+++ b/tests/040
@@ -18,7 +18,7 @@ _cleanup
 _start_sheep 0
 _wait_for_sheep 1
 
-$COLLIE cluster format -c 1
+_cluster_format -c 1
 
 # create vdi in background
 $COLLIE vdi create test 4G &
diff --git a/tests/041 b/tests/041
index ddcb43d..0ca29f7 100755
--- a/tests/041
+++ b/tests/041
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 5
 
-$COLLIE cluster format
+_cluster_format
 $COLLIE vdi create test 12M
 
 # create the first object
diff --git a/tests/042 b/tests/042
index 9680985..1fc8e88 100755
--- a/tests/042
+++ b/tests/042
@@ -33,7 +33,7 @@ done
 
 _wait_for_sheep 4
 
-$COLLIE cluster format
+_cluster_format
 
 # create two VDIs before there are enough spaces
 $COLLIE vdi create test0 100M
diff --git a/tests/043 b/tests/043
index ff6b7cc..0d26638 100755
--- a/tests/043
+++ b/tests/043
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 5
 
-$COLLIE cluster format -m unsafe
+_cluster_format -m unsafe
 
 $COLLIE vdi create test 40M
 
diff --git a/tests/044 b/tests/044
index 6dcf099..ce949ae 100755
--- a/tests/044
+++ b/tests/044
@@ -25,7 +25,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format
+_cluster_format
 $COLLIE vdi create base1 20M -p 7000
 $COLLIE vdi create base2 20M -p 7001
 $COLLIE vdi create base3 20M -p 7002
diff --git a/tests/045 b/tests/045
index 796cb84..d30e636 100755
--- a/tests/045
+++ b/tests/045
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 $COLLIE vdi create test 4M
 
 for i in `seq 0 7`; do
diff --git a/tests/046 b/tests/046
index 01a8379..33ff0d5 100755
--- a/tests/046
+++ b/tests/046
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 2
+_cluster_format -c 2
 
 echo "delete snapshot image before current one"
 $COLLIE vdi create test 4G
diff --git a/tests/047 b/tests/047
index f2963a1..e7309da 100755
--- a/tests/047
+++ b/tests/047
@@ -19,8 +19,7 @@ _start_sheep 0 "-j size=64"
 
 _wait_for_sheep 1
 
-$COLLIE cluster format -c 1
-sleep 1
+_cluster_format -c 1
 
 $COLLIE vdi create test 4G
 
diff --git a/tests/048 b/tests/048
index 37118b8..465d4e9 100755
--- a/tests/048
+++ b/tests/048
@@ -21,8 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 $COLLIE vdi create test 1G
 
diff --git a/tests/049 b/tests/049
index b27be1a..95fa6e2 100755
--- a/tests/049
+++ b/tests/049
@@ -21,8 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 1
-sleep 1
+_cluster_format -c 1
 
 $COLLIE vdi create test 20M
 _random | $COLLIE vdi write -w test
diff --git a/tests/050 b/tests/050
index 76eccdd..9a94649 100755
--- a/tests/050
+++ b/tests/050
@@ -31,7 +31,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format
+_cluster_format
 
 $COLLIE vdi create test 100M
 dd if=/dev/zero | $COLLIE vdi write test &
diff --git a/tests/051 b/tests/051
index 5c5f385..799fe70 100755
--- a/tests/051
+++ b/tests/051
@@ -19,8 +19,7 @@ for i in 0 1; do
     _start_sheep $i
 done
 _wait_for_sheep 2
-$COLLIE cluster format
-sleep 1
+_cluster_format
 $COLLIE cluster info | _filter_cluster_info
 
 _start_sheep 2
diff --git a/tests/052 b/tests/052
index 1954737..ae0834a 100755
--- a/tests/052
+++ b/tests/052
@@ -19,8 +19,7 @@ for i in 0 1 2 3; do
     _start_sheep $i
 done
 _wait_for_sheep 4
-$COLLIE cluster format
-sleep 1
+_cluster_format
 $COLLIE vdi create test 20M -P
 $COLLIE cluster info | _filter_cluster_info
 
diff --git a/tests/053 b/tests/053
index d9c1d71..41331da 100755
--- a/tests/053
+++ b/tests/053
@@ -23,8 +23,7 @@ _start_sheep 2
 _start_sheep 3
 _wait_for_sheep 4
 
-$COLLIE cluster format -c 2
-sleep 1
+_cluster_format -c 2
 for i in 0 1 2 3; do
     $COLLIE cluster info -p 700$i | _filter_cluster_info
 done
diff --git a/tests/054 b/tests/054
index 0649021..54b8df7 100755
--- a/tests/054
+++ b/tests/054
@@ -26,8 +26,7 @@ for i in 0 1 2; do
 	_start_sheep $i
 done
 _wait_for_sheep 3
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 $COLLIE vdi create test 100M -P
 $COLLIE cluster info | _filter_cluster_info
diff --git a/tests/055 b/tests/055
index 4a2a462..5a87f27 100755
--- a/tests/055
+++ b/tests/055
@@ -20,8 +20,7 @@ for i in 0 1 2; do
 	_start_sheep $i
 done
 _wait_for_sheep 3
-$COLLIE cluster format -c 2
-sleep 1
+_cluster_format -c 2
 $COLLIE vdi create test 200M -P
 
 # simulate one disk failure
diff --git a/tests/056 b/tests/056
index f6ad00b..b89c888 100755
--- a/tests/056
+++ b/tests/056
@@ -20,8 +20,7 @@ for i in 0 1 2; do
 	_start_sheep $i
 done
 _wait_for_sheep 3
-$COLLIE cluster format
-sleep 1
+_cluster_format
 $COLLIE vdi create test 200M -P
 
 # node event after disk failure
diff --git a/tests/057 b/tests/057
index ee95589..3c23e51 100755
--- a/tests/057
+++ b/tests/057
@@ -24,8 +24,7 @@ for i in 0 1 2; do
 	_start_sheep $i
 done
 _wait_for_sheep 3
-$COLLIE cluster format
-sleep 1
+_cluster_format
 $COLLIE vdi create test 100M -P
 
 _md_info
diff --git a/tests/058 b/tests/058
index bda659c..3bbb789 100755
--- a/tests/058
+++ b/tests/058
@@ -18,8 +18,7 @@ for i in 0 1 2; do
 	_start_sheep $i
 done
 _wait_for_sheep 3
-$COLLIE cluster format
-sleep 1
+_cluster_format
 $COLLIE vdi create test 100M -P
 _node_info
 qemu-io -c "discard 0 100m" sheepdog:test | _filter_qemu_io
diff --git a/tests/059 b/tests/059
index d818fcc..6b34d39 100755
--- a/tests/059
+++ b/tests/059
@@ -21,7 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
 $COLLIE vdi create test 4M
 
 _input()
diff --git a/tests/060 b/tests/060
index e9f51ea..7683285 100755
--- a/tests/060
+++ b/tests/060
@@ -20,7 +20,7 @@ done
 
 _wait_for_sheep 8
 
-$COLLIE cluster format
+_cluster_format
 
 for i in `seq 0 3`; do
     $COLLIE vdi create test$i 100M
diff --git a/tests/061 b/tests/061
index c1488bd..1cd0391 100755
--- a/tests/061
+++ b/tests/061
@@ -21,8 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format -c 1
-sleep 1
+_cluster_format -c 1
 
 $COLLIE vdi create test 40M -P
 
diff --git a/tests/062 b/tests/062
index 0292b1d..0fe16b0 100755
--- a/tests/062
+++ b/tests/062
@@ -21,8 +21,7 @@ done
 
 _wait_for_sheep 3
 
-$COLLIE cluster format
-sleep 1
+_cluster_format
 
 $COLLIE vdi create test 1234
 sleep 1
diff --git a/tests/063 b/tests/063
index deec2d5..2d687df 100755
--- a/tests/063
+++ b/tests/063
@@ -29,8 +29,7 @@ for i in 0 1 2; do
 done
 _start_sheep 3 "-g"
 _wait_for_sheep 4
-$COLLIE cluster format -c 1
-sleep 1
+_cluster_format -c 1
 
 $COLLIE vdi create test 200M -P
 _node_info
diff --git a/tests/064 b/tests/064
index e1ff9d0..f6a294a 100755
--- a/tests/064
+++ b/tests/064
@@ -26,8 +26,7 @@ for i in 0 1 2; do
 	_start_sheep $i
 done
 _wait_for_sheep 3
-$COLLIE cluster format -c 2
-sleep 1
+_cluster_format -c 2
 
 $COLLIE vdi create test 100M -P
 _node_info
diff --git a/tests/common.rc b/tests/common.rc
index 7d79dff..88f4c24 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -433,6 +433,32 @@ _md_info()
     _stat_store '?/d?'
 }
 
+_cluster_format()
+{
+    local args=$*
+    local port_opt=$(echo $args | grep -oE '\-*p[^ ]* 7...')
+
+    $COLLIE cluster format $args
+    if [ $? != 0 ]; then
+	_die "failed to format cluster"
+    fi
+
+    # wait for all the sheeps to be running
+    local ports=$($COLLIE node list -r $port_opt | perl -ne 'print "$1\n" if /:(\d+)/')
+    local port
+    for port in $ports; do
+	local cnt
+	for cnt in `seq 10`; do # wait at most 10 seconds
+	    $COLLIE cluster info -p $port | grep -E running\|halt > /dev/null
+	    if [ $? == 0 ]; then
+		continue 2
+	    fi
+	    sleep 1
+	done
+	_die "sheepdog was not able to start"
+    done
+}
+
 _random()
 {
 	openssl enc -aes-128-cbc -pass pass:"$(date)" -nosalt < /dev/zero 2>/dev/null
-- 
1.7.9.5




More information about the sheepdog mailing list