Skip to content

Commit

Permalink
tests: datasourcenone use client.restart to block until done (#4635)
Browse files Browse the repository at this point in the history
Earlier iterations of this test exposed failure cases where
DataSourceNone and cloud-init status --wait would block indefinitely
in some failure modes. The primary failure mode was DataSourceNone
config on LXD containers due to invalid network config on virtual
NICs due to LP:#2022947 and newer netplan resulting in
tracebacks preventing init local and network boot stages from
persisting completion status to /run/cloud-init/status.json.

This is resolved already within the test by copying working
network config prior to DataSourceNone detection on lxd_containers.

The test can now rely on client.restart default blocking and retries
to avoid expiring all retries on platforms with slower reboots.
  • Loading branch information
blackboxsw committed Dec 1, 2023
1 parent a84d788 commit 90825eb
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions tests/integration_tests/datasources/test_none.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""DataSourceNone integration tests on LXD."""
import json

from pycloudlib.lxd.instance import LXDInstance

from tests.integration_tests.decorators import retry
from tests.integration_tests.instances import IntegrationInstance
from tests.integration_tests.util import verify_clean_log

Expand All @@ -20,18 +17,6 @@
"""


@retry(tries=90, delay=1)
def wait_for_cloud_init_status_file(instance: LXDInstance):
"""Wait for a non-empty status.json indicating cloud-init has started.
We don't wait for cloud-init to complete in this scenario as the failure
path on some images leaves us with cloud-init status blocking
indefinitely in the "running" state.
"""
status_file = instance.read_from_file("/run/cloud-init/status.json")
assert len(status_file)


def test_datasource_none_discovery(client: IntegrationInstance):
"""Integration test for #4635.
Expand All @@ -58,8 +43,8 @@ def test_datasource_none_discovery(client: IntegrationInstance):
"cp /etc/netplan/50-cloud-init.yaml"
" /etc/cloud/cloud.cfg.d/99-orig-net.cfg"
)
client.execute("cloud-init clean --logs --reboot")
wait_for_cloud_init_status_file(client)
client.execute("cloud-init clean --logs")
client.restart()
status = json.loads(client.execute("cloud-init status --format=json"))
assert [] == status["errors"]
expected_warnings = [
Expand All @@ -77,7 +62,6 @@ def test_datasource_none_discovery(client: IntegrationInstance):
raise AssertionError(
f"Unexpected recoverable errors: {list(unexpected_warnings)}"
)
client.execute("cloud-init status --wait")
log = client.read_from_file("/var/log/cloud-init.log")
verify_clean_log(log)
assert client.execute("test -f /var/tmp/success-with-datasource-none").ok

0 comments on commit 90825eb

Please sign in to comment.