[sheepdog] [PATCH v3 6/6] tests: add test case for new kv_create_object() implemention

Robin Dong robin.k.dong at gmail.com
Tue Feb 25 08:59:31 CET 2014


From: Robin Dong <sanbai at taobao.com>

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 tests/functional/087        | 102 ++++++++++++++++++++++++++++++++++++++++++++
 tests/functional/087.out    |  32 ++++++++++++++
 tests/functional/group      |   1 +
 tests/functional/nginx.conf |   6 +++
 4 files changed, 141 insertions(+)
 create mode 100755 tests/functional/087
 create mode 100644 tests/functional/087.out

diff --git a/tests/functional/087 b/tests/functional/087
new file mode 100755
index 0000000..ce95a1e
--- /dev/null
+++ b/tests/functional/087
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+# Test http service with Incompleted-objects
+
+. ./common
+
+_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
+curl -s -X PUT http://localhost/v1/sd/sheep
+
+_random | dd iflag=fullblock of=$STORE/data_ bs=4M count=48 &> /dev/null
+dd if=$STORE/data_ bs=4M count=48 2> /dev/null | md5sum > $STORE/data_.ck
+
+# upload objects with different names and kill them suddenly
+
+for i in `seq 4 5`; do
+       port=8$(($i % 6))
+       curl -s -T $STORE/data_ -X PUT http://localhost:$port/v1/sd/sheep/data$i &> /dev/null &
+done
+sleep 2
+pkill -9 "curl -s -T" > /dev/null
+
+# get incomplete-objects
+for i in `seq 4 5`; do
+       port=8$(($i % 6))
+       curl -s -I -X GET http://localhost:$port/v1/sd/sheep/data$i > $STORE/data$i.2 &
+done
+wait
+
+for i in `seq 4 5`; do
+	grep HTTP $STORE/data$i.2|awk '{print $2}'
+done
+
+_vdi_list
+
+for i in `seq 0 5`; do
+       port=8$(($i % 6))
+       curl -s -X DELETE http://localhost:$port/v1/sd/sheep/data$i &
+done
+wait
+
+_vdi_list
+
+# upload objects with same name
+for i in `seq 0 5`; do
+       port=8$(($i % 6))
+       curl -s -T $STORE/data_ -X PUT http://localhost:$port/v1/sd/sheep/data_ -v &> $STORE/data$i.3 &
+done
+wait
+
+for i in `seq 0 5`; do
+	grep "HTTP/1.1 409" $STORE/data$i.3|awk '{print $3}'
+done
+
+curl -s -X GET http://localhost/v1/sd/sheep
+curl -s -X GET http://localhost/v1/sd/sheep/data_ | md5sum >$STORE/data_download.ck
+
+diff -u $STORE/data_.ck $STORE/data_download.ck
+
+curl -s -X DELETE http://localhost/v1/sd/sheep/data_
+
+_vdi_list
+
+# create and delete simultaneously
+curl -s -T $STORE/data_ -X PUT http://localhost:80/v1/sd/sheep/data_ -v &> $STORE/data1.4 &
+sleep 1
+curl -s -X DELETE http://localhost:81/v1/sd/sheep/data_ -v &> $STORE/data2.4
+
+grep "HTTP/1.1 409" $STORE/data2.4|awk '{print $3}'
+wait
+
+_vdi_list
+
+curl -s -X DELETE http://localhost/v1/sd/sheep/data_
+
+# only DELETE with HEADER 'Forced: true' can remove "Incomplete" object
+curl -s -T $STORE/data_ -X PUT http://localhost:80/v1/sd/sheep/data_ &> /dev/null &
+sleep 1
+pkill -9 "curl -s -T" > /dev/null
+
+curl -s -X DELETE http://localhost/v1/sd/sheep/data_ -v &> $STORE/data1.5
+
+grep "HTTP/1.1 409" $STORE/data1.5|awk '{print $3}'
+
+curl -s -X DELETE -H 'Forced: true' http://localhost/v1/sd/sheep/data_ -v &> $STORE/data2.5
+
+grep "HTTP/1.1 409" $STORE/data2.5|awk '{print $3}'
+
+_vdi_list
diff --git a/tests/functional/087.out b/tests/functional/087.out
new file mode 100644
index 0000000..04e4210
--- /dev/null
+++ b/tests/functional/087.out
@@ -0,0 +1,32 @@
+QA output created by 087
+using backend plain store
+206
+206
+  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  8.0 MB  0.0 MB DATE   8ad11e    4:2              
+  sd/sheep/allocator     0   16 PB  388 MB  0.0 MB DATE   fd57fc    4:2              
+  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  8.0 MB  0.0 MB DATE   8ad11e    4:2              
+  sd/sheep/allocator     0   16 PB  4.0 MB  0.0 MB DATE   fd57fc    4:2              
+409
+409
+409
+409
+409
+data_
+  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   12 MB  0.0 MB DATE   8ad11e    4:2              
+  sd/sheep/allocator     0   16 PB  4.0 MB  0.0 MB DATE   fd57fc    4:2              
+409
+  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   12 MB  0.0 MB DATE   8ad11e    4:2              
+  sd/sheep/allocator     0   16 PB  196 MB  0.0 MB DATE   fd57fc    4:2              
+409
+  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   12 MB  0.0 MB DATE   8ad11e    4:2              
+  sd/sheep/allocator     0   16 PB  4.0 MB  0.0 MB DATE   fd57fc    4:2              
diff --git a/tests/functional/group b/tests/functional/group
index 13306d9..0c9b71a 100644
--- a/tests/functional/group
+++ b/tests/functional/group
@@ -101,3 +101,4 @@
 084 auto quick sheepfs
 085 auto quick vdi md
 086 auto quick vdi md
+087 auto quick vdi md
diff --git a/tests/functional/nginx.conf b/tests/functional/nginx.conf
index 46b4a73..68e719c 100644
--- a/tests/functional/nginx.conf
+++ b/tests/functional/nginx.conf
@@ -16,6 +16,7 @@ http {
 			fastcgi_param	HTTP_RANGE		$http_range;
 			fastcgi_param	DOCUMENT_URI		$document_uri;
 			fastcgi_param	REQUEST_URI		$request_uri;
+			fastcgi_param   FORCED			$http_FORCED;
 		}
 	}
 	server {
@@ -31,6 +32,7 @@ http {
 			fastcgi_param	HTTP_RANGE		$http_range;
 			fastcgi_param	DOCUMENT_URI		$document_uri;
 			fastcgi_param	REQUEST_URI		$request_uri;
+			fastcgi_param   FORCED			$http_FORCED;
 		}
 	}
 	server {
@@ -46,6 +48,7 @@ http {
 			fastcgi_param	HTTP_RANGE		$http_range;
 			fastcgi_param	DOCUMENT_URI		$document_uri;
 			fastcgi_param	REQUEST_URI		$request_uri;
+			fastcgi_param   FORCED			$http_FORCED;
 		}
 	}
 	server {
@@ -61,6 +64,7 @@ http {
 			fastcgi_param	HTTP_RANGE		$http_range;
 			fastcgi_param	DOCUMENT_URI		$document_uri;
 			fastcgi_param	REQUEST_URI		$request_uri;
+			fastcgi_param   FORCED			$http_FORCED;
 		}
 	}
 	server {
@@ -76,6 +80,7 @@ http {
 			fastcgi_param	HTTP_RANGE		$http_range;
 			fastcgi_param	DOCUMENT_URI		$document_uri;
 			fastcgi_param	REQUEST_URI		$request_uri;
+			fastcgi_param   FORCED			$http_FORCED;
 		}
 	}
 	server {
@@ -91,6 +96,7 @@ http {
 			fastcgi_param	HTTP_RANGE		$http_range;
 			fastcgi_param	DOCUMENT_URI		$document_uri;
 			fastcgi_param	REQUEST_URI		$request_uri;
+			fastcgi_param   FORCED			$http_FORCED;
 		}
 	}
 	client_max_body_size 0;
-- 
1.7.12.4




More information about the sheepdog mailing list