Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Merge djmitche/build-relengapi:issue178 (PR #178)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Mar 31, 2015
2 parents b41ad5b + f83b872 commit 5ee8327
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions relengapi/lib/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def _spawn_sqs_listeners(self, _testing=False):
while True:
time.sleep(2 ** 31)

return threads


def init_app(app):
app.aws = AWS(app.config.get('AWS', {}))
Expand Down
27 changes: 16 additions & 11 deletions relengapi/tests/test_lib_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,22 @@ def listener(msg):
if body == 'BODY2':
raise aws._StopListening

app.aws._spawn_sqs_listeners(_testing=True)
app.aws.sqs_write('us-east-1', 'my-sqs-queue', 'BODY1')
app.aws.sqs_write('us-east-1', 'my-sqs-queue', 'EXC')
app.aws.sqs_write('us-east-1', 'my-sqs-queue', 'BODY2')

eq_(got_msgs.get(), 'BODY1')
eq_(got_msgs.get(), 'BODY2')

# check that the exception was logged
assert any(
'while invoking' in record.message for record in log_buffer.buffer)
threads = app.aws._spawn_sqs_listeners(_testing=True)
try:
app.aws.sqs_write('us-east-1', 'my-sqs-queue', 'BODY1')
app.aws.sqs_write('us-east-1', 'my-sqs-queue', 'EXC')
app.aws.sqs_write('us-east-1', 'my-sqs-queue', 'BODY2')

eq_(got_msgs.get(), 'BODY1')
eq_(got_msgs.get(), 'BODY2')

# check that the exception was logged
assert any(
'while invoking' in record.message for record in log_buffer.buffer)

finally:
for th in threads:
th.join()

# NOTE: moto does not support changing message visibility, so there's no
# good way to programmatically verify that messages are being deleted
Expand Down

0 comments on commit 5ee8327

Please sign in to comment.