Merge ~hyask/autopkgtest-cloud:skia/package_show_queued_jobs into autopkgtest-cloud:master

Proposed by Skia
Status: Merged
Merged at revision: 658e9b2fba4ade5bd7b7803cda9648a5f46c3fb3
Proposed branch: ~hyask/autopkgtest-cloud:skia/package_show_queued_jobs
Merge into: autopkgtest-cloud:master
Diff against target: 243 lines (+73/-47)
5 files modified
charms/focal/autopkgtest-web/webcontrol/browse.cgi (+26/-16)
charms/focal/autopkgtest-web/webcontrol/helpers/tests.py (+13/-3)
charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html (+3/-0)
charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html (+7/-28)
charms/focal/autopkgtest-web/webcontrol/templates/macros.html (+24/-0)
Reviewer Review Type Date Requested Status
Tim Andersson Approve
Review via email: mp+461122@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Andersson (andersson123) wrote :

Looks good brah, one inline comment which is just a question, not anything that needs fixing. Feel free to merge once CI passes :)

review: Approve
Revision history for this message
Skia (hyask) wrote :

See inline response. Don't hesitate to ask more regarding Jinja, I've quite some experience with that :-)

Revision history for this message
Tim Andersson (andersson123) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
2index f6be794..2918276 100755
3--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
4+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
5@@ -149,7 +149,7 @@ def get_release_arches():
6 return release_arches
7
8
9-def get_queue_info():
10+def get_queues_info():
11 """Return information about queued tests
12
13 Return (releases, arches, context -> release -> arch -> (queue_size, [requests])).
14@@ -280,6 +280,20 @@ def package_overview(package, _=None):
15 (k, v) for (k, v) in get_running_jobs().items() if k == package
16 )
17
18+ (_, _, queues_info) = get_queues_info()
19+ for queue_name, queue in queues_info.items():
20+ for release in queue:
21+ for arch in queue[release]:
22+ filtered_requests = [
23+ r
24+ for r in queue[release][arch][1]
25+ if r.startswith(package + "\n")
26+ ]
27+ queues_info[queue_name][release][arch] = (
28+ len(filtered_requests), # update the size too
29+ filtered_requests,
30+ )
31+
32 return render(
33 "browse-package.html",
34 package=package,
35@@ -293,6 +307,7 @@ def package_overview(package, _=None):
36 results=results,
37 title_suffix="- %s" % package,
38 running=running_info,
39+ queues_info=queues_info,
40 )
41
42
43@@ -368,19 +383,15 @@ def package_release_arch(package, release, arch, _=None):
44
45 @app.route("/running")
46 def running():
47- (releases, arches, queue_info) = get_queue_info()
48- queue_lengths = {}
49- for c in queue_info:
50+ (releases, arches, queues_info) = get_queues_info()
51+ queues_lengths = {}
52+ for c in queues_info:
53 for r in releases:
54 for a in arches:
55- # pylint: disable=unused-variable
56- (
57- queue_length,
58- queue_items,
59- ) = (
60- queue_info.get(c, {}).get(r, {}).get(a, (0, []))
61+ (queue_length, _) = (
62+ queues_info.get(c, {}).get(r, {}).get(a, (0, []))
63 )
64- queue_lengths.setdefault(c, {}).setdefault(r, {})[
65+ queues_lengths.setdefault(c, {}).setdefault(r, {})[
66 a
67 ] = queue_length
68
69@@ -388,11 +399,10 @@ def running():
70
71 return render(
72 "browse-running.html",
73- contexts=queue_info.keys(),
74 releases=releases,
75 arches=arches,
76- queue_info=queue_info,
77- queue_lengths=queue_lengths,
78+ queues_info=queues_info,
79+ queues_lengths=queues_lengths,
80 running=running_info,
81 )
82
83@@ -411,7 +421,7 @@ def admin():
84
85 @app.route("/queue_size.json")
86 def queuesize_json():
87- queue_info = get_queue_info()[2]
88+ queue_info = get_queues_info()[2]
89 # Strip the number of queue items, this is just their contents
90 for context in queue_info: # pylint: disable=consider-using-dict-items
91 for release in queue_info[context]:
92@@ -426,7 +436,7 @@ def queuesize_json():
93
94 @app.route("/queues.json")
95 def queues_json():
96- queue_info = get_queue_info()[2]
97+ queue_info = get_queues_info()[2]
98 # Strip the number of queue items, this is just their contents
99 for context in queue_info: # pylint: disable=consider-using-dict-items
100 for release in queue_info[context]:
101diff --git a/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py b/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py
102index 3e61e8c..504e855 100644
103--- a/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py
104+++ b/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py
105@@ -15,15 +15,25 @@ def populate_dummy_db(db_con):
106 (3, supported_releases[0], "ppc64el", "hello"),
107 (4, supported_releases[1], "ppc64el", "hello"),
108 (5, supported_releases[2], "amd64", "hello"),
109+ (6, supported_releases[2], "amd64", "hello2"),
110+ (7, supported_releases[2], "arm64", "hello2"),
111+ (8, supported_releases[3], "amd64", "hello2"),
112+ (9, supported_releases[3], "arm64", "hello2"),
113 ]
114 c.executemany("INSERT INTO test values(?, ?, ?, ?)", tests)
115 results = [
116 # fmt: off
117 # test_id | run_id | version | trigger | duration | exit_code | requester | env | uuid
118 (1, datetime.now(), "1.2.3", "hello/1.2.3", 42, 0, "hyask", "", str(uuid4())),
119- (1, datetime.now(), "1.2.3", "hello/1.2.3", 42, 0, "hyask", "all-proposed=1", str(uuid4())),
120- (2, datetime.now(), "1.2.3", "hello/1.2.3", 42, 0, "", "", str(uuid4())),
121- (3, datetime.now(), "1.2.3", "hello/1.2.3", 42, 20, "", "", str(uuid4())),
122+ (1, datetime.now(), "1.2.3", "hello/1.2.3", 42, 2, "hyask", "all-proposed=1", str(uuid4())),
123+ (2, datetime.now(), "1.2.3", "hello/1.2.3", 42, 4, "", "", str(uuid4())),
124+ (3, datetime.now(), "1.2.3", "hello/1.2.3", 42, 6, "", "", str(uuid4())),
125+ (4, datetime.now(), "1.2.3", "hello/1.2.3", 42, 8, "", "", str(uuid4())),
126+ (5, datetime.now(), "1.2.3", "hello/1.2.3", 42, 12, "", "", str(uuid4())),
127+ (6, datetime.now(), "2.0.0", "hello/1.2.3", 142, 14, "", "", str(uuid4())),
128+ (7, datetime.now(), "2.0.0", "hello/1.2.3", 142, 16, "", "", str(uuid4())),
129+ (8, datetime.now(), "2.0.0", "hello/1.2.3", 142, 20, "", "", str(uuid4())),
130+ (9, datetime.now(), "2.0.0", "hello/1.2.3", 142, 0, "", "", str(uuid4())),
131 # fmt: on
132 ]
133 c.executemany(
134diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
135index a313617..65d14de 100644
136--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
137+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
138@@ -26,4 +26,7 @@
139 {% for p, info in running.items()|sort %}
140 {{ macros.display_running_job(p, info) }}
141 {% endfor %}
142+
143+ <h3>Queued tests</h3>
144+ {{ macros.display_queues_info(queues_info) }}
145 {% endblock %}
146diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html
147index c876a22..86e555b 100644
148--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html
149+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html
150@@ -9,7 +9,7 @@
151 {% for column in running|sort|batch(3) %}
152 <tr>
153 {% for p in column %}
154- <td><a href="#pkg-{{p}}">{{p}}</a></td>
155+ <td><a href="#pkg-{{ p }}">{{ p }}</a></td>
156 {% endfor %}
157 </tr>
158 {% endfor %}
159@@ -19,18 +19,18 @@
160 <p>Click on the number in a cell to jump to the list of test requests for
161 that release and architecture which are waiting to be run.</p>
162
163- {% for context in ["ubuntu", "huge", "ppa", "upstream"] %}
164+ {% for context in queues_info.keys() %}
165 <table class="table-condensed table-striped" style="display: inline-block; padding-right: 30px">
166 <tr>
167- <th>{{context}}</th>
168- {% for a in arches %}<th>{{a}}</th>{% endfor %}
169+ <th>{{ context }}</th>
170+ {% for a in arches %}<th>{{ a }}</th>{% endfor %}
171 </tr>
172
173 {% for r in releases %}
174 <tr>
175- <td>{{r}}</td>
176+ <td>{{ r }}</td>
177 {% for a in arches %}
178- <td>{% if queue_lengths[context][r][a] %}<a href="#queue-{{context}}-{{r}}-{{a}}">{{queue_lengths[context][r][a]}} {% else %}-{% endif %}</td>
179+ <td>{% if queues_lengths[context][r][a] %}<a href="#queue-{{ context }}-{{ r }}-{{ a }}">{{ queues_lengths[context][r][a] }}</a>{% else %}-{% endif %}</td>
180 {% endfor %}
181 </tr>
182 {% endfor %}
183@@ -44,27 +44,6 @@
184 {% endfor %}
185
186 <!-- queue contents -->
187-
188- {% for context in contexts %}
189- {% for r in queue_info[context] %}
190- {% for a in queue_info[context][r] %}
191- {% if queue_info[context][r][a] %}
192- {% set (nreqs, reqs) = queue_info[context][r][a] %}
193- {% if nreqs > 0 %}
194- <table class="table-condensed table-striped" id="queue-{{context}}-{{r}}-{{a}}">
195- <thead>
196- <tr><th class="sticky-table-headers"><h3>Queued tests for {{context}} {{r}} {{a}}</h3></th></tr>
197- </thead>
198- <tbody>
199- {% for req in reqs %}
200- <tr><td>{{req}}</td></tr>
201- {% endfor %}
202- {% endif %}
203- </tbody>
204- </table>
205- {% endif %}
206- {% endfor %}
207- {% endfor %}
208- {% endfor %}
209+ {{ macros.display_queues_info(queues_info) }}
210
211 {% endblock %}
212diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
213index 244d64b..77400c8 100644
214--- a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
215+++ b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
216@@ -24,3 +24,27 @@
217 <hr>
218 {% endfor %}
219 {%- endmacro %}
220+
221+{% macro display_queues_info(queues_info) -%}
222+ {% for queue_name in queues_info.keys() -%}
223+ {% for r in queues_info[queue_name] -%}
224+ {% for a in queues_info[queue_name][r] -%}
225+ {% if queues_info[queue_name][r][a] -%}
226+ {% set (nreqs, reqs) = queues_info[queue_name][r][a] %}
227+ {%- if nreqs > 0 %}
228+ <table class="table-condensed table-striped" id="queue-{{ queue_name }}-{{ r }}-{{ a }}">
229+ <thead>
230+ <tr><th class="sticky-table-headers"><h3>Queued tests for {{ queue_name }} {{ r }} {{ a }}</h3></th></tr>
231+ </thead>
232+ <tbody>
233+ {% for req in reqs %}
234+ <tr><td>{{ req }}</td></tr>
235+ {% endfor %}
236+ </tbody>
237+ </table>
238+ {% endif %}
239+ {% endif %}
240+ {%- endfor %}
241+ {%- endfor %}
242+ {%- endfor %}
243+{%- endmacro %}

Subscribers

People subscribed via source and target branches