[sheepdog] [PATCH] test: add test for recovery logic
Liu Yuan
namei.unix at gmail.com
Tue Aug 21 16:39:38 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
tests/027 | 33 +++++++++++++++++++++++++++++++++
tests/027.out | 5 +++++
tests/common.rc | 10 ++++++++++
tests/group | 1 +
4 files changed, 49 insertions(+), 0 deletions(-)
create mode 100755 tests/027
create mode 100644 tests/027.out
diff --git a/tests/027 b/tests/027
new file mode 100755
index 0000000..456c0f7
--- /dev/null
+++ b/tests/027
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# Test sheep recovery logic
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_cleanup
+
+for i in `seq 0 3`; do
+ _start_sheep $i
+done
+
+_wait_for_sheep "4"
+
+$COLLIE cluster format -c 2
+
+$COLLIE vdi create test0 40M
+$COLLIE vdi create test1 40M
+
+_kill_sheep 3
+
+_wait_for_sheep_recovery 0
+
+find $STORE -name '80fd32fc00000000'
diff --git a/tests/027.out b/tests/027.out
new file mode 100644
index 0000000..f9887b5
--- /dev/null
+++ b/tests/027.out
@@ -0,0 +1,5 @@
+QA output created by 027
+using backend farm store
+/tmp/sheepdog/0/obj/80fd32fc00000000
+/tmp/sheepdog/3/obj/80fd32fc00000000
+/tmp/sheepdog/1/obj/80fd32fc00000000
diff --git a/tests/common.rc b/tests/common.rc
index 64182c6..7ede163 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -169,5 +169,15 @@ _kill_sheep()
pkill -f "$SHEEP $STORE/$1"
}
+_wait_for_sheep_recovery()
+{
+ while true; do
+ sleep 2
+ if [ $($COLLIE node recovery -p $((7000+$1)) | wc -l) -eq 2 ]; then
+ break
+ fi
+ done
+}
+
# make sure this script returns success
/bin/true
diff --git a/tests/group b/tests/group
index aaa1ab6..57edea5 100644
--- a/tests/group
+++ b/tests/group
@@ -38,3 +38,4 @@
024 auto quick cluster
025 auto quick cluster
026 auto quick vdi
+027 auto quick store
--
1.7.1
More information about the sheepdog
mailing list