[sheepdog] [PATCH 2/3] tests/functional: allow calling _wait_for_sheep() after _kill_sheep()
MORITA Kazutaka
morita.kazutaka at gmail.com
Thu Jun 27 07:11:31 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
This can remove a lot of sleep and avoid a false alarm which happens
due to timing problems.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
tests/functional/001 | 7 ++++---
tests/functional/002 | 4 +++-
tests/functional/003 | 4 +++-
tests/functional/004 | 8 +++++---
tests/functional/005 | 5 +++--
tests/functional/007 | 2 +-
tests/functional/010 | 4 ++--
tests/functional/025 | 2 +-
tests/functional/026 | 19 +++++--------------
tests/functional/033 | 8 +++++---
tests/functional/034 | 5 ++++-
tests/functional/048 | 5 +++--
tests/functional/056 | 2 +-
tests/functional/common.rc | 3 ---
14 files changed, 40 insertions(+), 38 deletions(-)
diff --git a/tests/functional/001 b/tests/functional/001
index 6cd0010..2c3fbdb 100755
--- a/tests/functional/001
+++ b/tests/functional/001
@@ -26,16 +26,17 @@ _cluster_format
# kill the master node
_kill_sheep 0
-sleep 1
+_wait_for_sheep 1 1
# start another sheep
_start_sheep 2
-_wait_for_sheep 2 2
# kill all sheeps
+nr=2
for i in 1 2; do
+ _wait_for_sheep $nr $i
_kill_sheep $i
- sleep 1
+ nr=$(($nr - 1))
done
for i in 0 1 2; do
diff --git a/tests/functional/002 b/tests/functional/002
index 572ab5b..67227c9 100755
--- a/tests/functional/002
+++ b/tests/functional/002
@@ -25,9 +25,11 @@ _wait_for_sheep 3
_cluster_format
# kill all sheeps
+nr=3
for i in 0 1 2; do
+ _wait_for_sheep $nr $i
_kill_sheep $i
- sleep 1
+ nr=$(($nr - 1))
done
# master transfer will happen once
diff --git a/tests/functional/003 b/tests/functional/003
index 5b3bdf5..05522fe 100755
--- a/tests/functional/003
+++ b/tests/functional/003
@@ -24,9 +24,11 @@ _wait_for_sheep 3
_cluster_format
# kill all sheeps
+nr=3
for i in 0 1 2; do
+ _wait_for_sheep $nr $i
_kill_sheep $i
- sleep 3
+ nr=$(($nr - 1))
done
# master transfer will happen twice
diff --git a/tests/functional/004 b/tests/functional/004
index fa540f3..240884d 100755
--- a/tests/functional/004
+++ b/tests/functional/004
@@ -25,17 +25,19 @@ _cluster_format -c 2
for i in 2 3 4; do
# add one node after killing existing one node
+ _wait_for_sheep 2 $((i - 2))
_kill_sheep $((i - 2))
- sleep 1
+ _wait_for_sheep 1 $((i - 1))
_start_sheep $i
- sleep 2
done
# kill all existing nodes
+nr=2
for i in 3 4; do
+ _wait_for_sheep $nr $i
_kill_sheep $i
- sleep 1
+ nr=$(($nr - 1))
done
for i in 0 1 2 3 4; do
diff --git a/tests/functional/005 b/tests/functional/005
index a7786e9..1e70669 100755
--- a/tests/functional/005
+++ b/tests/functional/005
@@ -24,10 +24,11 @@ _wait_for_sheep 2
_cluster_format -c 1
for i in 2 3 4; do
+ _wait_for_sheep 2 $((i - 2))
_kill_sheep $((i - 2))
- sleep 1
+ _wait_for_sheep 1 $((i - 1))
+
_start_sheep $i
- sleep 2
done
_wait_for_sheep 2 4
diff --git a/tests/functional/007 b/tests/functional/007
index 16555e6..1cc7763 100755
--- a/tests/functional/007
+++ b/tests/functional/007
@@ -42,7 +42,7 @@ for i in `seq 0 5`; do
fi
_kill_sheep 2
- sleep 1
+ _wait_for_sheep 1
done
echo "success"
diff --git a/tests/functional/010 b/tests/functional/010
index 25591f1..3dbcd92 100755
--- a/tests/functional/010
+++ b/tests/functional/010
@@ -36,7 +36,7 @@ ls $STORE/*/obj/* | _filter_store | sort
_kill_sheep 3
_kill_sheep 4
-sleep 2
+_wait_for_sheep 3
$COLLIE cluster info | head -6 | _filter_cluster_info
ls $STORE/*/obj/* | _filter_store | sort
@@ -60,7 +60,7 @@ for i in `seq 3 7`; do
done
_wait_for_sheep 8
-sleep 2
+
$COLLIE cluster info | head -6 | _filter_cluster_info
ls $STORE/*/obj/* | _filter_store | sort
diff --git a/tests/functional/025 b/tests/functional/025
index a7f7f4c..b1e9c52 100755
--- a/tests/functional/025
+++ b/tests/functional/025
@@ -47,7 +47,7 @@ for i in `seq 3 3`; do
$SHEEP $STORE/$i -d -z 2 -p 700$i -c $DRIVER -y 127.0.0.1
done
-sleep 10
+_wait_for_sheep 4
echo "check that all sheep are alive"
for i in `seq 0 3`; do
diff --git a/tests/functional/026 b/tests/functional/026
index 7cf5ad6..3bce862 100755
--- a/tests/functional/026
+++ b/tests/functional/026
@@ -36,27 +36,18 @@ done
# kill nodes and join them back
for i in 1 2; do _kill_sheep $i;done
-sleep 3
+_wait_for_sheep 6
_wait_for_sheep_recovery 0
for i in 3 4; do _kill_sheep $i;done
-sleep 3
+_wait_for_sheep 4
_wait_for_sheep_recovery 0
for i in 5; do _kill_sheep $i;done
-sleep 3
+_wait_for_sheep 3
_wait_for_sheep_recovery 0
for i in `seq 1 5`; do _start_sheep $i;done
+_wait_for_sheep 8
# wait for collie to finish
wait
-# wait vdi create to completion
-while true; do
- nr1=`$COLLIE vdi list | wc -l`
- sleep 3
- nr2=`$COLLIE vdi list | wc -l`
- if [ $nr1 -eq $nr2 ]; then
- break;
- fi
-done
-
-echo $nr1
+echo `$COLLIE vdi list | wc -l`
diff --git a/tests/functional/033 b/tests/functional/033
index e796d3e..5a85165 100755
--- a/tests/functional/033
+++ b/tests/functional/033
@@ -35,14 +35,16 @@ $COLLIE vdi read test | md5sum
for i in 7 6 5; do
_kill_sheep $i
done
-sleep 1 # this is necessary to avoid network partition detection
+# this is necessary to avoid network partition detection
+nr=5
for i in 4 3 2 1; do
+ _wait_for_sheep $nr $i
_kill_sheep $i
- sleep 1
+ nr=$(($nr - 1))
done
# make sheep 0 master to avoid master transfer
-sleep 1
+_wait_for_sheep 1
_kill_sheep 0
sleep 1
diff --git a/tests/functional/034 b/tests/functional/034
index 9c5fb99..1f10e69 100755
--- a/tests/functional/034
+++ b/tests/functional/034
@@ -35,11 +35,14 @@ for i in `seq 0 24`; do
done
# kill 5 nodes
+nr=8
for i in `seq 3 7`; do
+ _wait_for_sheep $nr
_wait_for_sheep_recovery 0
_kill_sheep $i
- sleep 3
+ nr=$(($nr - 1))
done
+_wait_for_sheep 3
# update vdi
for i in `seq 0 24`; do
diff --git a/tests/functional/048 b/tests/functional/048
index 465d4e9..82e1235 100755
--- a/tests/functional/048
+++ b/tests/functional/048
@@ -32,11 +32,12 @@ sleep 2
_wait_for_sheep_recovery 1
$COLLIE node list -p 7001
+nr=2
for i in 3 4 0; do
_start_sheep $i
- sleep 2
+ nr=$(($nr + 1))
+ _wait_for_sheep $nr $i
done
-_wait_for_sheep 5
_wait_for_sheep_recovery 0
$COLLIE vdi track test
diff --git a/tests/functional/056 b/tests/functional/056
index b89c888..0881646 100755
--- a/tests/functional/056
+++ b/tests/functional/056
@@ -40,7 +40,7 @@ _safe_remove $STORE/1/d0
dd if=/dev/zero | $COLLIE vdi write test &
sleep 1
_kill_sheep 2
-sleep 1
+_wait_for_sheep 3
_safe_remove $STORE/1/d1
_wait_for_sheep_recovery 0
wait # collie
diff --git a/tests/functional/common.rc b/tests/functional/common.rc
index 2fb3da4..036c193 100644
--- a/tests/functional/common.rc
+++ b/tests/functional/common.rc
@@ -213,9 +213,6 @@ _wait_for_sheep()
if [ ${nr_sheep} -eq $1 ]; then
break
fi
- if [ ${nr_sheep} -gt $1 ]; then
- _die "ERROR: too many sheep in cluster: ${nr_sheep}, expect: $1"
- fi
sleep 1
done
}
--
1.7.9.5
More information about the sheepdog
mailing list