Skip to content

Commit ad984da

Browse files
authored
test: decouple netplan integrations from libnetplan SRU (#6085)
The netplan.io SRU on Jammy is in an unresolved publication state for 140 days. Avoid hard-coding cloud-init integration tests to expect a specific series to contain libnetplan and instead check the instance under test to confirm python3-netplan is installed before validating cloud-init behavior.
1 parent ee7b6aa commit ad984da

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

tests/integration_tests/cmd/test_schema.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
from cloudinit import lifecycle
88
from tests.integration_tests.instances import IntegrationInstance
9-
from tests.integration_tests.releases import CURRENT_RELEASE, JAMMY
109
from tests.integration_tests.util import (
1110
get_feature_flag_value,
11+
has_netplanlib,
1212
verify_clean_boot,
1313
verify_clean_log,
1414
)
@@ -103,7 +103,7 @@ def test_network_config_schema_validation(
103103
"annotate": NET_V1_ANNOTATED,
104104
},
105105
}
106-
if CURRENT_RELEASE >= JAMMY:
106+
if has_netplanlib(class_client):
107107
# Support for netplan API available
108108
content_responses[NET_CFG_V2] = {
109109
"out": "Valid schema /root/net.yaml"

tests/integration_tests/modules/test_combined.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
OS_IMAGE_TYPE,
2727
PLATFORM,
2828
)
29-
from tests.integration_tests.releases import CURRENT_RELEASE, IS_UBUNTU, JAMMY
29+
from tests.integration_tests.releases import CURRENT_RELEASE, IS_UBUNTU
3030
from tests.integration_tests.util import (
3131
get_feature_flag_value,
3232
get_inactive_modules,
33+
has_netplanlib,
3334
lxd_has_nocloud,
3435
network_wait_logged,
3536
verify_clean_boot,
@@ -99,13 +100,13 @@ def test_netplan_permissions(self, class_client: IntegrationInstance):
99100
Test that netplan config file is generated with proper permissions
100101
"""
101102
log = class_client.read_from_file("/var/log/cloud-init.log")
102-
if CURRENT_RELEASE < JAMMY:
103+
if has_netplanlib(class_client):
104+
assert "Rendered netplan config using netplan python API" in log
105+
else:
103106
assert (
104107
"No netplan python module. Fallback to write"
105108
" /etc/netplan/50-cloud-init.yaml" in log
106109
)
107-
else:
108-
assert "Rendered netplan config using netplan python API" in log
109110
file_perms = class_client.execute(
110111
"stat -c %a /etc/netplan/50-cloud-init.yaml"
111112
)

tests/integration_tests/util.py

+5
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,11 @@ def get_feature_flag_value(client: "IntegrationInstance", key):
590590
return value
591591

592592

593+
def has_netplanlib(client: "IntegrationInstance") -> bool:
594+
"""Return True if netplan python3 pkg is installed on the instance."""
595+
return client.execute("dpkg-query -W python3-netplan").ok
596+
597+
593598
def override_kernel_command_line(ds_str: str, instance: "IntegrationInstance"):
594599
"""set the kernel command line and reboot, return after boot done
595600

0 commit comments

Comments
 (0)