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

Kai Zhang kyle at zelin.io
Tue Jun 18 08:15:18 CEST 2013


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

diff --git a/tests/functional/065 b/tests/functional/065
new file mode 100755
index 0000000..a6699ec
--- /dev/null
+++ b/tests/functional/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/functional/065.out b/tests/functional/065.out
new file mode 100644
index 0000000..1b2ef48
--- /dev/null
+++ b/tests/functional/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/functional/common.rc b/tests/functional/common.rc
index 88f4c24..4fa7076 100644
--- a/tests/functional/common.rc
+++ b/tests/functional/common.rc
@@ -464,5 +464,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/functional/group b/tests/functional/group
index 73ab542..42f6f7d 100644
--- a/tests/functional/group
+++ b/tests/functional/group
@@ -78,3 +78,4 @@
 062 auto quick cluster md
 063 auto quick cluster
 064 auto quick cluster
+065 auto quick cluster
-- 
1.7.9.5




More information about the sheepdog mailing list