From 6e4343eab55fcfdcf727905511b83e25254c38e3 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Mon, 26 Aug 2024 14:44:05 -0600 Subject: [PATCH] fix(tests): use instance.clean/restart instead of clean --reboot (#5636) Directly calling execute("cloud-init clean --logs --reboot") on an integration instances also involves awaiting a new boot id upon next interaction with with instance to ensure a reboot has actually taken place already on this target machine. Slow responding test instances/platforms may not completed the shutdown restart sequence yet when trying to iteract with an immediate blocking call to execut("cloud-init status --wait") which may exit early if accessing the prior instance boot before the reboot occurred. It is preferable to use inspect /proc/sys/kernel/random/boot_id before issuing a reboot request and block until a delta is seen in boot_id. This blocking wait on reboot and new boot_id is encapsulated inside pycloudlib.BaseInstance.restart which will inspect /proc/sys/kernel/random/boot_id before restart and block until a delta in boot_id across the requested restart. Fix test_status_block_through_all_boot_status to call instance.clean() and restart() to ensure we do not beat the instance reboot race with our post-boot assertions. --- tests/integration_tests/cmd/test_status.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration_tests/cmd/test_status.py b/tests/integration_tests/cmd/test_status.py index fe9946b06a0..de4222e2df5 100644 --- a/tests/integration_tests/cmd/test_status.py +++ b/tests/integration_tests/cmd/test_status.py @@ -19,9 +19,8 @@ def _remove_nocloud_dir_and_reboot(client: IntegrationInstance): # On Impish and below, NoCloud will be detected on an LXD container. # If we remove this directory, it will no longer be detected. client.execute("rm -rf /var/lib/cloud/seed/nocloud-net") - old_boot_id = client.instance.get_boot_id() - client.execute("cloud-init clean --logs --reboot") - client.instance._wait_for_execute(old_boot_id=old_boot_id) + client.instance.clean() + client.instance.restart() @retry(tries=30, delay=1) @@ -157,7 +156,8 @@ def test_status_block_through_all_boot_status(client): push_and_enable_systemd_unit( client, "before-cloud-init-local.service", BEFORE_CLOUD_INIT_LOCAL ) - client.execute("cloud-init clean --logs --reboot") + client.instance.clean() + client.instance.restart() wait_for_cloud_init(client).stdout.strip() client.execute("cloud-init status --wait")