[sheepdog] [PATCH 3/3] test: add tests for object cache

Liu Yuan namei.unix at gmail.com
Tue Aug 14 10:20:11 CEST 2012


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

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c |    2 +-
 tests/018     |   38 ++++++++++++++++++++++++++++++++++++++
 tests/018.out |    2 ++
 tests/019     |   36 ++++++++++++++++++++++++++++++++++++
 tests/019.out |    2 ++
 tests/020     |   34 ++++++++++++++++++++++++++++++++++
 tests/020.out |    2 ++
 tests/group   |    3 +++
 8 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100755 tests/018
 create mode 100644 tests/018.out
 create mode 100755 tests/019
 create mode 100644 tests/019.out
 create mode 100755 tests/020
 create mode 100644 tests/020.out

diff --git a/sheep/sheep.c b/sheep/sheep.c
index c743184..b10197e 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -280,7 +280,7 @@ int main(int argc, char **argv)
 			    strcmp(object_cache_mode, "writeback") != 0) {
 				sys->writethrough = 1;
 			}
-			vprintf(SDOG_INFO, "enable write cache, "
+			fprintf(stdout, "enable write cache, "
 				"max cache size %" PRIu64 "M, %s mode\n",
 				cache_size, sys->writethrough ?
 				"writethrough" : "writeback");
diff --git a/tests/018 b/tests/018
new file mode 100755
index 0000000..00d6ee5
--- /dev/null
+++ b/tests/018
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+# Test object cache writeback mode
+
+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 2`; do
+    $SHEEP $STORE/$i -w 100,writeback -z $i -p 700$i -c $DRIVER
+done
+
+_wait_for_sheep "3"
+
+$COLLIE cluster format -c 2
+
+$COLLIE vdi create test 4M
+
+dd if=/dev/urandom | $COLLIE vdi write -C test
+
+$COLLIE vdi flush test
+
+for port in `seq 0 2`; do
+    $COLLIE vdi read test -p 700$port | md5sum > /tmp/csum.$port
+done
+
+for port in `seq 1 2`; do
+    diff -u /tmp/csum.0 /tmp/csum.$port
+done
diff --git a/tests/018.out b/tests/018.out
new file mode 100644
index 0000000..5135743
--- /dev/null
+++ b/tests/018.out
@@ -0,0 +1,2 @@
+QA output created by 018
+using backend farm store
diff --git a/tests/019 b/tests/019
new file mode 100755
index 0000000..e6556ec
--- /dev/null
+++ b/tests/019
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Test object cache writethrough mode
+
+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 2`; do
+    $SHEEP $STORE/$i -w 100 -z $i -p 700$i -c $DRIVER
+done
+
+_wait_for_sheep "3"
+
+$COLLIE cluster format -c 2
+
+$COLLIE vdi create test 4M
+
+dd if=/dev/urandom | $COLLIE vdi write -C test
+
+for port in `seq 0 2`; do
+    $COLLIE vdi read test -p 700$port | md5sum > /tmp/csum.$port
+done
+
+for port in `seq 1 2`; do
+    diff -u /tmp/csum.0 /tmp/csum.$port
+done
diff --git a/tests/019.out b/tests/019.out
new file mode 100644
index 0000000..98ba52a
--- /dev/null
+++ b/tests/019.out
@@ -0,0 +1,2 @@
+QA output created by 019
+using backend farm store
diff --git a/tests/020 b/tests/020
new file mode 100755
index 0000000..242dab8
--- /dev/null
+++ b/tests/020
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# Test object cache reclaim
+
+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 2`; do
+    $SHEEP $STORE/$i -d -w 20 -z $i -p 700$i -c $DRIVER
+done
+
+_wait_for_sheep "3"
+
+$COLLIE cluster format -c 2
+
+$COLLIE vdi create test 40M
+
+dd if=/dev/urandom | $COLLIE vdi write -C test
+
+# check cache size, should be 20 * 80%
+nr=`ls /tmp/sheepdog/0/cache/7c2b25 | wc -l`
+if [ $nr -gt 4 ]; then
+    echo "reclaim failed"
+fi
diff --git a/tests/020.out b/tests/020.out
new file mode 100644
index 0000000..b6765d0
--- /dev/null
+++ b/tests/020.out
@@ -0,0 +1,2 @@
+QA output created by 020
+using backend farm store
diff --git a/tests/group b/tests/group
index 6cd2e04..e1e9da6 100644
--- a/tests/group
+++ b/tests/group
@@ -29,3 +29,6 @@
 015 auto quick vdi
 016 auto quick vdi
 017 auto quick vdi
+018 auto quick cache
+019 auto quick cache
+020 auto quick cache
-- 
1.7.10.2




More information about the sheepdog mailing list