|
0 |
Author: Serafeim Zanikolas <serzan@hellug.gr>
|
|
1 |
Forwarded: http://groups.google.com/group/beanstalk-talk/browse_thread/thread/badb729887f4f4d
|
|
2 |
Last-Update: 2010-02-21
|
|
3 |
|
|
4 |
--- beanstalkd-1.4.3.orig/check.sh
|
|
5 |
+++ beanstalkd-1.4.3/check.sh
|
|
6 |
@@ -1,5 +1,12 @@
|
|
7 |
#!/bin/bash
|
|
8 |
|
|
9 |
+if /sbin/ifconfig | egrep -q '^lo[[:space:]]+Link'; then
|
|
10 |
+ echo "loopback interface is configured, getting on with tests"
|
|
11 |
+else
|
|
12 |
+ echo "loopback interface is NOT configured, won't run tests"
|
|
13 |
+ exit 0
|
|
14 |
+fi
|
|
15 |
+
|
|
16 |
one="$(dirname "$0")/check-one.sh"
|
|
17 |
|
|
18 |
for commands in "$@"; do
|
|
19 |
--- beanstalkd-1.4.3.orig/check-one.sh
|
|
20 |
+++ beanstalkd-1.4.3/check-one.sh
|
|
21 |
@@ -1,7 +1,8 @@
|
|
22 |
-#!/bin/sh
|
|
23 |
+#!/bin/bash
|
|
24 |
+
|
|
25 |
+. sh-tests/common.functions
|
|
26 |
|
|
27 |
server=localhost
|
|
28 |
-port=11400
|
|
29 |
tmpdir="$TMPDIR"
|
|
30 |
test -z "$tmpdir" && tmpdir=/tmp
|
|
31 |
tmpf="${tmpdir}/bnch$$"
|
|
32 |
@@ -34,14 +35,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
33 |
exit 2
|
|
34 |
fi
|
|
35 |
|
|
36 |
-./beanstalkd -p $port >/dev/null 2>/dev/null &
|
|
37 |
-bpid=$!
|
|
38 |
-
|
|
39 |
-sleep .1
|
|
40 |
-if ! ps -p $bpid >/dev/null; then
|
|
41 |
- echo "Could not start beanstalkd for testing, port $port is taken"
|
|
42 |
- exit 2
|
|
43 |
-fi
|
|
44 |
+start_beanstalkd
|
|
45 |
|
|
46 |
# Run the test
|
|
47 |
fgrep -v "#" $commands | $nc $server $port > "$tmpf"
|
|
48 |
--- beanstalkd-1.4.3.orig/sh-tests/binlog-diskfull-delete.sh
|
|
49 |
+++ beanstalkd-1.4.3/sh-tests/binlog-diskfull-delete.sh
|
|
50 |
@@ -1,8 +1,9 @@
|
|
51 |
#!/usr/bin/env bash
|
|
52 |
|
|
53 |
+. sh-tests/common.functions
|
|
54 |
+
|
|
55 |
ENOSPC=28
|
|
56 |
server=localhost
|
|
57 |
-port=11400
|
|
58 |
tmpdir="$TMPDIR"
|
|
59 |
size=1000
|
|
60 |
test -z "$tmpdir" && tmpdir=/tmp
|
|
61 |
@@ -25,17 +26,9 @@ fail() {
|
|
62 |
exit 1
|
|
63 |
}
|
|
64 |
|
|
65 |
-killbeanstalkd() {
|
|
66 |
- {
|
|
67 |
- test -z "$bpid" || kill -9 $bpid
|
|
68 |
- /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
69 |
- } >/dev/null 2>&1
|
|
70 |
- bpid=
|
|
71 |
-}
|
|
72 |
-
|
|
73 |
cleanup() {
|
|
74 |
killbeanstalkd
|
|
75 |
- rm -rf "$logdir" "$out1" "$out2"
|
|
76 |
+ rm -rf "$logdir" "$out1" "$out2" ${tmpdir}/fiu-ctrl-[0-9]*.{in,out}
|
|
77 |
}
|
|
78 |
|
|
79 |
catch() {
|
|
80 |
@@ -56,16 +49,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
81 |
exit 2
|
|
82 |
fi
|
|
83 |
|
|
84 |
-mkdir -p $logdir
|
|
85 |
-
|
|
86 |
-fiu-run -x ./beanstalkd -p $port -b "$logdir" -s $size >/dev/null 2>/dev/null &
|
|
87 |
-bpid=$!
|
|
88 |
-
|
|
89 |
-sleep .1
|
|
90 |
-if ! ps -p $bpid >/dev/null; then
|
|
91 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
92 |
- exit 2
|
|
93 |
-fi
|
|
94 |
+start_beanstalkd $logdir "-s $size" "fiu-run -x"
|
|
95 |
|
|
96 |
# Insert enough jobs to create another binlog file
|
|
97 |
$nc $server $port <<EOF > "$out1"
|
|
98 |
@@ -181,15 +165,7 @@ test "$res" -eq 0 || exit $res
|
|
99 |
|
|
100 |
killbeanstalkd
|
|
101 |
|
|
102 |
-sleep .1
|
|
103 |
-./beanstalkd -p $port -b "$logdir" -s $size >/dev/null 2>/dev/null &
|
|
104 |
-bpid=$!
|
|
105 |
-
|
|
106 |
-sleep .1
|
|
107 |
-if ! ps -p $bpid >/dev/null; then
|
|
108 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
109 |
- exit 2
|
|
110 |
-fi
|
|
111 |
+start_beanstalkd $logdir "-s $size"
|
|
112 |
|
|
113 |
$nc $server $port <<EOF > "$out2"
|
|
114 |
delete 8
|
|
115 |
--- beanstalkd-1.4.3.orig/sh-tests/binlog-diskfull.sh
|
|
116 |
+++ beanstalkd-1.4.3/sh-tests/binlog-diskfull.sh
|
|
117 |
@@ -1,8 +1,9 @@
|
|
118 |
#!/usr/bin/env bash
|
|
119 |
|
|
120 |
+. sh-tests/common.functions
|
|
121 |
+
|
|
122 |
ENOSPC=28
|
|
123 |
server=localhost
|
|
124 |
-port=11400
|
|
125 |
tmpdir="$TMPDIR"
|
|
126 |
size=1000
|
|
127 |
test -z "$tmpdir" && tmpdir=/tmp
|
|
128 |
@@ -18,17 +19,9 @@ then
|
|
129 |
exit 0
|
|
130 |
fi
|
|
131 |
|
|
132 |
-killbeanstalkd() {
|
|
133 |
- {
|
|
134 |
- test -z "$bpid" || kill -9 $bpid
|
|
135 |
- /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
136 |
- } >/dev/null 2>&1
|
|
137 |
- bpid=
|
|
138 |
-}
|
|
139 |
-
|
|
140 |
cleanup() {
|
|
141 |
killbeanstalkd
|
|
142 |
- rm -rf "$logdir" "$out1" "$out2"
|
|
143 |
+ rm -rf "$logdir" "$out1" "$out2" ${tmpdir}/fiu-ctrl-[0-9]*.{in,out}
|
|
144 |
}
|
|
145 |
|
|
146 |
catch() {
|
|
147 |
@@ -44,16 +37,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
148 |
exit 2
|
|
149 |
fi
|
|
150 |
|
|
151 |
-mkdir -p $logdir
|
|
152 |
-
|
|
153 |
-fiu-run -x ./beanstalkd -p $port -b "$logdir" -s $size >/dev/null 2>/dev/null &
|
|
154 |
-bpid=$!
|
|
155 |
-
|
|
156 |
-sleep .1
|
|
157 |
-if ! ps -p $bpid >/dev/null; then
|
|
158 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
159 |
- exit 2
|
|
160 |
-fi
|
|
161 |
+start_beanstalkd $logdir "-s $size" "fiu-run -x"
|
|
162 |
|
|
163 |
# Make beanstalkd think the disk is full now.
|
|
164 |
fiu-ctrl -e posix/io/oc/open -i $ENOSPC $bpid
|
|
165 |
@@ -114,14 +98,7 @@ test "$res" -eq 0 || exit $res
|
|
166 |
killbeanstalkd
|
|
167 |
|
|
168 |
sleep .1
|
|
169 |
-./beanstalkd -p $port -b "$logdir" -s $size >/dev/null 2>/dev/null &
|
|
170 |
-bpid=$!
|
|
171 |
-
|
|
172 |
-sleep .1
|
|
173 |
-if ! ps -p $bpid >/dev/null; then
|
|
174 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
175 |
- exit 2
|
|
176 |
-fi
|
|
177 |
+start_beanstalkd $logdir "-s $size"
|
|
178 |
|
|
179 |
$nc $server $port <<EOF > "$out2"
|
|
180 |
delete 1
|
|
181 |
--- beanstalkd-1.4.3.orig/sh-tests/binlog-basic.sh
|
|
182 |
+++ beanstalkd-1.4.3/sh-tests/binlog-basic.sh
|
|
183 |
@@ -1,7 +1,8 @@
|
|
184 |
#!/usr/bin/env bash
|
|
185 |
|
|
186 |
+. sh-tests/common.functions
|
|
187 |
+
|
|
188 |
server=localhost
|
|
189 |
-port=11400
|
|
190 |
tmpdir="$TMPDIR"
|
|
191 |
test -z "$tmpdir" && tmpdir=/tmp
|
|
192 |
out1="${tmpdir}/bnch$$.1"
|
|
193 |
@@ -10,14 +11,6 @@ logdir="${tmpdir}/bnch$$.d"
|
|
194 |
nc='nc -q 1'
|
|
195 |
nc -q 1 2>&1 | grep -q "illegal option" && nc='nc -w 1' # workaround for older netcat
|
|
196 |
|
|
197 |
-killbeanstalkd() {
|
|
198 |
- {
|
|
199 |
- test -z "$bpid" || kill -9 $bpid
|
|
200 |
- /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
201 |
- } >/dev/null 2>&1
|
|
202 |
- bpid=
|
|
203 |
-}
|
|
204 |
-
|
|
205 |
cleanup() {
|
|
206 |
killbeanstalkd
|
|
207 |
rm -rf "$logdir" "$out1" "$out2"
|
|
208 |
@@ -36,16 +29,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
209 |
exit 2
|
|
210 |
fi
|
|
211 |
|
|
212 |
-mkdir -p $logdir
|
|
213 |
-
|
|
214 |
-./beanstalkd -p $port -b "$logdir" >/dev/null 2>/dev/null &
|
|
215 |
-bpid=$!
|
|
216 |
-
|
|
217 |
-sleep .1
|
|
218 |
-if ! ps -p $bpid >/dev/null; then
|
|
219 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
220 |
- exit 2
|
|
221 |
-fi
|
|
222 |
+start_beanstalkd $logdir
|
|
223 |
|
|
224 |
$nc $server $port <<EOF > "$out1"
|
|
225 |
put 0 0 100 0
|
|
226 |
@@ -62,14 +46,7 @@ test "$res" -eq 0 || exit $res
|
|
227 |
killbeanstalkd
|
|
228 |
|
|
229 |
sleep .1
|
|
230 |
-./beanstalkd -p $port -b "$logdir" >/dev/null 2>/dev/null &
|
|
231 |
-bpid=$!
|
|
232 |
-
|
|
233 |
-sleep .1
|
|
234 |
-if ! ps -p $bpid >/dev/null; then
|
|
235 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
236 |
- exit 2
|
|
237 |
-fi
|
|
238 |
+start_beanstalkd $logdir
|
|
239 |
|
|
240 |
$nc $server $port <<EOF > "$out2"
|
|
241 |
delete 1
|
|
242 |
--- beanstalkd-1.4.3.orig/sh-tests/binlog-sizelimit.sh
|
|
243 |
+++ beanstalkd-1.4.3/sh-tests/binlog-sizelimit.sh
|
|
244 |
@@ -1,7 +1,8 @@
|
|
245 |
#!/usr/bin/env bash
|
|
246 |
|
|
247 |
+. sh-tests/common.functions
|
|
248 |
+
|
|
249 |
server=localhost
|
|
250 |
-port=11400
|
|
251 |
tmpdir="$TMPDIR"
|
|
252 |
size=1024
|
|
253 |
truncated_size_1=796
|
|
254 |
@@ -20,14 +21,6 @@ fail() {
|
|
255 |
exit 1
|
|
256 |
}
|
|
257 |
|
|
258 |
-killbeanstalkd() {
|
|
259 |
- {
|
|
260 |
- test -z "$bpid" || kill -9 $bpid
|
|
261 |
- /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
262 |
- } >/dev/null 2>&1
|
|
263 |
- bpid=
|
|
264 |
-}
|
|
265 |
-
|
|
266 |
cleanup() {
|
|
267 |
killbeanstalkd
|
|
268 |
rm -rf "$logdir" "$out1" "$out2"
|
|
269 |
@@ -51,16 +44,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
270 |
exit 2
|
|
271 |
fi
|
|
272 |
|
|
273 |
-mkdir -p $logdir
|
|
274 |
-
|
|
275 |
-./beanstalkd -p $port -b "$logdir" -s $size >/dev/null 2>/dev/null &
|
|
276 |
-bpid=$!
|
|
277 |
-
|
|
278 |
-sleep .1
|
|
279 |
-if ! ps -p $bpid >/dev/null; then
|
|
280 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
281 |
- exit 2
|
|
282 |
-fi
|
|
283 |
+start_beanstalkd $logdir "-s $size"
|
|
284 |
|
|
285 |
# Check that the first binlog file is the proper size.
|
|
286 |
test "$(fsize "$logdir"/binlog.1)" -eq $size || fail first binlog wrong size
|
|
287 |
--- beanstalkd-1.4.3.orig/sh-tests/binlog-bury.sh
|
|
288 |
+++ beanstalkd-1.4.3/sh-tests/binlog-bury.sh
|
|
289 |
@@ -1,7 +1,8 @@
|
|
290 |
#!/usr/bin/env bash
|
|
291 |
|
|
292 |
+. sh-tests/common.functions
|
|
293 |
+
|
|
294 |
server=localhost
|
|
295 |
-port=11400
|
|
296 |
tmpdir="$TMPDIR"
|
|
297 |
test -z "$tmpdir" && tmpdir=/tmp
|
|
298 |
out1="${tmpdir}/bnch$$.1"
|
|
299 |
@@ -10,14 +11,6 @@ logdir="${tmpdir}/bnch$$.d"
|
|
300 |
nc='nc -q 1'
|
|
301 |
nc -q 1 2>&1 | grep -q "illegal option" && nc='nc -w 1' # workaround for older netcat
|
|
302 |
|
|
303 |
-killbeanstalkd() {
|
|
304 |
- {
|
|
305 |
- test -z "$bpid" || kill -9 $bpid
|
|
306 |
- /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
307 |
- } >/dev/null 2>&1
|
|
308 |
- bpid=
|
|
309 |
-}
|
|
310 |
-
|
|
311 |
cleanup() {
|
|
312 |
killbeanstalkd
|
|
313 |
rm -rf "$logdir" "$out1" "$out2"
|
|
314 |
@@ -36,16 +29,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
315 |
exit 2
|
|
316 |
fi
|
|
317 |
|
|
318 |
-mkdir -p $logdir
|
|
319 |
-
|
|
320 |
-./beanstalkd -p $port -b "$logdir" >/dev/null 2>/dev/null &
|
|
321 |
-bpid=$!
|
|
322 |
-
|
|
323 |
-sleep .1
|
|
324 |
-if ! ps -p $bpid >/dev/null; then
|
|
325 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
326 |
- exit 2
|
|
327 |
-fi
|
|
328 |
+start_beanstalkd $logdir
|
|
329 |
|
|
330 |
$nc $server $port <<EOF > "$out1"
|
|
331 |
put 0 0 100 0
|
|
332 |
--- beanstalkd-1.4.3.orig/sh-tests/binlog-read.sh
|
|
333 |
+++ beanstalkd-1.4.3/sh-tests/binlog-read.sh
|
|
334 |
@@ -1,7 +1,8 @@
|
|
335 |
#!/usr/bin/env bash
|
|
336 |
|
|
337 |
+. sh-tests/common.functions
|
|
338 |
+
|
|
339 |
server=localhost
|
|
340 |
-port=11400
|
|
341 |
tmpdir="$TMPDIR"
|
|
342 |
test -z "$tmpdir" && tmpdir=/tmp
|
|
343 |
out1="${tmpdir}/bnch$$.1"
|
|
344 |
@@ -10,14 +11,6 @@ logdir="${tmpdir}/bnch$$.d"
|
|
345 |
nc='nc -q 1'
|
|
346 |
nc -q 1 2>&1 | grep -q "illegal option" && nc='nc -w 1' # workaround for older netcat
|
|
347 |
|
|
348 |
-killbeanstalkd() {
|
|
349 |
- {
|
|
350 |
- test -z "$bpid" || kill -9 $bpid
|
|
351 |
- /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
352 |
- } >/dev/null 2>&1
|
|
353 |
- bpid=
|
|
354 |
-}
|
|
355 |
-
|
|
356 |
cleanup() {
|
|
357 |
killbeanstalkd
|
|
358 |
rm -rf "$logdir" "$out1" "$out2"
|
|
359 |
@@ -36,16 +29,7 @@ if [ ! -x ./beanstalkd ]; then
|
|
360 |
exit 2
|
|
361 |
fi
|
|
362 |
|
|
363 |
-mkdir -p $logdir
|
|
364 |
-
|
|
365 |
-./beanstalkd -p $port -b "$logdir" >/dev/null 2>/dev/null &
|
|
366 |
-bpid=$!
|
|
367 |
-
|
|
368 |
-sleep .1
|
|
369 |
-if ! ps -p $bpid >/dev/null; then
|
|
370 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
371 |
- exit 2
|
|
372 |
-fi
|
|
373 |
+start_beanstalkd $logdir
|
|
374 |
|
|
375 |
$nc $server $port <<EOF > "$out1"
|
|
376 |
use test
|
|
377 |
@@ -79,14 +63,7 @@ test "$res" -eq 0 || exit $res
|
|
378 |
killbeanstalkd
|
|
379 |
|
|
380 |
sleep 1
|
|
381 |
-./beanstalkd -p $port -b "$logdir" >/dev/null 2>/dev/null &
|
|
382 |
-bpid=$!
|
|
383 |
-
|
|
384 |
-sleep .1
|
|
385 |
-if ! ps -p $bpid >/dev/null; then
|
|
386 |
- echo "Could not start beanstalkd for testing (possibly port $port is taken)"
|
|
387 |
- exit 2
|
|
388 |
-fi
|
|
389 |
+start_beanstalkd $logdir
|
|
390 |
|
|
391 |
$nc $server $port <<EOF > "$out2"
|
|
392 |
watch test
|
|
393 |
--- /dev/null
|
|
394 |
+++ beanstalkd-1.4.3/sh-tests/common.functions
|
|
395 |
@@ -0,0 +1,41 @@
|
|
396 |
+#!/usr/bin/env bash
|
|
397 |
+
|
|
398 |
+start_port=11400
|
|
399 |
+max_port_retries=20
|
|
400 |
+
|
|
401 |
+function killbeanstalkd() {
|
|
402 |
+ {
|
|
403 |
+ test -z "$bpid" || kill -9 $bpid
|
|
404 |
+ /bin/true # Somehow this gets rid of an unnessary shell message.
|
|
405 |
+ } >/dev/null 2>&1
|
|
406 |
+}
|
|
407 |
+
|
|
408 |
+function start_beanstalkd {
|
|
409 |
+ port=$start_port
|
|
410 |
+ logdir="$1"
|
|
411 |
+ other_args="$2" # other_args and fiu are optional
|
|
412 |
+ fiu="$3"
|
|
413 |
+
|
|
414 |
+ if [ "x$logdir" != "x" ]; then
|
|
415 |
+ mkdir -p $logdir
|
|
416 |
+ other_args="-b $logdir $other_args"
|
|
417 |
+ fi
|
|
418 |
+
|
|
419 |
+ max_port=$(($port + $max_port_retries))
|
|
420 |
+ while [ $port -lt $max_port ]; do
|
|
421 |
+ $fiu ./beanstalkd -l 127.0.0.1 -p $port $other_args >/dev/null 2>/dev/null &
|
|
422 |
+ bpid=$!
|
|
423 |
+
|
|
424 |
+ sleep .1
|
|
425 |
+ if ! ps -p $bpid >/dev/null; then
|
|
426 |
+ echo "Could not start beanstalkd for testing (possibly port $port is taken)" >&2
|
|
427 |
+ port=$(($port + 1))
|
|
428 |
+ else
|
|
429 |
+ echo "Started beanstalkd (pid: $bpid), listening on port $port"
|
|
430 |
+ export port bpid
|
|
431 |
+ return
|
|
432 |
+ fi
|
|
433 |
+ done
|
|
434 |
+ echo "Giving up after having tried $max_port_retries different ports" >&2
|
|
435 |
+ exit 2
|
|
436 |
+}
|