Fix placement and handling of ansible-test cloud config (#60253)

* Move cloud templates.
* Update paths for cloud config templates.
* Fix cloud config paths.
* Fix cloud-config classification.
pull/60256/head
Matt Clay 5 years ago committed by GitHub
parent 81cb6f366a
commit 2e7d36a3f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -681,14 +681,6 @@ class PathMapper:
command: self.integration_all_target,
}
if name.startswith('cloud-config-'):
cloud_target = 'cloud/%s/' % name.split('-')[2].split('.')[0]
if cloud_target in self.integration_targets_by_alias:
return {
'integration': cloud_target,
}
return {
'integration': self.integration_all_target,
'windows-integration': self.integration_all_target,
@ -723,6 +715,15 @@ class PathMapper:
test_path = os.path.dirname(test_path)
if path.startswith('test/lib/ansible_test/config/'):
if name.startswith('cloud-config-'):
cloud_target = 'cloud/%s/' % name.split('-')[2].split('.')[0]
if cloud_target in self.integration_targets_by_alias:
return {
'integration': cloud_target,
}
if path.startswith('test/lib/ansible_test/_data/completion/'):
if path == 'test/lib/ansible_test/_data/completion/docker.txt':
return all_tests(self.args, force=True) # force all tests due to risk of breaking changes in new test environment

@ -24,6 +24,7 @@ from ..util import (
ABC,
to_bytes,
make_dirs,
ANSIBLE_TEST_CONFIG_ROOT,
)
from ..target import (
@ -188,7 +189,12 @@ class CloudBase(ABC):
def config_callback(files): # type: (t.List[t.Tuple[str, str]]) -> None
"""Add the config file to the payload file list."""
if self._get_cloud_config(self._CONFIG_PATH, ''):
pair = (self.config_path, os.path.relpath(self.config_path, data_context().content.root))
if data_context().content.collection:
working_path = data_context().content.collection.directory
else:
working_path = ''
pair = (self.config_path, os.path.join(working_path, os.path.relpath(self.config_path, data_context().content.root)))
if pair not in files:
display.info('Including %s config: %s -> %s' % (self.platform, pair[0], pair[1]), verbosity=3)
@ -283,8 +289,9 @@ class CloudProvider(CloudBase):
super(CloudProvider, self).__init__(args)
self.remove_config = False
self.config_static_path = '%s/cloud-config-%s%s' % (self.TEST_DIR, self.platform, config_extension)
self.config_template_path = '%s.template' % self.config_static_path
self.config_static_name = 'cloud-config-%s%s' % (self.platform, config_extension)
self.config_static_path = os.path.join(self.TEST_DIR, self.config_static_name)
self.config_template_path = os.path.join(ANSIBLE_TEST_CONFIG_ROOT, '%s.template' % self.config_static_name)
self.config_extension = config_extension
def filter(self, targets, exclude):
@ -349,9 +356,8 @@ class CloudProvider(CloudBase):
with tempfile.NamedTemporaryFile(dir=self.TEST_DIR, prefix=prefix, suffix=self.config_extension, delete=False) as config_fd:
filename = os.path.join(self.TEST_DIR, os.path.basename(config_fd.name))
self.config_path = config_fd.name
self.config_path = filename
self.remove_config = True
self._set_cloud_config('config_path', filename)
display.info('>>> Config: %s\n%s' % (filename, content.strip()), verbosity=3)

@ -65,6 +65,7 @@ COVERAGE_OUTPUT_PATH = 'coverage'
ANSIBLE_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
ANSIBLE_TEST_ROOT = os.path.join(ANSIBLE_ROOT, 'test', 'lib', 'ansible_test')
ANSIBLE_TEST_DATA_ROOT = os.path.join(ANSIBLE_TEST_ROOT, '_data')
ANSIBLE_TEST_CONFIG_ROOT = os.path.join(ANSIBLE_TEST_ROOT, 'config')
# Modes are set to allow all users the same level of access.
# This permits files to be used in tests that change users.

Loading…
Cancel
Save