Clean up some of the dummy jobs used for testing.

Also, add a random_failure test.
main
Vincent Driessen 13 years ago
parent f62e295454
commit 6f05e03293

@ -21,16 +21,12 @@ def main():
queues = ('default', 'high', 'low') queues = ('default', 'high', 'low')
sample_calls = [ sample_calls = [
(dummy.do_nothing, [], {}),
(dummy.do_nothing, [], {}),
(dummy.do_nothing, [], {}),
(dummy.do_nothing, [], {}),
(dummy.do_nothing, [], {}), (dummy.do_nothing, [], {}),
(dummy.sleep, [1], {}), (dummy.sleep, [1], {}),
(dummy.fib, [8], {}), # normal result (dummy.fib, [8], {}), # normal result
(dummy.fib, [24], {}), # takes pretty long (dummy.fib, [24], {}), # takes pretty long
(dummy.div_by_zero, [], {}), # 5 / 0 => div by zero exc (dummy.div_by_zero, [], {}), # 5 / 0 => div by zero exc
(dummy.fib, [30], {}), # takes long, then crashes (dummy.random_failure, [], {}), # simulate random failure (handy for requeue testing)
] ]
for i in range(opts.count): for i in range(opts.count):

@ -2,6 +2,7 @@
Some dummy tasks that are well-suited for generating load for testing purposes. Some dummy tasks that are well-suited for generating load for testing purposes.
""" """
import time import time
import random
def do_nothing(): def do_nothing():
@ -13,13 +14,8 @@ def sleep(secs):
def endless_loop(): def endless_loop():
x = 7
while True: while True:
x *= 28 time.sleep(1)
if x % 3 == 0:
x //= 21
if x == 0:
x = 82
def div_by_zero(): def div_by_zero():
@ -33,8 +29,9 @@ def fib(n):
return fib(n - 2) + fib(n - 1) return fib(n - 2) + fib(n - 1)
def yield_stuff(): def random_failure():
yield 7 if random.choice([True, False]):
yield 'foo' class RandomError(Exception):
yield (3.14, 2.18) pass
yield yield_stuff() raise RandomError('Ouch!')
return 'OK'

Loading…
Cancel
Save