Merge "Change the API of wait_any_url to return a tuple of url and response"

This commit is contained in:
Jenkins 2015-06-15 09:28:03 +00:00 committed by Gerrit Code Review
commit d8faf3f7a4
2 changed files with 7 additions and 2 deletions

View File

@ -29,8 +29,10 @@ class UrlHelperWaitForUrlsTest(test.TestCase):
url, body=b'no worky',
status=400)
url = url_helper.wait_any_url(urls)
url, response = url_helper.wait_any_url(urls)
self.assertEqual("http://www.yahoo.com", url)
self.assertIsInstance(response, url_helper.RequestsResponse)
self.assertEqual(response.contents, b'it worked!')
@httpretty.activate
def test_url_wait_for_no_work(self):

View File

@ -226,6 +226,9 @@ def wait_any_url(urls, max_wait=None, timeout=None,
service but is not going to find one. It is possible that the instance
data host (169.254.169.254) may be firewalled off Entirely for a sytem,
meaning that the connection will block forever unless a timeout is set.
This will return a tuple of the first url which succeeded and the
response object.
"""
start_time = now()
@ -268,7 +271,7 @@ def wait_any_url(urls, max_wait=None, timeout=None,
url_exc = UrlError(ValueError(reason), code=response.code,
headers=response.headers)
else:
return url
return url, response
except UrlError as e:
reason = "request error [%s]" % e
url_exc = e