mirror of https://github.com/rq/rq.git
Clean up some of the dummy jobs used for testing.
Also, add a random_failure test.
This commit is contained in:
parent
f62e295454
commit
6f05e03293
|
@ -21,16 +21,12 @@ def main():
|
|||
queues = ('default', 'high', 'low')
|
||||
|
||||
sample_calls = [
|
||||
(dummy.do_nothing, [], {}),
|
||||
(dummy.do_nothing, [], {}),
|
||||
(dummy.do_nothing, [], {}),
|
||||
(dummy.do_nothing, [], {}),
|
||||
(dummy.do_nothing, [], {}),
|
||||
(dummy.sleep, [1], {}),
|
||||
(dummy.fib, [8], {}), # normal result
|
||||
(dummy.fib, [24], {}), # takes pretty long
|
||||
(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):
|
||||
|
|
19
rq/dummy.py
19
rq/dummy.py
|
@ -2,6 +2,7 @@
|
|||
Some dummy tasks that are well-suited for generating load for testing purposes.
|
||||
"""
|
||||
import time
|
||||
import random
|
||||
|
||||
|
||||
def do_nothing():
|
||||
|
@ -13,13 +14,8 @@ def sleep(secs):
|
|||
|
||||
|
||||
def endless_loop():
|
||||
x = 7
|
||||
while True:
|
||||
x *= 28
|
||||
if x % 3 == 0:
|
||||
x //= 21
|
||||
if x == 0:
|
||||
x = 82
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def div_by_zero():
|
||||
|
@ -33,8 +29,9 @@ def fib(n):
|
|||
return fib(n - 2) + fib(n - 1)
|
||||
|
||||
|
||||
def yield_stuff():
|
||||
yield 7
|
||||
yield 'foo'
|
||||
yield (3.14, 2.18)
|
||||
yield yield_stuff()
|
||||
def random_failure():
|
||||
if random.choice([True, False]):
|
||||
class RandomError(Exception):
|
||||
pass
|
||||
raise RandomError('Ouch!')
|
||||
return 'OK'
|
||||
|
|
Loading…
Reference in New Issue