Merge ~adam-collard/maas-ci/+git/system-tests:handle-partial-proxy into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 535eb92e80325c7ad295d746e05073ff6a110628
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas-ci/+git/system-tests:handle-partial-proxy
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 117 lines (+31/-27)
1 file modified
systemtests/fixtures.py (+31/-27)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
MAAS Lander Approve
Review via email: mp+408940@code.launchpad.net

Commit message

Proxy configuration doesn't need to be complete

One should be able to configure the MAAS proxy without setting a proxy for the execution of tests

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

UNIT TESTS
-b handle-partial-proxy lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 083eaa69c1a355d247d35d5de6acc1dd143618d3

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

+1

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/fixtures.py b/systemtests/fixtures.py
2index 6e0760d..f97616b 100644
3--- a/systemtests/fixtures.py
4+++ b/systemtests/fixtures.py
5@@ -38,8 +38,7 @@ def build_container(config: dict[str, Any]) -> Iterator[str]:
6 else:
7 cloud_config = {}
8
9- proxy_config = config.get("proxy", {})
10- http_proxy = proxy_config.get("http", "")
11+ http_proxy = config.get("proxy", {}).get("http", "")
12 if http_proxy:
13 cloud_config["apt"] = {
14 "proxy": http_proxy,
15@@ -63,6 +62,7 @@ def maas_deb_repo(
16 yield None
17 else:
18 lxd = get_lxd(getLogger(f"{LOG_NAME}.maas_deb_repo"))
19+ build_ip = lxd.get_ip_address(build_container)
20 if not lxd.file_exists(build_container, "/var/www/html/repo/Packages.gz"):
21 lxd.execute(
22 build_container,
23@@ -116,18 +116,21 @@ def maas_deb_repo(
24 environment={"DEBIAN_FRONTEND": "noninteractive"},
25 )
26
27- proxy: Optional[dict[str, str]]
28- if "proxy" in config:
29- proxy = {
30- "http_proxy": config["proxy"]["http"],
31- "https_proxy": config["proxy"]["http"],
32- "no_proxy": lxd.get_ip_address(build_container),
33+ http_proxy = config.get("proxy", {}).get("http", "")
34+ proxy_env: Optional[dict[str, str]]
35+ if http_proxy:
36+ proxy_env = {
37+ "http_proxy": http_proxy,
38+ "https_proxy": http_proxy,
39+ "no_proxy": build_ip,
40 }
41 else:
42- proxy = None
43+ proxy_env = None
44
45 lxd.execute(
46- build_container, ["make", "-C", "maas", "package"], environment=proxy
47+ build_container,
48+ ["make", "-C", "maas", "package"],
49+ environment=proxy_env,
50 )
51 lxd.execute(
52 build_container,
53@@ -138,7 +141,7 @@ def maas_deb_repo(
54 ],
55 )
56 lxd.execute(build_container, ["mv", "build-area", "/var/www/html/repo"])
57- yield f"http://{lxd.get_ip_address(build_container)}/repo"
58+ yield f"http://{build_ip}/repo"
59
60
61 def get_user_data(
62@@ -213,10 +216,11 @@ def maas_container(config: dict[str, Any], build_container: str) -> Iterator[str
63 ]
64 },
65 }
66- if "proxy" in config:
67- proxy = config["proxy"]["http"]
68+ http_proxy = config.get("proxy", {}).get("http", "")
69+ if http_proxy:
70 snap_proxy_cmd = (
71- f'snap set system proxy.http="{proxy}" proxy.https="{proxy}"'
72+ f'snap set system proxy.http="{http_proxy}"'
73+ f'proxy.https="{http_proxy}"'
74 )
75 cloud_config["snap"]["commands"].insert(0, snap_proxy_cmd)
76 else:
77@@ -232,27 +236,27 @@ def maas_container(config: dict[str, Any], build_container: str) -> Iterator[str
78 with tempfile.NamedTemporaryFile("w") as f:
79 contents = dedent(
80 f"""\
81- Package: *
82- Pin: origin "{build_container_ip}"
83- Pin-Priority: 999
84- """
85+ Package: *
86+ Pin: origin "{build_container_ip}"
87+ Pin-Priority: 999
88+ """
89 )
90 f.write(contents)
91 f.flush()
92 lxd.push_file(container_name, f.name, apt_preference)
93
94- if "proxy" in config:
95- proxy = config["proxy"]["http"]
96- apt_conf = "/etc/apt/apt.conf.d/80maas-system-test"
97- with tempfile.NamedTemporaryFile("w") as f:
98- contents = dedent(
99- f"""\
100- Acquire::http::Proxy "{proxy}";
101- Acquire::https::Proxy "{proxy}";
102+ http_proxy = config.get("proxy", {}).get("http", "")
103+ if http_proxy:
104+ contents = dedent(
105+ f"""\
106+ Acquire::http::Proxy "{http_proxy}";
107+ Acquire::https::Proxy "{http_proxy}";
108 Acquire::http::Proxy::{build_container_ip} "DIRECT";
109 Acquire::https::Proxy::{build_container_ip} "DIRECT";
110 """
111- )
112+ )
113+ apt_conf = "/etc/apt/apt.conf.d/80maas-system-test"
114+ with tempfile.NamedTemporaryFile("w") as f:
115 f.write(contents)
116 f.flush()
117 lxd.push_file(container_name, f.name, apt_conf)

Subscribers

People subscribed via source and target branches

to all changes: