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
11 changes: 7 additions & 4 deletions tests/integration_tests/datasources/test_lxd_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def _customize_envionment(client: IntegrationInstance):
# Assert our platform can detect LXD during sytemd generator timeframe.
# Assert our platform can detect LXD during systemd generator timeframe.
ds_id_log = client.execute("cat /run/cloud-init/ds-identify.log").stdout
assert "check for 'LXD' returned found" in ds_id_log

Expand All @@ -35,6 +35,7 @@ def _customize_envionment(client: IntegrationInstance):
"/etc/cloud/cloud.cfg.d/99-detect-lxd-first.cfg",
"datasource_list: [LXD, NoCloud]\n",
)
# This is also to ensure that NoCloud can be detected
if ImageSpecification.from_os_image().release == "jammy":
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blackboxsw , this wasn't specifically related, but I don't see why this section would be needed/wanted in tests testing the LXD datasource. Is it ok to remove this or is there something I'm missing?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had originally put this in here for two reasons:

  1. allow ds-identify to detect two vaible datasources and ensure a tracer through the system was available to ensure a tracer through the system the even when multiple datasources are detected, priority order is honored when we get to python datasource get_data discovery. But, that is test case is handled anyway though by integration tests test_combined.py for each platform which don't modify default datasource_list config and manage to detect the right datasource).
  2. I also had the thought I wanted to be sure that we configure more than 1 datasource so ds-identify actually does run the dscheck_LXD and dscheck_NoCloud functions instead of skipping those discovery functions. But, I bet we can drop the seed file creation for two reasons:
    • we are configuring datasouce_list: [LXD, NoCloud] in /etc/cloud/cloud.cfg.d in this test which is what feeds ds-id's read_datasource_list so we don't limit ds-identify behavior because > 1 elements are in datasource_list
    • Any Bionic, Focal and Impish test is going to detect both NoCloud (from seed files) and LXD (from socket presence) so we have the inverse ordering test where 2 viable datasources are detected, but default priority order is honored by selecting NoCloud over LXD.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks. That makes sense. I can put it back.

# Add nocloud-net seed files because Jammy no longer delivers NoCloud
# (LP: #1958460).
Expand All @@ -47,8 +48,6 @@ def _customize_envionment(client: IntegrationInstance):
client.restart()


# This test should be able to work on any cloud whose datasource specifies
# a NETWORK dependency
@pytest.mark.lxd_container
@pytest.mark.lxd_vm
@pytest.mark.ubuntu # Because netplan
Expand Down Expand Up @@ -111,7 +110,11 @@ def test_lxd_datasource_discovery(client: IntegrationInstance):
assert "#cloud-config\ninstance-id" in ds_cfg["meta-data"]

# Jammy not longer provides nocloud-net seed files (LP: #1958460)
if ImageSpecification.from_os_image().release != "jammy":
if ImageSpecification.from_os_image().release in [
"bionic",
"focal",
"impish",
]:
# Assert NoCloud seed files are still present in non-Jammy images
# and that NoCloud seed files provide the same content as LXD socket.
nocloud_metadata = yaml.safe_load(
Expand Down
22 changes: 17 additions & 5 deletions tests/integration_tests/modules/test_combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,14 @@ def test_correct_datasource_detected(
parsed_datasource = json.loads(status_file)["v1"]["datasource"]

if client.settings.PLATFORM in ["lxd_container", "lxd_vm"]:
if ImageSpecification.from_os_image().release == "jammy":
datasource = "DataSourceLXD"
else:
if ImageSpecification.from_os_image().release in [
"bionic",
"focal",
"impish",
]:
datasource = "DataSourceNoCloud"
else:
datasource = "DataSourceLXD"
assert parsed_datasource.startswith(datasource)
else:
platform_datasources = {
Expand Down Expand Up @@ -246,7 +250,11 @@ def test_instance_json_lxd(self, class_client: IntegrationInstance):
data = json.loads(instance_json_file)
self._check_common_metadata(data)
v1_data = data["v1"]
if ImageSpecification.from_os_image().release == "jammy":
if ImageSpecification.from_os_image().release not in [
"bionic",
"focal",
"impish",
]:
cloud_name = "lxd"
subplatform = "LXD socket API v. 1.0 (/dev/lxd/sock)"
# instance-id should be a UUID
Expand Down Expand Up @@ -282,7 +290,11 @@ def test_instance_json_lxd_vm(self, class_client: IntegrationInstance):
data = json.loads(instance_json_file)
self._check_common_metadata(data)
v1_data = data["v1"]
if ImageSpecification.from_os_image().release == "jammy":
if ImageSpecification.from_os_image().release not in [
"bionic",
"focal",
"impish",
]:
cloud_name = "lxd"
subplatform = "LXD socket API v. 1.0 (/dev/lxd/sock)"
# instance-id should be a UUID
Expand Down