From 8e0b5800b793c699292c01f48b6074d7cf599c35 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 17 Aug 2017 12:04:43 -0700 Subject: [PATCH] Miscellaneous ansible-test fixes. (#28355) * Include .github in test targets. Fix BOTMETA.yml. * Include bin in compile tests. * Exclude links from test targets. * Include bin in pep8 and pylint tests. * Fix pep8 and pylint issues in bin dir. --- .github/BOTMETA.yml | 5 +---- bin/ansible | 2 +- bin/ansible-connection | 5 +++-- test/runner/lib/sanity.py | 4 ++-- test/runner/lib/target.py | 24 ++++++++++++++++++++---- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 01ce3095322..bbf67075395 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -568,7 +568,7 @@ files: $modules/remote_management/hpilo/: dagwieers haad $modules/remote_management/imc/: dagwieers $modules/remote_management/ipmi/: cloudnull - $modules/remote_management/manageiq/ : $team_manageiq + $modules/remote_management/manageiq/: $team_manageiq $modules/remote_management/stacki/stacki_host.py: bbyhuy bsanders $modules/remote_management/wakeonlan.py: dagwieers $modules/source_control/bzr.py: andreparames @@ -903,9 +903,6 @@ files: $module_utils/dellos: maintainers: skg-net labels: networking - $module_utils/eos.py: - maintainers: $team_networking - labels: networking $module_utils/f5_utils.py: maintainers: caphrim007 labels: networking diff --git a/bin/ansible b/bin/ansible index f7595430008..ffb79803f7b 100755 --- a/bin/ansible +++ b/bin/ansible @@ -44,7 +44,7 @@ from ansible.module_utils._text import to_text ######################################## -### OUTPUT OF LAST RESORT ### +# OUTPUT OF LAST RESORT class LastResort(object): def display(self, msg): print(msg, file=sys.stderr) diff --git a/bin/ansible-connection b/bin/ansible-connection index e29c6818152..d2d10e71c28 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -62,7 +62,7 @@ def do_fork(): return pid # This is done as a 'good practice' for daemons, but we need to keep the cwd # leaving it here as a note that we KNOW its good practice but are not doing it on purpose. - #os.chdir("/") + # os.chdir("/") os.setsid() os.umask(0) @@ -261,6 +261,7 @@ def communicate(sock, data): stderr = recv_data(sock) return (rc, stdout, stderr) + def main(): # Need stdin as a byte stream if PY3: @@ -304,7 +305,7 @@ def main(): socket_path = unfrackpath(cp % dict(directory=tmp_path)) # if the socket file doesn't exist, spin up the daemon process - lock_fd = os.open(lock_path, os.O_RDWR|os.O_CREAT, 0o600) + lock_fd = os.open(lock_path, os.O_RDWR | os.O_CREAT, 0o600) fcntl.lockf(lock_fd, fcntl.LOCK_EX) if not os.path.exists(socket_path): diff --git a/test/runner/lib/sanity.py b/test/runner/lib/sanity.py index 74faba7f26b..0ffa28ad76e 100644 --- a/test/runner/lib/sanity.py +++ b/test/runner/lib/sanity.py @@ -315,7 +315,7 @@ def command_sanity_pep8(args, targets): skip_paths_set = set(skip_paths) legacy_paths_set = set(legacy_paths) - paths = sorted(i.path for i in targets.include if os.path.splitext(i.path)[1] == '.py' and i.path not in skip_paths_set) + paths = sorted(i.path for i in targets.include if (os.path.splitext(i.path)[1] == '.py' or i.path.startswith('bin/')) and i.path not in skip_paths_set) if not paths: return SanitySkipped(test) @@ -458,7 +458,7 @@ def command_sanity_pylint(args, targets): skip_paths_set = set(skip_paths) - paths = sorted(i.path for i in targets.include if os.path.splitext(i.path)[1] == '.py' and i.path not in skip_paths_set) + paths = sorted(i.path for i in targets.include if (os.path.splitext(i.path)[1] == '.py' or i.path.startswith('bin/')) and i.path not in skip_paths_set) if not paths: return SanitySkipped(test) diff --git a/test/runner/lib/target.py b/test/runner/lib/target.py index 9aee95dcb0a..67e4d0ed8e2 100644 --- a/test/runner/lib/target.py +++ b/test/runner/lib/target.py @@ -209,7 +209,7 @@ def walk_compile_targets(): """ :rtype: collections.Iterable[TestTarget] """ - return walk_test_targets(module_path='lib/ansible/modules/', extensions=('.py',)) + return walk_test_targets(module_path='lib/ansible/modules/', extensions=('.py',), extra_dirs=('bin',)) def walk_sanity_targets(): @@ -276,12 +276,13 @@ def load_integration_prefixes(): return prefixes -def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None): +def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None, extra_dirs=None): """ :type path: str | None :type module_path: str | None :type extensions: tuple[str] | None :type prefix: str | None + :type extra_dirs: tuple[str] | None :rtype: collections.Iterable[TestTarget] """ for root, _, file_names in os.walk(path or '.', topdown=False): @@ -294,7 +295,7 @@ def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None) if path is None: root = root[2:] - if root.startswith('.'): + if root.startswith('.') and root != '.github': continue for file_name in file_names: @@ -309,7 +310,22 @@ def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None) if prefix and not name.startswith(prefix): continue - yield TestTarget(os.path.join(root, file_name), module_path, prefix, path) + file_path = os.path.join(root, file_name) + + if os.path.islink(file_path): + continue + + yield TestTarget(file_path, module_path, prefix, path) + + if extra_dirs: + for extra_dir in extra_dirs: + file_names = os.listdir(extra_dir) + + for file_name in file_names: + file_path = os.path.join(extra_dir, file_name) + + if os.path.isfile(file_path) and not os.path.islink(file_path): + yield TestTarget(file_path, module_path, prefix, path) def analyze_integration_target_dependencies(integration_targets):