Merge ~adam-collard/maas-ci/+git/system-tests:remove-unnecessary-fixtures into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: a26176fc782f99f330324dd41cfb375c9080f237
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas-ci/+git/system-tests:remove-unnecessary-fixtures
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 169 lines (+38/-10)
8 files modified
systemtests/collect_sos_report/test_collect.py (+5/-1)
systemtests/fixtures.py (+11/-5)
systemtests/general_tests/test_machine_config.py (+2/-0)
systemtests/o11y.py (+6/-2)
systemtests/tls.py (+6/-1)
systemtests/vault.py (+2/-0)
utils/filter_envs.py (+3/-0)
utils/gen_config.py (+3/-1)
Reviewer Review Type Date Requested Status
Jack Lloyd-Walters Approve
MAAS Lander Approve
Review via email: mp+436197@code.launchpad.net

Commit message

Don't launch a build_container for a snap run that doesn't use it

Fix annotations

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b remove-unnecessary-fixtures lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: a26176fc782f99f330324dd41cfb375c9080f237

review: Approve
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/systemtests/collect_sos_report/test_collect.py b/systemtests/collect_sos_report/test_collect.py
2index d8b1e5e..8b275b2 100644
3--- a/systemtests/collect_sos_report/test_collect.py
4+++ b/systemtests/collect_sos_report/test_collect.py
5@@ -1,9 +1,13 @@
6+from __future__ import annotations
7+
8 import contextlib
9 import subprocess
10 import tempfile
11 from pathlib import Path
12+from typing import TYPE_CHECKING
13
14-from ..lxd import Instance
15+if TYPE_CHECKING:
16+ from ..lxd import Instance
17
18
19 def collect_sos_report(instance: Instance, output: Path) -> None:
20diff --git a/systemtests/fixtures.py b/systemtests/fixtures.py
21index ba9bbb9..df540c8 100644
22--- a/systemtests/fixtures.py
23+++ b/systemtests/fixtures.py
24@@ -37,8 +37,10 @@ def _add_maas_ppa(
25
26
27 @pytest.fixture(scope="session")
28-def build_container(config: dict[str, Any]) -> Iterator[Instance]:
29+def build_container(config: dict[str, Any]) -> Optional[Iterator[Instance]]:
30 """Create a container for building MAAS package in."""
31+ if "snap" in config:
32+ yield None
33 log = getLogger(f"{LOG_NAME}.build_container")
34 lxd = get_lxd(log)
35 container_name = os.environ.get(
36@@ -69,10 +71,10 @@ def build_container(config: dict[str, Any]) -> Iterator[Instance]:
37
38 @pytest.fixture(scope="session")
39 def maas_deb_repo(
40- build_container: Instance, config: dict[str, Any]
41+ build_container: Optional[Instance], config: dict[str, Any]
42 ) -> Iterator[Optional[str]]:
43 """Build maas deb, and setup APT repo."""
44- if "snap" in config:
45+ if build_container is None:
46 yield None
47 else:
48 build_container.logger = getLogger(f"{LOG_NAME}.maas_deb_repo")
49@@ -181,7 +183,9 @@ def get_user_data(
50
51
52 @pytest.fixture(scope="session")
53-def maas_container(config: dict[str, Any], build_container: Instance) -> Instance:
54+def maas_container(
55+ config: dict[str, Any], build_container: Optional[Instance]
56+) -> Instance:
57 """Build a container for running MAAS in."""
58 lxd = get_lxd(getLogger(f"{LOG_NAME}.maas_container"))
59 profile_name = container_name = os.environ.get(
60@@ -189,7 +193,7 @@ def maas_container(config: dict[str, Any], build_container: Instance) -> Instanc
61 )
62 instance = Instance(lxd, container_name)
63 # FIXME: loggers could be a stack?
64- build_container.logger = instance.logger = lxd.logger
65+ instance.logger = lxd.logger
66 if not instance.exists():
67 if not lxd.profile_exists(profile_name):
68 lxd.copy_profile(LXD_PROFILE, profile_name)
69@@ -250,6 +254,8 @@ def maas_container(config: dict[str, Any], build_container: Instance) -> Instanc
70 )
71
72 if "snap" not in config:
73+ assert build_container is not None
74+ build_container.logger = instance.logger
75 build_container_ip = build_container.get_ip_address()
76 contents = dedent(
77 f"""\
78diff --git a/systemtests/general_tests/test_machine_config.py b/systemtests/general_tests/test_machine_config.py
79index 254f3dd..6e9152b 100644
80--- a/systemtests/general_tests/test_machine_config.py
81+++ b/systemtests/general_tests/test_machine_config.py
82@@ -1,3 +1,5 @@
83+from __future__ import annotations
84+
85 from ..machine_config import MachineConfig
86
87
88diff --git a/systemtests/o11y.py b/systemtests/o11y.py
89index 4dd4342..e95ba6e 100644
90--- a/systemtests/o11y.py
91+++ b/systemtests/o11y.py
92@@ -1,8 +1,11 @@
93+from __future__ import annotations
94+
95 from pathlib import Path
96 from textwrap import dedent
97-from typing import Any
98+from typing import TYPE_CHECKING, Any
99
100-from .lxd import Instance
101+if TYPE_CHECKING:
102+ from .lxd import Instance
103
104 AGENT_PATH = "/opt/agent/agent-linux-amd64"
105
106@@ -10,6 +13,7 @@ AGENT_PATH = "/opt/agent/agent-linux-amd64"
107 def setup_o11y(
108 o11y: dict[str, Any], maas_container: Instance, installed_from_snap: bool
109 ) -> None:
110+ """Runs telemetry in a systemd unit on the maas container."""
111 agent_on_container = maas_container.files[AGENT_PATH]
112 if not agent_on_container.exists():
113 host_path_to_agent = Path(o11y["grafana_agent_file_path"].strip())
114diff --git a/systemtests/tls.py b/systemtests/tls.py
115index 66cbdb4..53a739c 100644
116--- a/systemtests/tls.py
117+++ b/systemtests/tls.py
118@@ -1,4 +1,9 @@
119-from .lxd import Instance
120+from __future__ import annotations
121+
122+from typing import TYPE_CHECKING
123+
124+if TYPE_CHECKING:
125+ from .lxd import Instance
126
127 # Certs must be accessible for MAAS installed by snap, but
128 # this location is useful also when installed via deb package.
129diff --git a/systemtests/vault.py b/systemtests/vault.py
130index 178ea46..01e3e77 100644
131--- a/systemtests/vault.py
132+++ b/systemtests/vault.py
133@@ -1,3 +1,5 @@
134+from __future__ import annotations
135+
136 import json
137 import subprocess
138 import uuid
139diff --git a/utils/filter_envs.py b/utils/filter_envs.py
140index a233216..17afe71 100644
141--- a/utils/filter_envs.py
142+++ b/utils/filter_envs.py
143@@ -1,3 +1,6 @@
144+"""Filter the available environments by the given list."""
145+from __future__ import annotations
146+
147 import argparse
148 import subprocess
149 import sys
150diff --git a/utils/gen_config.py b/utils/gen_config.py
151index 98ed2ad..cb000a2 100755
152--- a/utils/gen_config.py
153+++ b/utils/gen_config.py
154@@ -1,4 +1,7 @@
155 #!/usr/bin/env python3
156+"""Generate specific system-test config from a base config and options."""
157+
158+from __future__ import annotations
159
160 import argparse
161 import pathlib
162@@ -11,7 +14,6 @@ yaml = YAML()
163
164
165 def main(argv: list[str]) -> int:
166-
167 parser = argparse.ArgumentParser()
168 parser.add_argument(
169 "base_config",

Subscribers

People subscribed via source and target branches

to all changes: