Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PyPI requirements for cloud-init integration testing
# https://cloudinit.readthedocs.io/en/latest/topics/integration_tests.html
#
pycloudlib @ git+https://github.com/canonical/pycloudlib.git@e52cc257c5467bb16442a8ef943ca1931c4e1757
pycloudlib @ git+https://github.com/canonical/pycloudlib.git@d8c7654dbef1a7daf47417337e50515e6842aed6
pytest
23 changes: 17 additions & 6 deletions tests/integration_tests/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def launch(
user_data=None,
launch_kwargs=None,
settings=integration_settings,
**kwargs
**kwargs,
) -> IntegrationInstance:
if launch_kwargs is None:
launch_kwargs = {}
Expand Down Expand Up @@ -258,10 +258,6 @@ def _mount_source(instance: LXDInstance):
cloudinit_path = cloudinit.__path__[0]
mounts = [
(cloudinit_path, "/usr/lib/python3/dist-packages/cloudinit"),
(
os.path.join(cloudinit_path, "..", "config", "cloud.cfg.d"),
"/etc/cloud/cloud.cfg.d",
),
(
os.path.join(cloudinit_path, "..", "templates"),
"/etc/cloud/templates",
Expand All @@ -286,6 +282,21 @@ def _mount_source(instance: LXDInstance):
).format(**format_variables)
subp(command.split())

# /etc/cloud/cloud.cfg.d is a directory we write to in some
# integration tests. We can't use lxc mount in the container
# as /etc/cloud/cloud.cfg.d will then be owned nobody:nogroup and be
# read-only for root.
# Instead copy static files to the instance under test.
config_dir = os.path.join(
cloudinit_path, "..", "config", "cloud.cfg.d"
)
for src_file in os.listdir(config_dir):
command = (
f"lxc file push {config_dir}/{src_file} "
f"{instance.name}/etc/cloud/cloud.cfg.d/"
)
subp(command.split())

def _perform_launch(self, launch_kwargs, **kwargs):
launch_kwargs["inst_type"] = launch_kwargs.pop("instance_type", None)
wait = launch_kwargs.pop("wait", True)
Expand All @@ -304,7 +315,7 @@ def _perform_launch(self, launch_kwargs, **kwargs):
launch_kwargs.pop("name", default_name),
release,
profile_list=profile_list,
**launch_kwargs
**launch_kwargs,
)
if self.settings.CLOUD_INIT_SOURCE == "IN_PLACE":
self._mount_source(pycloudlib_instance)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def pull_file(self, remote_path, local_path):
# First copy to a temporary directory because of permissions issues
tmp_path = _get_tmp_path()
self.instance.execute("cp {} {}".format(str(remote_path), tmp_path))
self.instance.pull_file(tmp_path, str(local_path))
assert self.instance.pull_file(tmp_path, str(local_path)).ok

def push_file(self, local_path, remote_path):
# First push to a temporary directory because of permissions issues
tmp_path = _get_tmp_path()
self.instance.push_file(str(local_path), tmp_path)
self.execute("mv {} {}".format(tmp_path, str(remote_path)))
assert self.execute("mv {} {}".format(tmp_path, str(remote_path))).ok

def read_from_file(self, remote_path) -> str:
result = self.execute("cat {}".format(remote_path))
Expand Down