diff options
author | Matt Clay <matt@mystile.com> | 2019-08-28 22:18:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 22:18:20 -0700 |
commit | d92e2a6b0eecbb74cee639eb7d53a5de4325d7e3 (patch) | |
tree | 577dacf07fef612ee63c0d7cf7fbd52c5d9c9b68 | |
parent | d7845da326e3d0cf74ff813a0e8b84b4137d185d (diff) | |
download | ansible-d92e2a6b0eecbb74cee639eb7d53a5de4325d7e3.tar.gz |
Simplify ansible-test target processing. (#61506)
* Clean up layout paths for integration tests.
* Remove "special" integration test target type.
* Remove unnecessary role detection logic.
* Remove support for non-sh runme scripts.
* Simplify reading of aliases.
7 files changed, 21 insertions, 19 deletions
diff --git a/test/integration/targets/binary_modules/aliases b/test/integration/targets/binary_modules/aliases new file mode 100644 index 0000000000..136c05e0d0 --- /dev/null +++ b/test/integration/targets/binary_modules/aliases @@ -0,0 +1 @@ +hidden diff --git a/test/integration/targets/connection/aliases b/test/integration/targets/connection/aliases new file mode 100644 index 0000000000..136c05e0d0 --- /dev/null +++ b/test/integration/targets/connection/aliases @@ -0,0 +1 @@ +hidden diff --git a/test/integration/targets/connection_posix/aliases b/test/integration/targets/connection_posix/aliases index c0fdd23c55..f5e09799b1 100644 --- a/test/integration/targets/connection_posix/aliases +++ b/test/integration/targets/connection_posix/aliases @@ -1 +1,2 @@ needs/target/connection +hidden diff --git a/test/lib/ansible_test/_internal/provider/layout/__init__.py b/test/lib/ansible_test/_internal/provider/layout/__init__.py index 49f304b14d..54fa0e88c1 100644 --- a/test/lib/ansible_test/_internal/provider/layout/__init__.py +++ b/test/lib/ansible_test/_internal/provider/layout/__init__.py @@ -85,6 +85,8 @@ class ContentLayout(Layout): results_path, # type: str sanity_path, # type: str integration_path, # type: str + integration_targets_path, # type: str + integration_vars_path, # type: str unit_path, # type: str unit_module_path, # type: str unit_module_utils_path, # type: str @@ -97,11 +99,12 @@ class ContentLayout(Layout): self.results_path = results_path self.sanity_path = sanity_path self.integration_path = integration_path - self.integration_targets_path = os.path.join(integration_path, 'targets') - self.integration_vars_path = os.path.join(integration_path, 'integration_config.yml') + self.integration_targets_path = integration_targets_path + self.integration_vars_path = integration_vars_path self.unit_path = unit_path self.unit_module_path = unit_module_path self.unit_module_utils_path = unit_module_utils_path + self.is_ansible = root == ANSIBLE_SOURCE_ROOT @property diff --git a/test/lib/ansible_test/_internal/provider/layout/ansible.py b/test/lib/ansible_test/_internal/provider/layout/ansible.py index 6ef68dada2..b393d7907a 100644 --- a/test/lib/ansible_test/_internal/provider/layout/ansible.py +++ b/test/lib/ansible_test/_internal/provider/layout/ansible.py @@ -36,6 +36,8 @@ class AnsibleLayout(LayoutProvider): results_path='test/results', sanity_path='test/sanity', integration_path='test/integration', + integration_targets_path='test/integration/targets', + integration_vars_path='test/integration/integration_config.yml', unit_path='test/units', unit_module_path='test/units/modules', unit_module_utils_path='test/units/module_utils', diff --git a/test/lib/ansible_test/_internal/provider/layout/collection.py b/test/lib/ansible_test/_internal/provider/layout/collection.py index 1b83065d1c..3f4ddbd858 100644 --- a/test/lib/ansible_test/_internal/provider/layout/collection.py +++ b/test/lib/ansible_test/_internal/provider/layout/collection.py @@ -48,6 +48,8 @@ class CollectionLayout(LayoutProvider): results_path='tests/output', sanity_path='tests/sanity', integration_path='tests/integration', + integration_targets_path='tests/integration/targets', + integration_vars_path='tests/integration/integration_config.yml', unit_path='tests/unit', unit_module_path='tests/unit/plugins/modules', unit_module_utils_path='tests/unit/plugins/module_utils', diff --git a/test/lib/ansible_test/_internal/target.py b/test/lib/ansible_test/_internal/target.py index 5c2f84a407..c0cf8c5b10 100644 --- a/test/lib/ansible_test/_internal/target.py +++ b/test/lib/ansible_test/_internal/target.py @@ -520,31 +520,23 @@ class IntegrationTarget(CompletionTarget): # script_path and type - contents = [os.path.basename(p) for p in data_context().content.get_files(path)] + file_paths = data_context().content.get_files(path) + runme_path = os.path.join(path, 'runme.sh') - runme_files = tuple(c for c in contents if os.path.splitext(c)[0] == 'runme') - test_files = tuple(c for c in contents if os.path.splitext(c)[0] == 'test') - - self.script_path = None - - if runme_files: + if runme_path in file_paths: self.type = 'script' - self.script_path = os.path.join(path, runme_files[0]) - elif test_files: - self.type = 'special' - elif os.path.isdir(os.path.join(path, 'tasks')) or os.path.isdir(os.path.join(path, 'defaults')): - self.type = 'role' + self.script_path = runme_path else: self.type = 'role' # ansible will consider these empty roles, so ansible-test should as well + self.script_path = None # static_aliases - try: - aliases_path = os.path.join(path, 'aliases') + aliases_path = os.path.join(path, 'aliases') + + if aliases_path in file_paths: static_aliases = tuple(read_lines_without_comments(aliases_path, remove_blank_lines=True)) - except IOError as ex: - if ex.errno != errno.ENOENT: - raise + else: static_aliases = tuple() # modules |