Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Add test for failed retry.
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgestar committed Aug 3, 2015
1 parent 4024747 commit b2351d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
29 changes: 29 additions & 0 deletions go/apps/http_api_nostream/tests/test_vumi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,35 @@ def test_post_inbound_message_500_schedule_retry(self):

self.assertEqual(retry_msg['message_id'], msg['message_id'])

@inlineCallbacks
def test_post_inbound_message_500_schedule_retry_failed_500(self):
retry_url, retry_calls = yield self.start_retry_server()
yield self.start_app_worker({
'http_retry_api': retry_url,
})
msg_d = self.app_helper.make_dispatch_inbound(
'in 1', message_id='1', conv=self.conversation)

# return 500 response to message push
req = yield self.push_calls.get()
req.setResponseCode(500)
req.finish()

# catch and check retry
retry = yield retry_calls.get()
retry_data = retry.content.read()
retry.setResponseCode(500)
retry.finish()

with LogCatcher(log_level=logging.WARNING) as lc:
yield msg_d

self.assertEqual(lc.messages(), [
"Failed to schedule retry request [account: u'test-0-user'"
", request: %r, response: [500, 'Internal Server Error']]"
% (retry_data,),
])

@inlineCallbacks
def test_post_inbound_message_300_does_not_schedule_retry(self):
retry_url, retry_calls = yield self.start_retry_server()
Expand Down
6 changes: 3 additions & 3 deletions go/apps/http_api_nostream/vumi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ def schedule_push_retry(self, user_account_key, url, method, data,
headers=retry_headers, timeout=self.http_retry_timeout)
if not (200 <= resp.code < 300):
log.warning(
'Failed to schedule retry request.'
'Failed to schedule retry request'
' [account: %r, request: %r, response: %r]'
% (user_account_key, retry_data, resp))
% (user_account_key, retry_data, [resp.code, resp.phrase]))
except Exception as err:
log.warning(
'Error scheduling retry of request.'
'Error scheduling retry of request'
' [account: %r, request: %r, error: %r]'
% (user_account_key, retry_data, err))
else:
Expand Down

0 comments on commit b2351d7

Please sign in to comment.