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.
pull/27946/head
Matt Clay 7 years ago committed by GitHub
parent 875c8e4f3e
commit a40cb5a47f

@ -260,7 +260,7 @@ class PathMapper(object):
return minimal
if path.startswith('lib/ansible/module_utils/'):
if ext == '.ps1':
if ext in ('.ps1', '.psm1'):
return {
'windows-integration': self.integration_all_target,
}

@ -181,7 +181,7 @@ class AnsibleCoreCI(object):
raise self._create_http_error(response)
def get(self, tries=2, sleep=10, always_raise_on=None):
def get(self, tries=3, sleep=15, always_raise_on=None):
"""
Get instance connection information.
:type tries: int
@ -290,8 +290,8 @@ class AnsibleCoreCI(object):
'Content-Type': 'application/json',
}
tries = 2
sleep = 10
tries = 3
sleep = 15
while True:
tries -= 1

@ -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):

@ -110,7 +110,18 @@ class ManagePosixCI(object):
:type core_ci: AnsibleCoreCI
"""
self.core_ci = core_ci
self.ssh_args = ['-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=no', '-i', self.core_ci.ssh_key.key]
self.ssh_args = ['-i', self.core_ci.ssh_key.key]
ssh_options = dict(
BatchMode='yes',
StrictHostKeyChecking='no',
UserKnownHostsFile='/dev/null',
ServerAliveInterval=15,
ServerAliveCountMax=4,
)
for ssh_option in sorted(ssh_options):
self.ssh_args += ['-o', '%s=%s' % (ssh_option, ssh_options[ssh_option])]
if self.core_ci.platform == 'freebsd':
self.become = ['su', '-l', 'root', '-c']

Loading…
Cancel
Save