ansible-test: setup up http runner in between each target (#47100)

* ansible-test: setup up http runner in between each target

* review changes
pull/47112/head
Jordan Borean 6 years ago committed by GitHub
parent acbecd5f23
commit 9a5561da0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -509,7 +509,8 @@ def command_windows_integration(args):
all_targets = tuple(walk_windows_integration_targets(include_hidden=True)) all_targets = tuple(walk_windows_integration_targets(include_hidden=True))
internal_targets = command_integration_filter(args, all_targets, init_callback=windows_init) internal_targets = command_integration_filter(args, all_targets, init_callback=windows_init)
instances = [] # type: list [lib.thread.WrappedThread] instances = [] # type: list [lib.thread.WrappedThread]
use_httptester = False pre_target = None
post_target = None
httptester_id = None httptester_id = None
if args.windows: if args.windows:
@ -543,9 +544,7 @@ def command_windows_integration(args):
if use_httptester and not docker_available() and not docker_httptester: if use_httptester and not docker_available() and not docker_httptester:
display.warning('Assuming --disable-httptester since `docker` is not available.') display.warning('Assuming --disable-httptester since `docker` is not available.')
use_httptester = False elif use_httptester:
if use_httptester:
if docker_httptester: if docker_httptester:
# we are running in a Docker container that is linked to the httptester container, we just need to # we are running in a Docker container that is linked to the httptester container, we just need to
# forward these requests to the linked hostname # forward these requests to the linked hostname
@ -563,7 +562,13 @@ def command_windows_integration(args):
# create a script that will continue to run in the background until the script is deleted, this will # create a script that will continue to run in the background until the script is deleted, this will
# cleanup and close the connection # cleanup and close the connection
watcher_path = "ansible-test-http-watcher-%s.ps1" % time.time() def forward_ssh_ports(target):
"""
:type target: IntegrationTarget
"""
if 'needs/httptester/' not in target.aliases:
return
for remote in [r for r in remotes if r.version != '2008']: for remote in [r for r in remotes if r.version != '2008']:
manage = ManageWindowsCI(remote) manage = ManageWindowsCI(remote)
manage.upload("test/runner/setup/windows-httptester.ps1", watcher_path) manage.upload("test/runner/setup/windows-httptester.ps1", watcher_path)
@ -575,21 +580,32 @@ def command_windows_integration(args):
script += " -Verbose" script += " -Verbose"
manage.ssh(script, options=ssh_options, force_pty=False) manage.ssh(script, options=ssh_options, force_pty=False)
def cleanup_ssh_ports(target):
"""
:type target: IntegrationTarget
"""
if 'needs/httptester/' not in target.aliases:
return
for remote in [r for r in remotes if r.version != '2008']:
# delete the tmp file that keeps the http-tester alive
manage = ManageWindowsCI(remote)
manage.ssh("del %s /F /Q" % watcher_path)
watcher_path = "ansible-test-http-watcher-%s.ps1" % time.time()
pre_target = forward_ssh_ports
post_target = cleanup_ssh_ports
success = False success = False
try: try:
command_integration_filtered(args, internal_targets, all_targets) command_integration_filtered(args, internal_targets, all_targets, pre_target=pre_target,
post_target=post_target)
success = True success = True
finally: finally:
if use_httptester:
if httptester_id: if httptester_id:
docker_rm(args, httptester_id) docker_rm(args, httptester_id)
for remote in [r for r in remotes if r.version != '2008']:
# delete the tmp file that keeps the http-tester alive
manage = ManageWindowsCI(remote)
manage.ssh("del %s /F /Q" % watcher_path)
if args.remote_terminate == 'always' or (args.remote_terminate == 'success' and success): if args.remote_terminate == 'always' or (args.remote_terminate == 'success' and success):
for instance in instances: for instance in instances:
instance.result.stop() instance.result.stop()
@ -746,11 +762,13 @@ def command_integration_filter(args, targets, init_callback=None):
return internal_targets return internal_targets
def command_integration_filtered(args, targets, all_targets): def command_integration_filtered(args, targets, all_targets, pre_target=None, post_target=None):
""" """
:type args: IntegrationConfig :type args: IntegrationConfig
:type targets: tuple[IntegrationTarget] :type targets: tuple[IntegrationTarget]
:type all_targets: tuple[IntegrationTarget] :type all_targets: tuple[IntegrationTarget]
:type pre_target: (IntegrationTarget) -> None | None
:type post_target: (IntegrationTarget) -> None | None
""" """
found = False found = False
passed = [] passed = []
@ -837,11 +855,18 @@ def command_integration_filtered(args, targets, all_targets):
remove_tree(test_dir) remove_tree(test_dir)
make_dirs(test_dir) make_dirs(test_dir)
if pre_target:
pre_target(target)
try:
if target.script_path: if target.script_path:
command_integration_script(args, target, test_dir) command_integration_script(args, target, test_dir)
else: else:
command_integration_role(args, target, start_at_task, test_dir) command_integration_role(args, target, start_at_task, test_dir)
start_at_task = None start_at_task = None
finally:
if post_target:
post_target(target)
end_time = time.time() end_time = time.time()

Loading…
Cancel
Save