[sheepdog] [PATCH 4/4] tests: add tests/065 for testing rejoin cluster

Kai Zhang kyle at zelin.io
Fri Jun 14 03:46:38 CEST 2013


Signed-off-by: Kai Zhang <kyle at zelin.io>
---
 tests/065       |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/065.out   |   38 ++++++++++++++++++++++++++++++++++++++
 tests/common.rc |   15 +++++++++++++++
 tests/group     |    1 +
 4 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100755 tests/065
 create mode 100644 tests/065.out

diff --git a/tests/065 b/tests/065
new file mode 100755
index 0000000..a6699ec
--- /dev/null
+++ b/tests/065
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# Test rejoin cluster
+
+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 0 1 2; do
+    _start_sheep $i
+done
+
+_wait_for_sheep 3
+
+$COLLIE cluster format
+sleep 1
+
+# kill a non-master sheep
+_kill_zk_session 1
+
+# wait for rejoin
+sleep 5
+
+# kill a master
+_kill_zk_session 0
+
+# wait for rejoin
+sleep 5
+
+for i in 0 1 2; do
+    $COLLIE cluster info -p 700$i | _filter_cluster_info
+done
+
+$COLLIE vdi create test 10M
+for i in 0 1 2; do
+    $COLLIE vdi list | _filter_short_date
+done
diff --git a/tests/065.out b/tests/065.out
new file mode 100644
index 0000000..1b2ef48
--- /dev/null
+++ b/tests/065.out
@@ -0,0 +1,38 @@
+QA output created by 065
+using backend plain store
+Cluster status: running, auto-recovery enabled
+
+Cluster created at DATE
+
+Epoch Time           Version
+DATE      5 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+DATE      4 [127.0.0.1:7001, 127.0.0.1:7002]
+DATE      3 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+DATE      2 [127.0.0.1:7000, 127.0.0.1:7002]
+DATE      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+Cluster status: running, auto-recovery enabled
+
+Cluster created at DATE
+
+Epoch Time           Version
+DATE      5 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+DATE      4 [127.0.0.1:7001, 127.0.0.1:7002]
+DATE      3 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+DATE      2 [127.0.0.1:7000, 127.0.0.1:7002]
+DATE      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+Cluster status: running, auto-recovery enabled
+
+Cluster created at DATE
+
+Epoch Time           Version
+DATE      5 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+DATE      4 [127.0.0.1:7001, 127.0.0.1:7002]
+DATE      3 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+DATE      2 [127.0.0.1:7000, 127.0.0.1:7002]
+DATE      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+  Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
+  test         0   10 MB  0.0 MB  0.0 MB DATE   7c2b25     3              
+  Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
+  test         0   10 MB  0.0 MB  0.0 MB DATE   7c2b25     3              
+  Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
+  test         0   10 MB  0.0 MB  0.0 MB DATE   7c2b25     3              
diff --git a/tests/common.rc b/tests/common.rc
index 7d79dff..14f046a 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -438,5 +438,20 @@ _random()
 	openssl enc -aes-128-cbc -pass pass:"$(date)" -nosalt < /dev/zero 2>/dev/null
 }
 
+_kill_zk_session()
+{
+	local path="/sheepdog/member/IPv4 ip:127.0.0.1 port:700$1"
+	if [[ "$DRIVER" == zoo* ]]; then
+		../tools/kill_zk_session "$path"
+		if [ $? -ne 0 ]; then
+			_die "failed to kill session"
+		fi
+	else
+		_kill_sheep $1
+		_wait_for_sheep_stop $1
+		_start_sheep $1
+	fi
+}
+
 # make sure this script returns success
 /bin/true
diff --git a/tests/group b/tests/group
index 73ab542..42f6f7d 100644
--- a/tests/group
+++ b/tests/group
@@ -78,3 +78,4 @@
 062 auto quick cluster md
 063 auto quick cluster
 064 auto quick cluster
+065 auto quick cluster
-- 
1.7.1




More information about the sheepdog mailing list