From b446ca100f22f8be8d84387ed70e824874a33828 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 5 Aug 2019 14:56:38 -0700 Subject: Prepare ansible-test code for relocation. (#60110) * Fix imports in cli.py. * Fix imports in executor.py. * Remove old test/runner/ansible-test entry point. Use the official bin/ansible-test entry point instead, which has been around since Ansible 2.5. * Use bin/ansible-test on Shippable. --- test/runner/ansible-test | 10 ---------- test/runner/lib/cli.py | 35 ++++++++++++++++++++++------------- test/runner/lib/executor.py | 20 +++++++++++--------- test/utils/shippable/shippable.sh | 2 +- 4 files changed, 34 insertions(+), 33 deletions(-) delete mode 100755 test/runner/ansible-test (limited to 'test') diff --git a/test/runner/ansible-test b/test/runner/ansible-test deleted file mode 100755 index 74dc229f16..0000000000 --- a/test/runner/ansible-test +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python -# PYTHON_ARGCOMPLETE_OK -"""Legacy entry point for ansible-test. The preferred version is in the bin directory.""" -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import lib.cli - -if __name__ == '__main__': - lib.cli.main() diff --git a/test/runner/lib/cli.py b/test/runner/lib/cli.py index b6699dd9ff..079422276f 100644 --- a/test/runner/lib/cli.py +++ b/test/runner/lib/cli.py @@ -88,7 +88,16 @@ from lib.util_common import ( CommonConfig, ) -import lib.cover +from lib.cover import ( + command_coverage_combine, + command_coverage_erase, + command_coverage_html, + command_coverage_report, + command_coverage_xml, + COVERAGE_GROUPS, + CoverageConfig, + CoverageReportConfig, +) def main(): @@ -478,8 +487,8 @@ def parse_args(): parents=[coverage_common], help='combine coverage data and rewrite remote paths') - coverage_combine.set_defaults(func=lib.cover.command_coverage_combine, - config=lib.cover.CoverageConfig) + coverage_combine.set_defaults(func=command_coverage_combine, + config=CoverageConfig) add_extra_coverage_options(coverage_combine) @@ -487,15 +496,15 @@ def parse_args(): parents=[coverage_common], help='erase coverage data files') - coverage_erase.set_defaults(func=lib.cover.command_coverage_erase, - config=lib.cover.CoverageConfig) + coverage_erase.set_defaults(func=command_coverage_erase, + config=CoverageConfig) coverage_report = coverage_subparsers.add_parser('report', parents=[coverage_common], help='generate console coverage report') - coverage_report.set_defaults(func=lib.cover.command_coverage_report, - config=lib.cover.CoverageReportConfig) + coverage_report.set_defaults(func=command_coverage_report, + config=CoverageReportConfig) coverage_report.add_argument('--show-missing', action='store_true', @@ -516,8 +525,8 @@ def parse_args(): parents=[coverage_common], help='generate html coverage report') - coverage_html.set_defaults(func=lib.cover.command_coverage_html, - config=lib.cover.CoverageConfig) + coverage_html.set_defaults(func=command_coverage_html, + config=CoverageConfig) add_extra_coverage_options(coverage_html) @@ -525,8 +534,8 @@ def parse_args(): parents=[coverage_common], help='generate xml coverage report') - coverage_xml.set_defaults(func=lib.cover.command_coverage_xml, - config=lib.cover.CoverageConfig) + coverage_xml.set_defaults(func=command_coverage_xml, + config=CoverageConfig) add_extra_coverage_options(coverage_xml) @@ -710,8 +719,8 @@ def add_extra_coverage_options(parser): parser.add_argument('--group-by', metavar='GROUP', action='append', - choices=lib.cover.COVERAGE_GROUPS, - help='group output by: %s' % ', '.join(lib.cover.COVERAGE_GROUPS)) + choices=COVERAGE_GROUPS, + help='group output by: %s' % ', '.join(COVERAGE_GROUPS)) parser.add_argument('--all', action='store_true', diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py index 2331a8826d..1d265a81df 100644 --- a/test/runner/lib/executor.py +++ b/test/runner/lib/executor.py @@ -20,7 +20,9 @@ import shutil import lib.types as t -import lib.thread +from lib.thread import ( + WrappedThread, +) from lib.core_ci import ( AnsibleCoreCI, @@ -380,7 +382,7 @@ def command_network_integration(args): all_targets = tuple(walk_network_integration_targets(include_hidden=True)) internal_targets = command_integration_filter(args, all_targets, init_callback=network_init) - instances = [] # type: t.List[lib.thread.WrappedThread] + instances = [] # type: t.List[WrappedThread] if args.platform: get_python_path(args, args.python_executable) # initialize before starting threads @@ -394,7 +396,7 @@ def command_network_integration(args): if not config: continue - instance = lib.thread.WrappedThread(functools.partial(network_run, args, platform, version, config)) + instance = WrappedThread(functools.partial(network_run, args, platform, version, config)) instance.daemon = True instance.start() instances.append(instance) @@ -435,7 +437,7 @@ def network_init(args, internal_targets): platform_targets = set(a for target in internal_targets for a in target.aliases if a.startswith('network/')) - instances = [] # type: t.List[lib.thread.WrappedThread] + instances = [] # type: t.List[WrappedThread] # generate an ssh key (if needed) up front once, instead of for each instance SshKey(args) @@ -449,7 +451,7 @@ def network_init(args, internal_targets): platform_version, platform)) continue - instance = lib.thread.WrappedThread(functools.partial(network_start, args, platform, version)) + instance = WrappedThread(functools.partial(network_start, args, platform, version)) instance.daemon = True instance.start() instances.append(instance) @@ -545,7 +547,7 @@ def command_windows_integration(args): all_targets = tuple(walk_windows_integration_targets(include_hidden=True)) internal_targets = command_integration_filter(args, all_targets, init_callback=windows_init) - instances = [] # type: t.List[lib.thread.WrappedThread] + instances = [] # type: t.List[WrappedThread] pre_target = None post_target = None httptester_id = None @@ -558,7 +560,7 @@ def command_windows_integration(args): for version in args.windows: config = configs['windows/%s' % version] - instance = lib.thread.WrappedThread(functools.partial(windows_run, args, version, config)) + instance = WrappedThread(functools.partial(windows_run, args, version, config)) instance.daemon = True instance.start() instances.append(instance) @@ -660,10 +662,10 @@ def windows_init(args, internal_targets): # pylint: disable=locally-disabled, u if args.metadata.instance_config is not None: return - instances = [] # type: t.List[lib.thread.WrappedThread] + instances = [] # type: t.List[WrappedThread] for version in args.windows: - instance = lib.thread.WrappedThread(functools.partial(windows_start, args, version)) + instance = WrappedThread(functools.partial(windows_start, args, version)) instance.daemon = True instance.start() instances.append(instance) diff --git a/test/utils/shippable/shippable.sh b/test/utils/shippable/shippable.sh index 79aa5d08e9..98f9c879ff 100755 --- a/test/utils/shippable/shippable.sh +++ b/test/utils/shippable/shippable.sh @@ -30,7 +30,7 @@ command -v pip pip --version pip list --disable-pip-version-check -export PATH="test/runner:${PATH}" +export PATH="${PWD}/bin:${PATH}" export PYTHONIOENCODING='utf-8' if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then -- cgit v1.2.3