Merge ~adam-collard/maas-ci/+git/system-tests:lxd-vm-bug into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: ad35e0bff700625ef2d85b1d6812fbb8bed45215
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas-ci/+git/system-tests:lxd-vm-bug
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 83 lines (+19/-6)
4 files modified
systemtests/api.py (+1/-1)
systemtests/fixtures.py (+1/-1)
systemtests/lxd.py (+16/-3)
systemtests/utils.py (+1/-1)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Jack Lloyd-Walters Approve
Review via email: mp+426008@code.launchpad.net

Commit message

Several small fixes to get system-tests green

- No need to actually look at the results from grep

- Timeout on login

Avoid the multiple hour hang that we hit in http://maas-integration-ci.internal:8080/job/maas-system-tests/1355/

- Retry device removal

- Reverse the event logs so most recent is at the bottom

To post a comment you must log in.
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lxd-vm-bug lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: ad35e0bff700625ef2d85b1d6812fbb8bed45215

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/systemtests/api.py b/systemtests/api.py
2index 46d9dad..8279739 100644
3--- a/systemtests/api.py
4+++ b/systemtests/api.py
5@@ -108,7 +108,7 @@ class UnauthenticatedMAASAPIClient:
6 cmd = ["login", session, self.url, token]
7 if self.url.startswith("https://"):
8 cmd += ["--cacerts", f"{MAAS_CONTAINER_CERTS_PATH}cacerts.pem"]
9- output = self.execute(cmd)
10+ output = self.execute(cmd, base_cmd=["timeout", "5m", "maas"])
11 return output, AuthenticatedAPIClient(self, session)
12
13
14diff --git a/systemtests/fixtures.py b/systemtests/fixtures.py
15index 0bbfaf9..8a73fa3 100644
16--- a/systemtests/fixtures.py
17+++ b/systemtests/fixtures.py
18@@ -590,7 +590,7 @@ def maas_client_container(
19 f"{MAAS_CONTAINER_CERTS_PATH}cacerts.pem",
20 )
21 try:
22- lxd.execute(container, ["sh", "-c", "grep maas.under.test /etc/hosts"])
23+ lxd.execute(container, ["sh", "-c", "grep -q maas.under.test /etc/hosts"])
24 except subprocess.CalledProcessError:
25 lxd.execute(
26 container,
27diff --git a/systemtests/lxd.py b/systemtests/lxd.py
28index c2c1540..a7fec6e 100644
29--- a/systemtests/lxd.py
30+++ b/systemtests/lxd.py
31@@ -9,7 +9,7 @@ from itertools import chain
32 from pathlib import Path
33 from typing import TYPE_CHECKING, Optional
34
35-from retry.api import retry
36+from retry import retry
37
38 from .device_config import DeviceConfig, fmt_lxd_options
39 from .subprocess import run_with_logging
40@@ -82,7 +82,7 @@ class CLILXD:
41 self.logger.info(f"Container {name} created.")
42 self.logger.info("Waiting for boot to finish...")
43
44- @retry(tries=120, delay=1, exceptions=CloudInitDisabled, logger=self.logger)
45+ @retry(exceptions=CloudInitDisabled, tries=120, delay=1, logger=self.logger)
46 def _cloud_init_wait() -> None:
47 process = self.execute(
48 name, ["timeout", "2000", "cloud-init", "status", "--wait", "--long"]
49@@ -283,7 +283,20 @@ class CLILXD:
50 )
51
52 def remove_instance_device(self, instance_name: str, device_name: str) -> None:
53- self._run(["lxc", "config", "device", "remove", instance_name, device_name])
54+ """Remove a device from an instance."""
55+
56+ @retry(
57+ exceptions=subprocess.CalledProcessError,
58+ tries=5,
59+ delay=0.5,
60+ logger=self.logger,
61+ )
62+ def _remove_device() -> subprocess.CompletedProcess[str]:
63+ return self._run(
64+ ["lxc", "config", "device", "remove", instance_name, device_name]
65+ )
66+
67+ _remove_device()
68
69 def list_instances(self) -> dict[str, dict[str, Any]]:
70 result = self._run(["lxc", "list", "-f", "json"])
71diff --git a/systemtests/utils.py b/systemtests/utils.py
72index 37b2906..bc389ce 100644
73--- a/systemtests/utils.py
74+++ b/systemtests/utils.py
75@@ -174,7 +174,7 @@ def wait_for_machine(
76 debug_outputs.extend(
77 f"- {event['type']}"
78 + (f": {event['description']}" if event["description"] else "")
79- for event in events["events"]
80+ for event in reversed(events["events"])
81 )
82 raise UnexpectedMachineStatus(
83 machine["hostname"], status, retry_info.elapsed, debug_outputs

Subscribers

People subscribed via source and target branches

to all changes: