Skip to content

Commit

Permalink
test: Remove snapshot option from install_new_cloud_init (#4682)
Browse files Browse the repository at this point in the history
Integration tests allow for installing a new version of cloud-init with
the option of snapshotting the image after install. After taking
a snapshot, it will then set the snapshot as the default for *all*
future launches in this test run. This is also used by the conftest to
setup the initial image, but it should not be used anywhere else.

Rather than having it as an option to the install_new_cloud_init method,
remove the option and make the confest set the global snapshot instead.
This removes a footgun when writing other tests that need to install a
different version of cloud-init.
  • Loading branch information
TheRealFalcon committed Jan 17, 2024
1 parent 5b5eb8b commit 1c5726b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
4 changes: 1 addition & 3 deletions tests/integration_tests/bugs/test_lp1835584.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,5 @@ def test_azure_kernel_upgrade_case_insensitive_uuid(
# We can't use setup_image fixture here because we want to avoid
# taking a snapshot or cleaning the booted machine after cloud-init
# upgrade.
instance.install_new_cloud_init(
source, take_snapshot=False, clean=False
)
instance.install_new_cloud_init(source, clean=False)
_check_iid_insensitive_across_kernel_upgrade(instance)
3 changes: 3 additions & 0 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def setup_image(session_cloud: IntegrationCloud, request):
log.info("Setting up environment for %s", session_cloud.datasource)
client = session_cloud.launch()
client.install_new_cloud_init(source)
# All done customizing the image, so snapshot it and make it global
snapshot_id = client.snapshot()
client.cloud.snapshot_id = snapshot_id
# Even if we're keeping instances, we don't want to keep this
# one around as it was just for image creation
client.destroy()
Expand Down
4 changes: 0 additions & 4 deletions tests/integration_tests/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def snapshot(self):
def install_new_cloud_init(
self,
source: CloudInitSource,
take_snapshot=True,
clean=True,
):
if source == CloudInitSource.DEB_PACKAGE:
Expand All @@ -148,9 +147,6 @@ def install_new_cloud_init(
log.info("Installed cloud-init version: %s", version)
if clean:
self.instance.clean()
if take_snapshot:
snapshot_id = self.snapshot()
self.cloud.snapshot_id = snapshot_id

# assert with retry because we can compete with apt already running in the
# background and get: E: Could not get lock /var/lib/apt/lists/lock - open
Expand Down
4 changes: 1 addition & 3 deletions tests/integration_tests/test_kernel_commandline_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ def test_lxd_datasource_kernel_override_nocloud_net(
client.instance.execute_via_ssh = False # pyright: ignore
assert wait_for_cloud_init(client, num_retries=60).ok
if source.installs_new_version():
client.install_new_cloud_init(
source, take_snapshot=False, clean=False
)
client.install_new_cloud_init(source, clean=False)
override_kernel_cmdline(ds_str, client)

logs = client.execute("cat /var/log/cloud-init.log")
Expand Down
6 changes: 2 additions & 4 deletions tests/integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_clean_boot_of_upgraded_package(session_cloud: IntegrationCloud):
)

# Upgrade
instance.install_new_cloud_init(source, take_snapshot=False)
instance.install_new_cloud_init(source)

# 'cloud-init init' helps us understand if our pickling upgrade paths
# have broken across re-constitution of a cached datasource. Some
Expand Down Expand Up @@ -185,9 +185,7 @@ def test_subsequent_boot_of_upgraded_package(session_cloud: IntegrationCloud):
launch_kwargs = {"image_id": session_cloud.initial_image_id}

with session_cloud.launch(launch_kwargs=launch_kwargs) as instance:
instance.install_new_cloud_init(
source, take_snapshot=False, clean=False
)
instance.install_new_cloud_init(source, clean=False)
instance.restart()
log = instance.read_from_file("/var/log/cloud-init.log")
verify_clean_log(log)
Expand Down

0 comments on commit 1c5726b

Please sign in to comment.