[sheepdog] [PATCH v3 6/8] tests: add a test 055 for md

Liu Yuan namei.unix at gmail.com
Wed Mar 27 10:11:34 CET 2013


From: Liu Yuan <tailai.ly at taobao.com>

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/md.c    |   13 +------------
 tests/055     |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/055.out |   24 ++++++++++++++++++++++++
 tests/group   |    1 +
 4 files changed, 72 insertions(+), 12 deletions(-)
 create mode 100755 tests/055
 create mode 100644 tests/055.out

diff --git a/sheep/md.c b/sheep/md.c
index b3177e0..5a55835 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -422,7 +422,7 @@ static int scan_wd(uint64_t oid)
 	return ret;
 }
 
-static bool md_handle_exist(uint64_t oid)
+bool md_exist(uint64_t oid)
 {
 	char path[PATH_MAX];
 
@@ -439,14 +439,3 @@ static bool md_handle_exist(uint64_t oid)
 
 	return false;
 }
-
-bool md_exist(uint64_t oid)
-{
-	char path[PATH_MAX];
-	if (!sys->enable_md) {
-		snprintf(path, PATH_MAX, "%s/%016" PRIx64, obj_path, oid);
-		return md_access(path);
-	}
-
-	return md_handle_exist(oid);
-}
diff --git a/tests/055 b/tests/055
new file mode 100755
index 0000000..7dc478f
--- /dev/null
+++ b/tests/055
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# Test md with single failure, multiple failure and all failure
+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 -c 2
+sleep 1
+$COLLIE vdi create test 200M -P
+
+# simulate one disk failure
+rm $STORE/0/d0 -rf
+dd if=/dev/urandom | $COLLIE vdi write test
+_wait_for_sheep_recovery 0
+$COLLIE vdi check test
+$COLLIE cluster info | _filter_cluster_info
+
+# simulate multiple disk failure
+rm $STORE/1/d0 -rf
+dd if=/dev/urandom | $COLLIE vdi write test &
+sleep 1
+rm $STORE/1/d1 -rf
+_wait_for_sheep_recovery 0
+wait
+$COLLIE vdi check test
+$COLLIE cluster info | _filter_cluster_info
+
+# simulate all disks failure
+rm $STORE/1/d2 -rf
+dd if=/dev/zero | $COLLIE vdi write test
+$COLLIE vdi check test
+$COLLIE cluster info | _filter_cluster_info
diff --git a/tests/055.out b/tests/055.out
new file mode 100644
index 0000000..284665a
--- /dev/null
+++ b/tests/055.out
@@ -0,0 +1,24 @@
+QA output created by 055
+using backend farm store
+finish check&repair test
+Cluster status: running
+
+Cluster created at DATE
+
+Epoch Time           Version
+DATE      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+finish check&repair test
+Cluster status: running
+
+Cluster created at DATE
+
+Epoch Time           Version
+DATE      1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002]
+finish check&repair test
+Cluster status: running
+
+Cluster created at DATE
+
+Epoch Time           Version
+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]
diff --git a/tests/group b/tests/group
index 2cfb41e..0dda9b8 100644
--- a/tests/group
+++ b/tests/group
@@ -68,3 +68,4 @@
 052 auto quick cluster md
 053 auto quick cluster md
 054 auto quick cluster md
+055 md
-- 
1.7.9.5




More information about the sheepdog mailing list