Skip to content

Commit

Permalink
fix(tests): use instance.clean/restart instead of clean --reboot (#5636)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
blackboxsw authored Aug 26, 2024
1 parent 8f741da commit 6e4343e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/integration_tests/cmd/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 6e4343e

Please sign in to comment.