Miscellaneous ansible-test updates. (#27937)

* Add keep alives to ansible-test ssh delegation.
* Improve ansible-test JSON parsing error messages.
* Increase ansible-test delegation sleep and retry.
* Update ansible-test to recognize .psm1 files.
This commit is contained in:
Matt Clay 2017-08-08 22:55:17 -07:00 committed by GitHub
parent 875c8e4f3e
commit a40cb5a47f
4 changed files with 24 additions and 9 deletions

View file

@ -86,7 +86,7 @@ class HttpClient(object):
stdout, _ = run_command(self.args, cmd, capture=True, always=self.always, cmd_verbosity=2)
if self.args.explain and not self.always:
return HttpResponse(200, '')
return HttpResponse(method, url, 200, '')
header, body = stdout.split('\r\n\r\n', 1)
@ -95,16 +95,20 @@ class HttpClient(object):
http_response = first_line.split(' ')
status_code = int(http_response[1])
return HttpResponse(status_code, body)
return HttpResponse(method, url, status_code, body)
class HttpResponse(object):
"""HTTP response from curl."""
def __init__(self, status_code, response):
def __init__(self, method, url, status_code, response):
"""
:type method: str
:type url: str
:type status_code: int
:type response: str
"""
self.method = method
self.url = url
self.status_code = status_code
self.response = response
@ -115,7 +119,7 @@ class HttpResponse(object):
try:
return json.loads(self.response)
except ValueError:
raise HttpError(self.status_code, 'Cannot parse response as JSON:\n%s' % self.response)
raise HttpError(self.status_code, 'Cannot parse response to %s %s as JSON:\n%s' % (self.method, self.url, self.response))
class HttpError(ApplicationError):