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
45 changes: 18 additions & 27 deletions tests/integration_tests/cmd/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
"""

Expand All @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions tests/integration_tests/test_ds_identify.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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()