[sheepdog] [PATCH stable-0.6 10/22] functional: add wrapper _cluster_format

Hitoshi Mitake mitake.hitoshi at gmail.com
Mon Aug 12 16:55:14 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>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 tests/functional/001       |  3 +--
 tests/functional/002       |  3 +--
 tests/functional/003       |  3 +--
 tests/functional/004       |  2 +-
 tests/functional/005       |  3 +--
 tests/functional/006       |  3 +--
 tests/functional/007       |  4 ++--
 tests/functional/008       |  3 +--
 tests/functional/009       |  2 +-
 tests/functional/010       |  2 +-
 tests/functional/013       |  2 +-
 tests/functional/014       |  2 +-
 tests/functional/015       |  4 ++--
 tests/functional/016       |  2 +-
 tests/functional/017       |  2 +-
 tests/functional/018       |  2 +-
 tests/functional/019       |  2 +-
 tests/functional/020       |  2 +-
 tests/functional/021       |  2 +-
 tests/functional/022       |  2 +-
 tests/functional/024       |  3 +--
 tests/functional/025       |  2 +-
 tests/functional/026       |  2 +-
 tests/functional/027       |  2 +-
 tests/functional/028       |  2 +-
 tests/functional/029       |  2 +-
 tests/functional/030       |  4 ++--
 tests/functional/031       |  2 +-
 tests/functional/032       |  2 +-
 tests/functional/033       |  2 +-
 tests/functional/034       |  3 +--
 tests/functional/035       |  2 +-
 tests/functional/039       |  2 +-
 tests/functional/040       |  2 +-
 tests/functional/041       |  2 +-
 tests/functional/042       |  2 +-
 tests/functional/043       |  2 +-
 tests/functional/044       |  2 +-
 tests/functional/045       |  2 +-
 tests/functional/046       |  2 +-
 tests/functional/047       |  3 +--
 tests/functional/048       |  3 +--
 tests/functional/049       |  3 +--
 tests/functional/050       |  2 +-
 tests/functional/051       |  3 +--
 tests/functional/052       |  3 +--
 tests/functional/053       |  3 +--
 tests/functional/054       |  3 +--
 tests/functional/055       |  3 +--
 tests/functional/056       |  3 +--
 tests/functional/057       |  3 +--
 tests/functional/058       |  3 +--
 tests/functional/059       |  2 +-
 tests/functional/060       |  2 +-
 tests/functional/061       |  3 +--
 tests/functional/062       |  3 +--
 tests/functional/063       |  3 +--
 tests/functional/064       |  3 +--
 tests/functional/common.rc | 26 ++++++++++++++++++++++++++
 59 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/tests/functional/001 b/tests/functional/001
index 3f61d95..6cd0010 100755
--- a/tests/functional/001
+++ b/tests/functional/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/functional/002 b/tests/functional/002
index 13c48eb..572ab5b 100755
--- a/tests/functional/002
+++ b/tests/functional/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/functional/003 b/tests/functional/003
index 52c5e5f..5b3bdf5 100755
--- a/tests/functional/003
+++ b/tests/functional/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/functional/004 b/tests/functional/004
index 28e2f24..fa540f3 100755
--- a/tests/functional/004
+++ b/tests/functional/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/functional/005 b/tests/functional/005
index 3ed013d..a7786e9 100755
--- a/tests/functional/005
+++ b/tests/functional/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/functional/006 b/tests/functional/006
index c89676b..b670a44 100755
--- a/tests/functional/006
+++ b/tests/functional/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/functional/007 b/tests/functional/007
index 2af9254..16555e6 100755
--- a/tests/functional/007
+++ b/tests/functional/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/functional/008 b/tests/functional/008
index 1b78ecd..36078ce 100755
--- a/tests/functional/008
+++ b/tests/functional/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/functional/009 b/tests/functional/009
index c76bb5e..3d3142e 100755
--- a/tests/functional/009
+++ b/tests/functional/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/functional/010 b/tests/functional/010
index 6800c2e..25591f1 100755
--- a/tests/functional/010
+++ b/tests/functional/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/functional/013 b/tests/functional/013
index 27c4bac..76f62a8 100755
--- a/tests/functional/013
+++ b/tests/functional/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/functional/014 b/tests/functional/014
index 9f8b625..28167b7 100755
--- a/tests/functional/014
+++ b/tests/functional/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/functional/015 b/tests/functional/015
index d3bd1e3..d1de9d2 100755
--- a/tests/functional/015
+++ b/tests/functional/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/functional/016 b/tests/functional/016
index c10d9e1..378a82a 100755
--- a/tests/functional/016
+++ b/tests/functional/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/functional/017 b/tests/functional/017
index 2858e22..9093c63 100755
--- a/tests/functional/017
+++ b/tests/functional/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/functional/018 b/tests/functional/018
index aab6194..db87e4e 100755
--- a/tests/functional/018
+++ b/tests/functional/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/functional/019 b/tests/functional/019
index 351a1e9..8fbd8de 100755
--- a/tests/functional/019
+++ b/tests/functional/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/functional/020 b/tests/functional/020
index c5993f8..3b66b5f 100755
--- a/tests/functional/020
+++ b/tests/functional/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/functional/021 b/tests/functional/021
index f7c86c3..a23b353 100755
--- a/tests/functional/021
+++ b/tests/functional/021
@@ -21,4 +21,4 @@ done
 
 _wait_for_sheep "3"
 
-$COLLIE cluster format -c 3
+_cluster_format -c 3
diff --git a/tests/functional/022 b/tests/functional/022
index d7b4bfe..0084ac0 100755
--- a/tests/functional/022
+++ b/tests/functional/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/functional/024 b/tests/functional/024
index f8668f0..a8b03bc 100755
--- a/tests/functional/024
+++ b/tests/functional/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/functional/025 b/tests/functional/025
index 5f4259a..a7f7f4c 100755
--- a/tests/functional/025
+++ b/tests/functional/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/functional/026 b/tests/functional/026
index 9843e22..7cf5ad6 100755
--- a/tests/functional/026
+++ b/tests/functional/026
@@ -25,7 +25,7 @@ done
 
 _wait_for_sheep "8"
 
-$COLLIE cluster format
+_cluster_format
 
 # create new vdis
 (
diff --git a/tests/functional/027 b/tests/functional/027
index 05f4ab9..55dcda9 100755
--- a/tests/functional/027
+++ b/tests/functional/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/functional/028 b/tests/functional/028
index 53d4ecf..c704972 100755
--- a/tests/functional/028
+++ b/tests/functional/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/functional/029 b/tests/functional/029
index 3bec2ec..4d1e6ff 100755
--- a/tests/functional/029
+++ b/tests/functional/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/functional/030 b/tests/functional/030
index 62e78ec..5a34ba2 100755
--- a/tests/functional/030
+++ b/tests/functional/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/functional/031 b/tests/functional/031
index 61fde5b..467f468 100755
--- a/tests/functional/031
+++ b/tests/functional/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/functional/032 b/tests/functional/032
index 7887a1c..c2915dd 100755
--- a/tests/functional/032
+++ b/tests/functional/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/functional/033 b/tests/functional/033
index 28a5da6..e796d3e 100755
--- a/tests/functional/033
+++ b/tests/functional/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/functional/034 b/tests/functional/034
index be80633..9c5fb99 100755
--- a/tests/functional/034
+++ b/tests/functional/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/functional/035 b/tests/functional/035
index 090bd2f..bcc044a 100755
--- a/tests/functional/035
+++ b/tests/functional/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/functional/039 b/tests/functional/039
index 55bd65d..d88ea70 100755
--- a/tests/functional/039
+++ b/tests/functional/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/functional/040 b/tests/functional/040
index f471500..9eb9351 100755
--- a/tests/functional/040
+++ b/tests/functional/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/functional/041 b/tests/functional/041
index ddcb43d..0ca29f7 100755
--- a/tests/functional/041
+++ b/tests/functional/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/functional/042 b/tests/functional/042
index 9680985..1fc8e88 100755
--- a/tests/functional/042
+++ b/tests/functional/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/functional/043 b/tests/functional/043
index ff6b7cc..0d26638 100755
--- a/tests/functional/043
+++ b/tests/functional/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/functional/044 b/tests/functional/044
index 6dcf099..ce949ae 100755
--- a/tests/functional/044
+++ b/tests/functional/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/functional/045 b/tests/functional/045
index 796cb84..d30e636 100755
--- a/tests/functional/045
+++ b/tests/functional/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/functional/046 b/tests/functional/046
index 01a8379..33ff0d5 100755
--- a/tests/functional/046
+++ b/tests/functional/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/functional/047 b/tests/functional/047
index f2963a1..e7309da 100755
--- a/tests/functional/047
+++ b/tests/functional/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/functional/048 b/tests/functional/048
index 37118b8..465d4e9 100755
--- a/tests/functional/048
+++ b/tests/functional/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/functional/049 b/tests/functional/049
index b27be1a..95fa6e2 100755
--- a/tests/functional/049
+++ b/tests/functional/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/functional/050 b/tests/functional/050
index 76eccdd..9a94649 100755
--- a/tests/functional/050
+++ b/tests/functional/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/functional/051 b/tests/functional/051
index 5c5f385..799fe70 100755
--- a/tests/functional/051
+++ b/tests/functional/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/functional/052 b/tests/functional/052
index 1954737..ae0834a 100755
--- a/tests/functional/052
+++ b/tests/functional/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/functional/053 b/tests/functional/053
index d9c1d71..41331da 100755
--- a/tests/functional/053
+++ b/tests/functional/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/functional/054 b/tests/functional/054
index 0649021..54b8df7 100755
--- a/tests/functional/054
+++ b/tests/functional/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/functional/055 b/tests/functional/055
index 4a2a462..5a87f27 100755
--- a/tests/functional/055
+++ b/tests/functional/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/functional/056 b/tests/functional/056
index f6ad00b..b89c888 100755
--- a/tests/functional/056
+++ b/tests/functional/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/functional/057 b/tests/functional/057
index ee95589..3c23e51 100755
--- a/tests/functional/057
+++ b/tests/functional/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/functional/058 b/tests/functional/058
index bda659c..3bbb789 100755
--- a/tests/functional/058
+++ b/tests/functional/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/functional/059 b/tests/functional/059
index d818fcc..6b34d39 100755
--- a/tests/functional/059
+++ b/tests/functional/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/functional/060 b/tests/functional/060
index e9f51ea..7683285 100755
--- a/tests/functional/060
+++ b/tests/functional/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/functional/061 b/tests/functional/061
index c1488bd..1cd0391 100755
--- a/tests/functional/061
+++ b/tests/functional/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/functional/062 b/tests/functional/062
index 0292b1d..0fe16b0 100755
--- a/tests/functional/062
+++ b/tests/functional/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/functional/063 b/tests/functional/063
index deec2d5..2d687df 100755
--- a/tests/functional/063
+++ b/tests/functional/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/functional/064 b/tests/functional/064
index e1ff9d0..f6a294a 100755
--- a/tests/functional/064
+++ b/tests/functional/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/functional/common.rc b/tests/functional/common.rc
index 7d79dff..88f4c24 100644
--- a/tests/functional/common.rc
+++ b/tests/functional/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.8.1.2




More information about the sheepdog mailing list