[sheepdog] [PATCH v3 3/4] test: add test case for cache of http interface in sheepfs

Robin Dong robin.k.dong at gmail.com
Fri Mar 7 10:48:58 CET 2014


From: Robin Dong <sanbai at taobao.com>

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
v2-->v3:
  1. add header for PUT request

 tests/functional/089     | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/functional/089.out |  6 ++++
 tests/functional/group   |  1 +
 3 files changed, 89 insertions(+)
 create mode 100755 tests/functional/089
 create mode 100644 tests/functional/089.out

diff --git a/tests/functional/089 b/tests/functional/089
new file mode 100755
index 0000000..f114668
--- /dev/null
+++ b/tests/functional/089
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+# Test http interface of sheepfs
+
+. ./common
+
+trap "_uninit; exit \$status" 0 1 2 3 15
+_uninit()
+{
+	umount $STORE/sheepfs > /dev/null 2>&1
+	rm -rf $STORE/sheepfs > /dev/null 2>&1
+}
+
+_need_to_be_root
+
+which nginx > /dev/null || _notrun "Require nginx but it's not running"
+pkill nginx > /dev/null
+nginx -c `pwd`/nginx.conf
+
+for i in `seq 0 5`; do
+	_start_sheep $i "-r swift,port=800$i"
+done
+
+_wait_for_sheep 6
+
+_cluster_format -c 4:2
+
+curl -s -X PUT http://localhost/v1/sd -H 'Content-Length: 0'
+curl -s -X PUT http://localhost/v1/sd/sheep -H 'Content-Length: 0'
+
+for i in 4 19 97 137; do
+    _random | dd iflag=fullblock of=$STORE/data$i bs=1M count=$i &> /dev/null
+    dd if=$STORE/data$i 2> /dev/null | md5sum > $STORE/data$i.1
+done
+
+# upload the objects
+for i in 4 19 97 137; do
+	curl -s -T $STORE/data$i -X PUT http://localhost/v1/sd/sheep/data$i &
+done
+wait
+
+# mount objects in sheepfs
+mkdir -p $STORE/sheepfs
+$SHEEPFS $STORE/sheepfs/
+
+echo "localhost:83" > $STORE/sheepfs/http/address
+
+# mount objects
+for i in 4 19 97 137; do
+	echo "/sd/sheep/data$i" > $STORE/sheepfs/http/object
+done
+
+# read objects with 'cat'
+for i in 4 19 97 137; do
+	cat $STORE/sheepfs/http/sd/sheep/data$i | md5sum > $STORE/data$i.2 &
+done
+wait
+
+# read objects with 'dd'
+for i in 4 19 97 137; do
+	dd if=$STORE/sheepfs/http/sd/sheep/data$i bs=1345679 2> /dev/null | md5sum > $STORE/data$i.3 &
+done
+wait
+
+for i in 4 19 97 137; do
+	diff -u $STORE/data$i.1 $STORE/data$i.2
+	diff -u $STORE/data$i.1 $STORE/data$i.3
+done
+
+# read same objects with many processes
+for i in `seq 1 4`; do
+	dd if=$STORE/sheepfs/http/sd/sheep/data137 bs=134567 2> /dev/null | md5sum > $STORE/data$i.4 &
+done
+wait
+
+for i in `seq 1 4`; do
+	diff -u $STORE/data137.1 $STORE/data$i.4
+done
+
+_vdi_list
+
+status=0
diff --git a/tests/functional/089.out b/tests/functional/089.out
new file mode 100644
index 0000000..b0c7869
--- /dev/null
+++ b/tests/functional/089.out
@@ -0,0 +1,6 @@
+QA output created by 089
+using backend plain store
+  Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
+  sd           0   16 PB  4.0 MB  0.0 MB DATE   7927f2    4:2              
+  sd/sheep     0   16 PB   16 MB  0.0 MB DATE   8ad11e    4:2              
+  sd/sheep/allocator     0   16 PB  268 MB  0.0 MB DATE   fd57fc    4:2              
diff --git a/tests/functional/group b/tests/functional/group
index b073747..12879a6 100644
--- a/tests/functional/group
+++ b/tests/functional/group
@@ -102,4 +102,5 @@
 085 auto quick vdi md
 086 auto quick vdi md
 087 auto quick vdi md
+089 auto quick sheepfs
 088 auto quick cluster
-- 
1.7.12.4




More information about the sheepdog mailing list