summaryrefslogtreecommitdiff
path: root/tests/integration_tests/modules/test_combined.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration_tests/modules/test_combined.py')
-rw-r--r--tests/integration_tests/modules/test_combined.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py
index 43aa809e..7a9a6e27 100644
--- a/tests/integration_tests/modules/test_combined.py
+++ b/tests/integration_tests/modules/test_combined.py
@@ -222,6 +222,16 @@ class TestCombined:
== parsed_datasource
)
+ def test_cloud_id_file_symlink(self, class_client: IntegrationInstance):
+ cloud_id = class_client.execute("cloud-id").stdout
+ expected_link_output = (
+ "'/run/cloud-init/cloud-id' -> "
+ f"'/run/cloud-init/cloud-id-{cloud_id}'"
+ )
+ assert expected_link_output == str(
+ class_client.execute("stat -c %N /run/cloud-init/cloud-id")
+ )
+
def _check_common_metadata(self, data):
assert data["base64_encoded_keys"] == []
assert data["merged_cfg"] == "redacted for non-root user"
@@ -249,6 +259,10 @@ class TestCombined:
v1_data = data["v1"]
assert v1_data["cloud_name"] == "unknown"
assert v1_data["platform"] == "lxd"
+ assert v1_data["cloud_id"] == "lxd"
+ assert f"{v1_data['cloud_id']}" == client.read_from_file(
+ "/run/cloud-init/cloud-id-lxd"
+ )
assert (
v1_data["subplatform"]
== "seed-dir (/var/lib/cloud/seed/nocloud-net)"
@@ -270,6 +284,10 @@ class TestCombined:
v1_data = data["v1"]
assert v1_data["cloud_name"] == "unknown"
assert v1_data["platform"] == "lxd"
+ assert v1_data["cloud_id"] == "lxd"
+ assert f"{v1_data['cloud_id']}" == client.read_from_file(
+ "/run/cloud-init/cloud-id-lxd"
+ )
assert any(
[
"/var/lib/cloud/seed/nocloud-net" in v1_data["subplatform"],
@@ -291,6 +309,11 @@ class TestCombined:
v1_data = data["v1"]
assert v1_data["cloud_name"] == "aws"
assert v1_data["platform"] == "ec2"
+ # Different regions will show up as ec2-(gov|china)
+ assert v1_data["cloud_id"].startswith("ec2")
+ assert f"{v1_data['cloud_id']}" == client.read_from_file(
+ "/run/cloud-init/cloud-id-ec2"
+ )
assert v1_data["subplatform"].startswith("metadata")
assert (
v1_data["availability_zone"] == client.instance.availability_zone
@@ -310,6 +333,9 @@ class TestCombined:
v1_data = data["v1"]
assert v1_data["cloud_name"] == "gce"
assert v1_data["platform"] == "gce"
+ assert f"{v1_data['cloud_id']}" == client.read_from_file(
+ "/run/cloud-init/cloud-id-gce"
+ )
assert v1_data["subplatform"].startswith("metadata")
assert v1_data["availability_zone"] == client.instance.zone
assert v1_data["instance_id"] == client.instance.instance_id