mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-31 00:51:23 -07:00
ansible-test: setup up http runner in between each target (#47100)
* ansible-test: setup up http runner in between each target * review changes
This commit is contained in:
parent
acbecd5f23
commit
9a5561da0f
1 changed files with 54 additions and 29 deletions
|
@ -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,32 +562,49 @@ 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):
|
||||||
for remote in [r for r in remotes if r.version != '2008']:
|
"""
|
||||||
manage = ManageWindowsCI(remote)
|
:type target: IntegrationTarget
|
||||||
manage.upload("test/runner/setup/windows-httptester.ps1", watcher_path)
|
"""
|
||||||
|
if 'needs/httptester/' not in target.aliases:
|
||||||
|
return
|
||||||
|
|
||||||
# need to use -Command as we cannot pass an array of values with -File
|
for remote in [r for r in remotes if r.version != '2008']:
|
||||||
script = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command .\\%s -Hosts %s" \
|
manage = ManageWindowsCI(remote)
|
||||||
% (watcher_path, ", ".join(HTTPTESTER_HOSTS))
|
manage.upload("test/runner/setup/windows-httptester.ps1", watcher_path)
|
||||||
if args.verbosity > 3:
|
|
||||||
script += " -Verbose"
|
# need to use -Command as we cannot pass an array of values with -File
|
||||||
manage.ssh(script, options=ssh_options, force_pty=False)
|
script = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command .\\%s -Hosts %s" \
|
||||||
|
% (watcher_path, ", ".join(HTTPTESTER_HOSTS))
|
||||||
|
if args.verbosity > 3:
|
||||||
|
script += " -Verbose"
|
||||||
|
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:
|
||||||
|
@ -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 target.script_path:
|
if pre_target:
|
||||||
command_integration_script(args, target, test_dir)
|
pre_target(target)
|
||||||
else:
|
|
||||||
command_integration_role(args, target, start_at_task, test_dir)
|
try:
|
||||||
start_at_task = None
|
if target.script_path:
|
||||||
|
command_integration_script(args, target, test_dir)
|
||||||
|
else:
|
||||||
|
command_integration_role(args, target, start_at_task, test_dir)
|
||||||
|
start_at_task = None
|
||||||
|
finally:
|
||||||
|
if post_target:
|
||||||
|
post_target(target)
|
||||||
|
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue