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.
This commit is contained in:
parent
d7845da326
commit
d92e2a6b0e
7 changed files with 21 additions and 19 deletions
1
test/integration/targets/binary_modules/aliases
Normal file
1
test/integration/targets/binary_modules/aliases
Normal file
|
@ -0,0 +1 @@
|
||||||
|
hidden
|
1
test/integration/targets/connection/aliases
Normal file
1
test/integration/targets/connection/aliases
Normal file
|
@ -0,0 +1 @@
|
||||||
|
hidden
|
|
@ -1 +1,2 @@
|
||||||
needs/target/connection
|
needs/target/connection
|
||||||
|
hidden
|
||||||
|
|
|
@ -85,6 +85,8 @@ class ContentLayout(Layout):
|
||||||
results_path, # type: str
|
results_path, # type: str
|
||||||
sanity_path, # type: str
|
sanity_path, # type: str
|
||||||
integration_path, # type: str
|
integration_path, # type: str
|
||||||
|
integration_targets_path, # type: str
|
||||||
|
integration_vars_path, # type: str
|
||||||
unit_path, # type: str
|
unit_path, # type: str
|
||||||
unit_module_path, # type: str
|
unit_module_path, # type: str
|
||||||
unit_module_utils_path, # type: str
|
unit_module_utils_path, # type: str
|
||||||
|
@ -97,11 +99,12 @@ class ContentLayout(Layout):
|
||||||
self.results_path = results_path
|
self.results_path = results_path
|
||||||
self.sanity_path = sanity_path
|
self.sanity_path = sanity_path
|
||||||
self.integration_path = integration_path
|
self.integration_path = integration_path
|
||||||
self.integration_targets_path = os.path.join(integration_path, 'targets')
|
self.integration_targets_path = integration_targets_path
|
||||||
self.integration_vars_path = os.path.join(integration_path, 'integration_config.yml')
|
self.integration_vars_path = integration_vars_path
|
||||||
self.unit_path = unit_path
|
self.unit_path = unit_path
|
||||||
self.unit_module_path = unit_module_path
|
self.unit_module_path = unit_module_path
|
||||||
self.unit_module_utils_path = unit_module_utils_path
|
self.unit_module_utils_path = unit_module_utils_path
|
||||||
|
|
||||||
self.is_ansible = root == ANSIBLE_SOURCE_ROOT
|
self.is_ansible = root == ANSIBLE_SOURCE_ROOT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -36,6 +36,8 @@ class AnsibleLayout(LayoutProvider):
|
||||||
results_path='test/results',
|
results_path='test/results',
|
||||||
sanity_path='test/sanity',
|
sanity_path='test/sanity',
|
||||||
integration_path='test/integration',
|
integration_path='test/integration',
|
||||||
|
integration_targets_path='test/integration/targets',
|
||||||
|
integration_vars_path='test/integration/integration_config.yml',
|
||||||
unit_path='test/units',
|
unit_path='test/units',
|
||||||
unit_module_path='test/units/modules',
|
unit_module_path='test/units/modules',
|
||||||
unit_module_utils_path='test/units/module_utils',
|
unit_module_utils_path='test/units/module_utils',
|
||||||
|
|
|
@ -48,6 +48,8 @@ class CollectionLayout(LayoutProvider):
|
||||||
results_path='tests/output',
|
results_path='tests/output',
|
||||||
sanity_path='tests/sanity',
|
sanity_path='tests/sanity',
|
||||||
integration_path='tests/integration',
|
integration_path='tests/integration',
|
||||||
|
integration_targets_path='tests/integration/targets',
|
||||||
|
integration_vars_path='tests/integration/integration_config.yml',
|
||||||
unit_path='tests/unit',
|
unit_path='tests/unit',
|
||||||
unit_module_path='tests/unit/plugins/modules',
|
unit_module_path='tests/unit/plugins/modules',
|
||||||
unit_module_utils_path='tests/unit/plugins/module_utils',
|
unit_module_utils_path='tests/unit/plugins/module_utils',
|
||||||
|
|
|
@ -520,31 +520,23 @@ class IntegrationTarget(CompletionTarget):
|
||||||
|
|
||||||
# script_path and type
|
# 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')
|
if runme_path in file_paths:
|
||||||
test_files = tuple(c for c in contents if os.path.splitext(c)[0] == 'test')
|
|
||||||
|
|
||||||
self.script_path = None
|
|
||||||
|
|
||||||
if runme_files:
|
|
||||||
self.type = 'script'
|
self.type = 'script'
|
||||||
self.script_path = os.path.join(path, runme_files[0])
|
self.script_path = runme_path
|
||||||
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'
|
|
||||||
else:
|
else:
|
||||||
self.type = 'role' # ansible will consider these empty roles, so ansible-test should as well
|
self.type = 'role' # ansible will consider these empty roles, so ansible-test should as well
|
||||||
|
self.script_path = None
|
||||||
|
|
||||||
# static_aliases
|
# 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))
|
static_aliases = tuple(read_lines_without_comments(aliases_path, remove_blank_lines=True))
|
||||||
except IOError as ex:
|
else:
|
||||||
if ex.errno != errno.ENOENT:
|
|
||||||
raise
|
|
||||||
static_aliases = tuple()
|
static_aliases = tuple()
|
||||||
|
|
||||||
# modules
|
# modules
|
||||||
|
|
Loading…
Reference in a new issue