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: 0c0f08cf73b3cc5a152a6688dbfc86ead903ff86
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: 129 lines (+28/-1)
5 files modified
systemtests/api.py (+5/-0)
systemtests/conftest.py (+16/-0)
systemtests/lxd.py (+5/-0)
systemtests/subprocess.py (+1/-0)
tox.ini (+1/-1)
Reviewer Review Type Date Requested Status
Jack Lloyd-Walters Approve
Diego Mascialino (community) Approve
MAAS Lander Approve
Review via email: mp+427375@code.launchpad.net

Commit message

Add info to pytest header, hide helpers from traceback

Description of the change

Example output from before: https://paste.ubuntu.com/p/dy9m9H9Nfj/ and after: https://paste.ubuntu.com/p/M8jsyDFFwF/

we can see the failure much clearer when the subprocess helper is elided

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) :
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: 0c0f08cf73b3cc5a152a6688dbfc86ead903ff86

review: Approve
Revision history for this message
Diego Mascialino (dmascialino) :
review: Approve
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) wrote (last edit ):

+1, with small question

review: Approve
Revision history for this message
Adam Collard (adam-collard) :

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 7e68c0e..5e164f0 100644
3--- a/systemtests/api.py
4+++ b/systemtests/api.py
5@@ -106,12 +106,14 @@ class UnauthenticatedMAASAPIClient:
6 self.lxd.logger = logger
7
8 def execute(self, cmd: list[str], base_cmd: Optional[list[str]] = None) -> str:
9+ __tracebackhide__ = True
10 if base_cmd is None:
11 base_cmd = self.MAAS_CMD
12 result = self.lxd.execute(self.maas_container, base_cmd + cmd)
13 return result.stdout
14
15 def quietly_execute(self, cmd: list[str]) -> str:
16+ __tracebackhide__ = True
17 result = self.lxd.quietly_execute(self.maas_container, self.MAAS_CMD + cmd)
18 return result.stdout
19
20@@ -146,6 +148,7 @@ class AuthenticatedAPIClient:
21 self.api_client.logger = logger
22
23 def _execute(self, cmd: list[str]) -> str:
24+ __tracebackhide__ = True
25 return self.api_client.execute([self.session] + cmd)
26
27 def execute(
28@@ -154,6 +157,7 @@ class AuthenticatedAPIClient:
29 extra_params: Optional[dict[str, str]] = None,
30 json_output: bool = True,
31 ) -> Any:
32+ __tracebackhide__ = True
33 if extra_params:
34 cmd.extend([f"{k}={v}" for (k, v) in extra_params.items()])
35 output = self._execute(cmd)
36@@ -695,4 +699,5 @@ class QuietAuthenticatedAPIClient(AuthenticatedAPIClient):
37 return f"<QuietAuthenticatedAPIClient for {self.api_client.url!r}>"
38
39 def _execute(self, cmd: list[str]) -> str:
40+ __tracebackhide__ = True
41 return self.api_client.quietly_execute([self.session] + cmd)
42diff --git a/systemtests/conftest.py b/systemtests/conftest.py
43index 1c92187..cccd490 100644
44--- a/systemtests/conftest.py
45+++ b/systemtests/conftest.py
46@@ -93,6 +93,22 @@ def config(request: pytest.FixtureRequest) -> dict[str, Any]:
47 return config
48
49
50+def pytest_report_header(config: pytest.Config) -> list[str]:
51+ headers = []
52+ systemtests_config = config.getoption("--ss-config")
53+ package_type = "snap" if "snap" in systemtests_config else "deb"
54+ headers.append(f"packagetype: {package_type}")
55+ machines = ", ".join(
56+ machine_config.name
57+ for machine_config in generate_machines_config(systemtests_config)
58+ )
59+ headers.append(f"machines: {machines}")
60+ tls = "tls" in systemtests_config
61+ if tls:
62+ headers.append("tlsenabled: true")
63+ return headers
64+
65+
66 @pytest.hookimpl(tryfirst=True, hookwrapper=True) # type: ignore
67 def pytest_runtest_makereport(item: Any, call: Any) -> Iterator[Any]:
68 # execute all other hooks to obtain the report object
69diff --git a/systemtests/lxd.py b/systemtests/lxd.py
70index 29df65c..cc7ab97 100644
71--- a/systemtests/lxd.py
72+++ b/systemtests/lxd.py
73@@ -55,6 +55,7 @@ class CLILXD:
74 prefix: Optional[list[str]] = None,
75 logger: Optional[logging.Logger] = None,
76 ) -> subprocess.CompletedProcess[str]:
77+ __tracebackhide__ = True
78 if logger is None:
79 logger = self.logger
80 return run_with_logging(cmd, logger, prefix=prefix)
81@@ -177,6 +178,8 @@ class CLILXD:
82 executor: Callable[[], subprocess.CompletedProcess[str]],
83 logger: Optional[logging.Logger],
84 ) -> subprocess.CompletedProcess[str]:
85+ __tracebackhide__ = True
86+
87 # Retry the run, excepting websocket: bad handshake errors
88 @retry(exceptions=BadWebSocketHandshakeError, tries=3, logger=logger)
89 def _retry_bad_handshake() -> subprocess.CompletedProcess[str]:
90@@ -208,6 +211,7 @@ class CLILXD:
91 command: list[str],
92 environment: Optional[dict[str, str]] = None,
93 ) -> subprocess.CompletedProcess[str]:
94+ __tracebackhide__ = True
95 logger = self.logger.getChild(container)
96 lxc_command = self._get_lxc_command(container, environment)
97
98@@ -222,6 +226,7 @@ class CLILXD:
99 environment: Optional[dict[str, str]] = None,
100 ) -> subprocess.CompletedProcess[str]:
101 """Execute a command without logging it."""
102+ __tracebackhide__ = True
103 lxc_command = self._get_lxc_command(container, environment)
104
105 executor = partial(
106diff --git a/systemtests/subprocess.py b/systemtests/subprocess.py
107index 500e304..51ef9a5 100644
108--- a/systemtests/subprocess.py
109+++ b/systemtests/subprocess.py
110@@ -16,6 +16,7 @@ def run_with_logging(
111 env: Optional[dict[str, str]] = None,
112 prefix: Optional[list[str]] = None,
113 ) -> subprocess.CompletedProcess[str]:
114+ __tracebackhide__ = True
115 if prefix is None:
116 prefix = []
117 logger.info("┌ " + " ".join(repr(arg) if "\n" in arg else arg for arg in cmd))
118diff --git a/tox.ini b/tox.ini
119index 920433a..5f06548 100644
120--- a/tox.ini
121+++ b/tox.ini
122@@ -4,7 +4,7 @@ envlist = cog,lint,mypy,env_builder
123
124 [testenv]
125 commands=
126- pytest -k {envname} --log-file systemtests.{envname}.log --junit-xml=junit.{envname}.xml {posargs}
127+ pytest --pyargs systemtests -k {envname} --log-file systemtests.{envname}.log --junit-xml=junit.{envname}.xml {posargs}
128 setenv =
129 env_builder: PYTEST_ADDOPTS=--maxfail=1
130

Subscribers

People subscribed via source and target branches

to all changes: