Skip to content

Commit

Permalink
Add settings py to testing module (lost during last commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachayev committed Jul 30, 2011
1 parent 68fd81c commit 5c716b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/env_stub/client.py
Expand Up @@ -60,21 +60,21 @@ def random_sequence(delimiter, elements, randomizer=random.randrange, randomizer
client = gearman.GearmanClient(settings.STUB_GEARMAN_NODES)

while True:
if random.random() > settings.STUB_TASKS_PROBABILITY.get('reverse', 0.5):
if random.random() < settings.STUB_TASKS_PROBABILITY.get('reverse', 0.5):
# Add task for random word reversing
word = random_word(*settings.STUB_TASKS_ARGS.get('reverse', []))
client.submit_job('reverse', word, background=True)
# TODO: logging!
print 'Add reverse task for <%s>' % word

if random.random() > settings.STUB_TASKS_PROBABILITY.get('sum', 0.5):
if random.random() < settings.STUB_TASKS_PROBABILITY.get('sum', 0.5):
# Add task for calculating sum of 4 digits
sum = random_sum(*settings.STUB_TASKS_ARGS.get('sum', []))
client.submit_job('sum', sum, background=True)
# TODO: logging!
print 'Add sum calculation task for <%s>' % sum

if random.random() > settings.STUB_TASKS_PROBABILITY.get('multiple', 0.5):
if random.random() < settings.STUB_TASKS_PROBABILITY.get('multiple', 0.5):
# Add task for calculating multiple of 2 digits
multiple = random_multiple(*settings.STUB_TASKS_ARGS.get('multiple', []))
client.submit_job('multiple', multiple, background=True)
Expand Down
26 changes: 26 additions & 0 deletions tests/settings.py
@@ -0,0 +1,26 @@
import settings

# List of gearman nodes connection host:port pairs,
# which will be used for stub environment running
STUB_GEARMAN_NODES = ['localhost:4730']

# High value of probability means that
# client will generate more tasks per each delay block
STUB_TASKS_PROBABILITY = {
'reverse': 0.5,
'sum': 0.7,
'multiple': 0.7
}

# List of argumensts which will be given
# to sequence randomizer as params for each task processing
STUB_TASKS_ARGS = {
'reverse': [30],
'sum': [4],
'multiple': [3]
}

# Time delay in seconds between to generator's tic
# Leave current value as 1.0 and tasks will be generating once per each second
STUB_TASKS_FREQUENCY = 1.0

0 comments on commit 5c716b8

Please sign in to comment.