-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add integration test for validating Azure UUID case-insentive
- Loading branch information
1 parent
f059ac4
commit 5c199e9
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
""" Integration test for LP #1835584 | ||
Kernels prior to 4.15 report dmi product_uuid as uppercase, Azure | ||
relies on system UUID as their "instance-id". Upgrades to kernels >= 4.15 | ||
will represent the same product_uuid as lowercase. System UUID should be a | ||
case-insensitive comparison and avoid triggering "new instance" detection | ||
in cloud-init on Azure platform. | ||
The test will launch an Ubuntu image which has a 5.4 kernel. We allow | ||
cloud-init to detect the instance-id on the 5.4 kernel, set a 4.15 kernel as | ||
default and reboot the system. Expectation is that cloud-init retains same | ||
instance-id status and avoids triggering ssh host key regeneration across that | ||
reboot. | ||
Across the reboot, assert that we didn't re-run config_ssh by virtue of | ||
seeing only one semaphore creation log entry of type: | ||
Writing to /var/lib/cloud/instances/<UUID>/sem/config_ssh - | ||
https://bugs.launchpad.net/cloud-init/+bug/1897099 | ||
""" | ||
import re | ||
|
||
import pytest | ||
|
||
from tests.integration_tests.instances import IntegrationInstance | ||
|
||
|
||
KERNEL_URL = "https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.120/" | ||
PKG_VER = "4.14.120-0414120-generic_4.14.120-0414120.201905161610_amd64" | ||
PKGS = [ | ||
"linux-headers-4.14.120-0414120_4.14.120-0414120.201905161610_all.deb", | ||
"linux-headers-{pkg_ver}.deb".format(pkg_ver=PKG_VER), | ||
"linux-image-unsigned-{pkg_ver}.deb".format(pkg_ver=PKG_VER), | ||
"linux-modules-{pkg_ver}.deb".format(pkg_ver=PKG_VER), | ||
] | ||
|
||
# create a list of wgets to inject in #cloud-config runcmd below | ||
wgets = "\n".join( | ||
[" - 'wget {url}{pkg}'".format(url=KERNEL_URL, pkg=pkg) for pkg in PKGS] | ||
) | ||
|
||
USER_DATA = """\ | ||
#cloud-config | ||
runcmd: | ||
{wgets} | ||
- 'dpkg -i *.deb' | ||
""".format(wgets=wgets) | ||
|
||
|
||
def _check_iid_insensitive_across_kernel_upgrade(client): | ||
uuid = client.read_from_file('/sys/class/dmi/id/product_uuid') | ||
assert uuid.islower(), "UUID does not appear to be lowercase {}".format( | ||
uuid | ||
) | ||
orig_kernel = client.execute('uname -r').strip() | ||
assert "azure" in orig_kernel | ||
orig_kernel = client.execute('uname -r').strip() | ||
client.write_to_file( | ||
"/etc/default/grub.d/90-generic.cfg", | ||
"GRUB_FLAVOUR_ORDER=\"generic\"\n" | ||
) | ||
result = client.execute("update-grub") | ||
if not result.ok: | ||
raise Exception( | ||
"Unable to update grub for generic default: {}".format(result) | ||
) | ||
client.restart() | ||
new_kernel = client.execute('uname -r').strip() | ||
assert orig_kernel != new_kernel | ||
assert 'generic' in new_kernel | ||
uuid = client.read_from_file('/sys/class/dmi/id/product_uuid') | ||
assert uuid.isupper(), "UUID does not appear to be uppercase {}".format( | ||
uuid | ||
) | ||
log = client.read_from_file('/var/log/cloud-init.log') | ||
RE_CONFIG_SSH_SEMAPHORE = r'Writing.*sem/config_ssh ' | ||
ssh_runs = len(re.findall(RE_CONFIG_SSH_SEMAPHORE, log)) | ||
assert 1 == ssh_runs, "config_ssh ran too many times {}".format(ssh_runs) | ||
|
||
|
||
@pytest.mark.azure | ||
@pytest.mark.sru_next | ||
@pytest.mark.user_data(USER_DATA) | ||
def test_azure_kernel_upgrade_case_insensitive_uuid( | ||
client: IntegrationInstance | ||
): | ||
_check_iid_insensitive_across_kernel_upgrade(client) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters