File: 081

package info (click to toggle)
sheepdog 0.8.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,364 kB
  • ctags: 3,951
  • sloc: ansic: 30,552; sh: 3,573; perl: 2,924; asm: 453; makefile: 391; python: 192
file content (160 lines) | stat: -rwxr-xr-x 3,897 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash

# Test http service with a single server

. ./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
curl -s -X PUT http://localhost/v1/sd/dog

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
sheep_files=`find $SOURCE/sheep -name '*.c'`
dog_files=`find $SOURCE/dog -name '*.c'`

# upload the objects
for file in $sheep_files; do
	f=`basename $file`
	cat $file | md5sum > $STORE/sheep.$f.1
	cat $file | curl -s -T "-" -X PUT http://localhost/v1/sd/sheep/$f &
done

for file in $dog_files; do
	f=`basename $file`
	cat $file | md5sum > $STORE/dog.$f.1
	cat $file | curl -s -T "-" -X PUT http://localhost/v1/sd/dog/$f &
done

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

# list the container and objects
curl -s -X GET http://localhost/v1/sd | sort
curl -s -X GET http://localhost/v1/sd/sheep | sort
curl -s -X GET http://localhost/v1/sd/dog | sort

# download the objects
for file in $sheep_files; do
	f=`basename $file`
	curl -s -X GET http://localhost/v1/sd/sheep/$f | md5sum > $STORE/sheep.$f.2 &
done
for file in $dog_files; do
	f=`basename $file`
	curl -s -X GET http://localhost/v1/sd/dog/$f | md5sum > $STORE/dog.$f.2 &
done
for i in 4 19 97 137; do
	curl -s -X GET http://localhost/v1/sd/sheep/data$i | md5sum > $STORE/data$i.2 &
done
wait

# check the objects
for file in $sheep_files; do
	f=`basename $file`
	diff -u $STORE/sheep.$f.1 $STORE/sheep.$f.2
done
for file in $dog_files; do
	f=`basename $file`
	diff -u $STORE/dog.$f.1 $STORE/dog.$f.2
done
for i in 4 19 97 137; do
	diff -u $STORE/data$i.1 $STORE/data$i.2
done

# get object range and check
for i in 4 19 97 137; do
	j=`expr $i \* $i`
	curl -s --header "Range: bytes=${i}-${j}" -X GET http://localhost/v1/sd/sheep/data$i > $STORE/data$i.3 &
done
wait

for i in 4 19 97 137; do
	j=`expr $i \* $i`
	cnt=`expr $j - $i + 1`
	dd if=$STORE/data$i bs=1 skip=$i count=$cnt of=$STORE/data$i.4 2> /dev/null &
done
wait

for i in 4 19 97 137; do
	diff -u $STORE/data$i.3 $STORE/data$i.4
done
## check range 0 to $i
for i in 1 7 19 97 137; do
	curl -s --header "Range: bytes=0-${i}" -X GET http://localhost/v1/sd/sheep/data4 > $STORE/data$i.5 &
done
wait

for i in 1 7 19 97 137; do
	cnt=`expr $i + 1`
	dd if=$STORE/data4 bs=1 count=$cnt of=$STORE/data$i.6 2> /dev/null &
done
wait

for i in 1 7 19 97 137; do
	diff -u $STORE/data$i.5 $STORE/data$i.6
done
## check range $i to 'end of file'
for i in 1 7 19 97 137; do
	j=`expr $i + 4 \* 1048576`
	curl -s --header "Range: bytes=${i}-${j}" -X GET http://localhost/v1/sd/sheep/data4 > $STORE/data$i.7 &
done
wait

for i in 1 7 19 97 137; do
	cnt=`expr 4 \* 1048576`
	dd if=$STORE/data4 bs=1 skip=$i count=$cnt of=$STORE/data$i.8 2> /dev/null &
done
wait

for i in 1 7 19 97 137; do
	diff -u $STORE/data$i.7 $STORE/data$i.8
done
## check range which offset is already out of file
for i in 7 19 97; do
	j=`expr $i \* 1048576`
	k=`expr 137 \* 1048576`
	curl -s --header "Range: bytes=${j}-${k}" -X GET http://localhost/v1/sd/sheep/data4 -v 2>&1 |grep "< HTTP"
done
wait

_vdi_list

# delete the objects
for file in $sheep_files; do
	f=`basename $file`
	curl -s -X DELETE http://localhost/v1/sd/sheep/$f &
done
wait
curl -s -X GET http://localhost/v1/sd/sheep | sort

_vdi_list

for i in 4 19 97 137; do
	curl -s -X DELETE http://localhost/v1/sd/sheep/data$i &
done
wait

curl -s -X DELETE http://localhost/v1/sd/dog

curl -s -X GET http://localhost/v1/sd
curl -s -X GET http://localhost/v1/sd/sheep

_vdi_list