diff options
author | Matt Clay <matt@mystile.com> | 2019-07-23 04:24:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-23 04:24:48 +0200 |
commit | 79eca9c8fb57b6e043e8ea72d6ab144ab5416607 (patch) | |
tree | d616445248e4763f7bfb98184e399a60148ea928 /test/runner/lib/cloud/__init__.py | |
parent | Mark Docker tests unstable (#59408) (diff) | |
download | ansible-79eca9c8fb57b6e043e8ea72d6ab144ab5416607.tar.xz ansible-79eca9c8fb57b6e043e8ea72d6ab144ab5416607.zip |
Initial ansible-test support for collections. (#59197)
* Initial ansible-test support for collections.
* Include cloud config in delegation payload.
* Add missing types import and fix `t` shadowing.
* Fix plugin traceback when config_path not set.
* Fix encoding issues.
* Remove unused imports.
* More encoding fixes.
* Handle delegation outside exception handler.
* Inject ssh keys only if not already in place.
* More defensive approach to getting remote pwd.
* Add missing string format var.
* Correct PowerShell require regex.
* Rename `is_install` and `INSTALL_ROOT`.
Diffstat (limited to 'test/runner/lib/cloud/__init__.py')
-rw-r--r-- | test/runner/lib/cloud/__init__.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/test/runner/lib/cloud/__init__.py b/test/runner/lib/cloud/__init__.py index 063e6b999e..40fce32734 100644 --- a/test/runner/lib/cloud/__init__.py +++ b/test/runner/lib/cloud/__init__.py @@ -13,6 +13,8 @@ import random import re import tempfile +import lib.types as t + from lib.util import ( ApplicationError, display, @@ -20,6 +22,7 @@ from lib.util import ( import_plugins, load_plugins, ABC, + to_bytes, ) from lib.target import ( @@ -30,6 +33,10 @@ from lib.config import ( IntegrationConfig, ) +from lib.data import ( + data_context, +) + PROVIDERS = {} ENVIRONMENTS = {} @@ -55,7 +62,7 @@ def get_cloud_platforms(args, targets=None): if targets is None: cloud_platforms = set(args.metadata.cloud_config or []) else: - cloud_platforms = set(get_cloud_platform(t) for t in targets) + cloud_platforms = set(get_cloud_platform(target) for target in targets) cloud_platforms.discard(None) @@ -145,7 +152,7 @@ def cloud_init(args, targets): results[provider.platform] = dict( platform=provider.platform, setup_seconds=int(end_time - start_time), - targets=[t.name for t in targets], + targets=[target.name for target in targets], ) if not args.explain and results: @@ -175,6 +182,17 @@ class CloudBase(ABC): self.args = args self.platform = self.__module__.split('.')[2] + 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 pair not in files: + display.info('Including %s config: %s -> %s' % (self.platform, pair[0], pair[1]), verbosity=3) + files.append(pair) + + data_context().register_payload_callback(config_callback) + @property def setup_executed(self): """ @@ -194,7 +212,7 @@ class CloudBase(ABC): """ :rtype: str """ - return os.path.join(os.getcwd(), self._get_cloud_config(self._CONFIG_PATH)) + return os.path.join(data_context().content.root, self._get_cloud_config(self._CONFIG_PATH)) @config_path.setter def config_path(self, value): @@ -334,7 +352,7 @@ class CloudProvider(CloudBase): display.info('>>> Config: %s\n%s' % (filename, content.strip()), verbosity=3) - config_fd.write(content.encode('utf-8')) + config_fd.write(to_bytes(content)) config_fd.flush() def _read_config_template(self): |