From 6102ec61130022f04b0978446b5f560ae0111593 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 1 Jul 2024 15:10:03 -0500 Subject: [PATCH 1/3] test: Ensure deprecation test uses deprecated key 'ca-certs' doesn't warn on Focal. --- tests/integration_tests/cmd/test_status.py | 45 +++++++++------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/tests/integration_tests/cmd/test_status.py b/tests/integration_tests/cmd/test_status.py index 20c78433257..84d9b694f63 100644 --- a/tests/integration_tests/cmd/test_status.py +++ b/tests/integration_tests/cmd/test_status.py @@ -3,14 +3,12 @@ import pytest -from cloudinit.util import should_log_deprecation from tests.integration_tests.clouds import IntegrationCloud from tests.integration_tests.decorators import retry from tests.integration_tests.instances import IntegrationInstance from tests.integration_tests.integration_settings import PLATFORM from tests.integration_tests.releases import CURRENT_RELEASE, IS_UBUNTU, JAMMY from tests.integration_tests.util import ( - get_feature_flag_value, push_and_enable_systemd_unit, wait_for_cloud_init, ) @@ -65,8 +63,10 @@ def test_wait_when_no_datasource(session_cloud: IntegrationCloud, setup_image): USER_DATA = """\ #cloud-config +users: + - name: something + ssh-authorized-keys: ["something"] ca-certs: - remove_defaults: false invalid_key: true """ @@ -81,32 +81,23 @@ def test_status_json_errors(client): "DEPRECATED" ) - status_json = json.loads( - client.execute("cloud-init status --format json").stdout + status_json = client.execute("cloud-init status --format json").stdout + assert ( + "Deprecated cloud-config provided: users.0.ssh-authorized-keys" + in json.loads(status_json)["init"]["recoverable_errors"] + .get("DEPRECATED") + .pop(0) ) - version_boundary = get_feature_flag_value( - client, "DEPRECATION_INFO_BOUNDARY" + assert ( + "Deprecated cloud-config provided: users.0.ssh-authorized-keys:" + in json.loads(status_json)["recoverable_errors"] + .get("DEPRECATED") + .pop(0) ) - # The deprecation_version is 22.3 in schema for ca-certs. - # Expect an extra deprecation level log in status if boundary > 22.3 - if should_log_deprecation("22.3", version_boundary): - assert "Deprecated cloud-config provided: ca-certs" in status_json[ - "init" - ]["recoverable_errors"].get("DEPRECATED").pop(0) - assert "Deprecated cloud-config provided: ca-certs" in status_json[ - "recoverable_errors" - ].get("DEPRECATED").pop(0) - - assert "Key 'ca-certs' is deprecated in 22.1" in status_json["init"][ - "recoverable_errors" - ].get("DEPRECATED").pop(0) - assert "Key 'ca-certs' is deprecated in 22.1" in status_json[ - "recoverable_errors" - ].get("DEPRECATED").pop(0) - assert "cloud-config failed schema validation" in status_json["init"][ - "recoverable_errors" - ].get("WARNING").pop(0) - assert "cloud-config failed schema validation" in status_json[ + assert "cloud-config failed schema validation" in json.loads(status_json)[ + "init" + ]["recoverable_errors"].get("WARNING").pop(0) + assert "cloud-config failed schema validation" in json.loads(status_json)[ "recoverable_errors" ].get("WARNING").pop(0) From f30824594e117b6e94580b18a56fe2105676fcfb Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 1 Jul 2024 15:21:02 -0500 Subject: [PATCH 2/3] cloud-id lies on Focal so dont test for it --- tests/integration_tests/test_ds_identify.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration_tests/test_ds_identify.py b/tests/integration_tests/test_ds_identify.py index 2375dde7909..b2195d0f323 100644 --- a/tests/integration_tests/test_ds_identify.py +++ b/tests/integration_tests/test_ds_identify.py @@ -29,8 +29,6 @@ def test_ds_identify(client: IntegrationInstance): assert client.execute("cloud-init status --wait") datasource = MAP_PLATFORM_TO_DATASOURCE.get(PLATFORM, PLATFORM) - if "lxd" == datasource and "focal" == OS_IMAGE: - datasource = "nocloud" cloud_id = client.execute("cloud-id") assert cloud_id.ok assert datasource == cloud_id.stdout.rstrip() From d0df8513eefc0d221e36cbb730d66b0663ea0dee Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 1 Jul 2024 16:06:37 -0500 Subject: [PATCH 3/3] lint --- tests/integration_tests/test_ds_identify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests/test_ds_identify.py b/tests/integration_tests/test_ds_identify.py index b2195d0f323..59d3edd778f 100644 --- a/tests/integration_tests/test_ds_identify.py +++ b/tests/integration_tests/test_ds_identify.py @@ -1,7 +1,7 @@ """test that ds-identify works as expected""" from tests.integration_tests.instances import IntegrationInstance -from tests.integration_tests.integration_settings import OS_IMAGE, PLATFORM +from tests.integration_tests.integration_settings import PLATFORM from tests.integration_tests.util import verify_clean_log, wait_for_cloud_init DATASOURCE_LIST_FILE = "/etc/cloud/cloud.cfg.d/90_dpkg.cfg"