Merge ~andersson123/autopkgtest-cloud:all-proposed-patch into autopkgtest-cloud:master

Proposed by Tim Andersson
Status: Merged
Merged at revision: 64f492d3b7d4f6cb215296986d5599d686ba952d
Proposed branch: ~andersson123/autopkgtest-cloud:all-proposed-patch
Merge into: autopkgtest-cloud:master
Diff against target: 175 lines (+38/-23)
4 files modified
charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker (+21/-6)
charms/focal/autopkgtest-web/webcontrol/browse.cgi (+8/-4)
charms/focal/autopkgtest-web/webcontrol/download-results (+1/-9)
charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html (+8/-4)
Reviewer Review Type Date Requested Status
Skia Approve
Review via email: mp+459627@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Andersson (andersson123) wrote :

Needs testing in staging.

Revision history for this message
Skia (hyask) wrote :

I've added a few inline comments. If you want to discuss the approach I'm proposing, feel free to ping me for a call.

review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) wrote :

I've tested this this morning with cowboys + charms etc. Now that I've rebased and cleaned up the commits, I'm going to build the charms one last time and re-test, then request review.

Revision history for this message
Tim Andersson (andersson123) wrote :

per Skia's review in a call we're having right now, I'll rename all the variables that use 'env' or something similar, to like additional_params

rabbitmq key will stay as "env"
database column will stay as "env"

e.g.
VARS_FOR_ENV
->
KEYS_FOR_ADDITIONAL_PARAMS

Revision history for this message
Tim Andersson (andersson123) wrote :

I'll also add comments to all my changes to explain why I made them.

Revision history for this message
Tim Andersson (andersson123) wrote :

(and what the variables are for etc)

Revision history for this message
Tim Andersson (andersson123) wrote :

I also should amend the way all-proposed is preserved in the retry link. Use a boolean value and have the jinja template handle the value, and incorporate "&all-proposed=1" in the retry url.

Revision history for this message
Tim Andersson (andersson123) wrote :
Revision history for this message
Tim Andersson (andersson123) wrote :

amended, I'm just going to test in staging now

Revision history for this message
Tim Andersson (andersson123) wrote :

Tested in staging, ready for re-review

Revision history for this message
Skia (hyask) wrote :

Last round of small fixes, nothing big

review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) wrote :

I kept the sameas for the reason described here:
https://stackoverflow.com/a/49331424

in the case the code gets changed and accidentally passes all_proposed as an int with value either 0 or 1, sameas will cause a traceback - which is intended since all_proposed should only be a boolean.

Revision history for this message
Skia (hyask) :
Revision history for this message
Tim Andersson (andersson123) wrote :

I'll amend

Revision history for this message
Tim Andersson (andersson123) wrote :

amended, please re-review

Revision history for this message
Skia (hyask) wrote :

Great, thanks!

review: Approve
Revision history for this message
Tim Andersson (andersson123) wrote :

Awesome, thank you. I'll wait for CI then I'll merge this.

Revision history for this message
Skia (hyask) wrote :

Lint issues

Revision history for this message
Tim Andersson (andersson123) wrote :

I amended the linting issues, just waiting for CI now

Revision history for this message
Tim Andersson (andersson123) wrote :

CI is tempfail here, I'm merging this

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
index ea31096..3744f06 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -79,6 +79,8 @@ ARCH_RELEASE_ALLOW_MAPPING = {
7979
80FAIL_CODES = (4, 6, 12, 14, 20)80FAIL_CODES = (4, 6, 12, 14, 20)
8181
82KEYS_FOR_ADDITIONAL_PARAMS = ["all-proposed"]
83
82# In the case of a tmpfail, look for these strings in the log and if they're84# In the case of a tmpfail, look for these strings in the log and if they're
83# found, consider this a real failure instead. This is useful if the test85# found, consider this a real failure instead. This is useful if the test
84# breaks the testbed so much that autopkgtest can't report a failure properly -86# breaks the testbed so much that autopkgtest can't report a failure properly -
@@ -319,7 +321,9 @@ def request_matches_per_package(package, arch, release, s):
319 )321 )
320322
321323
322def process_output_dir(dir, pkgname, code, triggers, all_proposed):324def process_output_dir(
325 dir, pkgname, code, triggers, additional_params: dict = None
326):
323 """Post-process output directory"""327 """Post-process output directory"""
324328
325 files = set(os.listdir(dir))329 files = set(os.listdir(dir))
@@ -349,12 +353,12 @@ def process_output_dir(dir, pkgname, code, triggers, all_proposed):
349 json.dump(d, testinfo, indent=True)353 json.dump(d, testinfo, indent=True)
350 files.add("testinfo.json")354 files.add("testinfo.json")
351355
352 # add all-proposed to testinfo.json if test was triggered with all-proposed=1356 if additional_params not in [None, {}]:
353 if all_proposed:
354 d = {}357 d = {}
355 with open(os.path.join(dir, "testinfo.json"), "r") as testinfo:358 with open(os.path.join(dir, "testinfo.json"), "r") as testinfo:
356 d = json.load(testinfo)359 d = json.load(testinfo)
357 d["all-proposed"] = 1360 for key, val in additional_params.items():
361 d[key] = val
358 with open(os.path.join(dir, "testinfo.json"), "w") as testinfo:362 with open(os.path.join(dir, "testinfo.json"), "w") as testinfo:
359 json.dump(d, testinfo, indent=True)363 json.dump(d, testinfo, indent=True)
360364
@@ -1243,12 +1247,23 @@ def request(msg):
1243 else:1247 else:
1244 f.write("%s\n" % params["readable-by"])1248 f.write("%s\n" % params["readable-by"])
12451249
1250 # List of key=value strings to be sent as a rabbitmq msg
1251 # These variables are optional additional parameters users
1252 # can employ when requesting a test which alters the behaviour
1253 additional_parameters = []
1254 # We also create it as a dict to easily insert into a json file
1255 additional_parameters_for_testinfo = {}
1256 for key in KEYS_FOR_ADDITIONAL_PARAMS:
1257 if params.get(key, None) is not None:
1258 additional_parameters.append("%s=%s" % (key, params[key]))
1259 additional_parameters_for_testinfo[key] = params[key]
1260
1246 (testpkg_version, duration, requester) = process_output_dir(1261 (testpkg_version, duration, requester) = process_output_dir(
1247 out_dir,1262 out_dir,
1248 pkgname,1263 pkgname,
1249 code,1264 code,
1250 params.get("triggers", []),1265 params.get("triggers", []),
1251 True if params.get("all-proposed", 0) == 1 else False,1266 additional_parameters_for_testinfo, # embed additional parameters in testinfo.json
1252 )1267 )
12531268
1254 # If two tests for the same package with different triggers finish at the1269 # If two tests for the same package with different triggers finish at the
@@ -1371,7 +1386,7 @@ def request(msg):
1371 "requester": requester,1386 "requester": requester,
1372 "swift_dir": swift_dir,1387 "swift_dir": swift_dir,
1373 "triggers": triggers,1388 "triggers": triggers,
1374 "all-proposed": 1 if "all-proposed" in params else 0,1389 "env": ",".join(additional_parameters),
1375 }1390 }
1376 )1391 )
1377 complete_amqp.basic_publish(1392 complete_amqp.basic_publish(
diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
index 9a86a66..4772be2 100755
--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
@@ -305,7 +305,7 @@ def package_release_arch(package, release, arch, _=None):
305 code = human_exitcode(row[4])305 code = human_exitcode(row[4])
306 version = row[1]306 version = row[1]
307 triggers = row[2]307 triggers = row[2]
308 env = row[308 additional_params = row[
309 6309 6
310 ] # string of comma separated env variables e.g. all-proposed=1,test-name=mytest310 ] # string of comma separated env variables e.g. all-proposed=1,test-name=mytest
311311
@@ -323,18 +323,22 @@ def package_release_arch(package, release, arch, _=None):
323 package,323 package,
324 row[0],324 row[0],
325 )325 )
326 all_proposed = (
327 additional_params is not None
328 and "all-proposed=1" in additional_params
329 )
326 results.append(330 results.append(
327 (331 (
328 version,332 version,
329 triggers,333 triggers,
330 env,334 additional_params,
331 human_date(row[0]),335 human_date(row[0]),
332 human_sec(row[3]),336 human_sec(int(row[3])),
333 requester,337 requester,
334 code,338 code,
335 url,339 url,
336 show_retry,340 show_retry,
337 "&all-proposed=1" if "all-proposed=1" in env else "",341 all_proposed,
338 )342 )
339 )343 )
340344
diff --git a/charms/focal/autopkgtest-web/webcontrol/download-results b/charms/focal/autopkgtest-web/webcontrol/download-results
index ca0de53..c36b5ab 100755
--- a/charms/focal/autopkgtest-web/webcontrol/download-results
+++ b/charms/focal/autopkgtest-web/webcontrol/download-results
@@ -79,14 +79,6 @@ def process_message(msg, db_con):
79 msg.channel.basic_ack(msg.delivery_tag)79 msg.channel.basic_ack(msg.delivery_tag)
80 return80 return
8181
82 env_vars = []
83 env_spec = {
84 "all-proposed": "all-proposed=1",
85 }
86 for env, spec in env_spec.items():
87 if env in info:
88 env_vars.append(spec)
89
90 test_id = get_test_id(db_con, release, arch, package)82 test_id = get_test_id(db_con, release, arch, package)
9183
92 try:84 try:
@@ -101,7 +93,7 @@ def process_message(msg, db_con):
101 duration,93 duration,
102 exitcode,94 exitcode,
103 requester,95 requester,
104 ",".join(env_vars),96 info.get("env", ""),
105 ),97 ),
106 )98 )
107 db_con.commit()99 db_con.commit()
diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
index 6ae5ab8..3da1e24 100644
--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
@@ -20,21 +20,25 @@
20 <td>{{row[1]}}</td>20 <td>{{row[1]}}</td>
21 <td>{{row[2]}}</td>21 <td>{{row[2]}}</td>
22 <td>{{row[3]}}</td>22 <td>{{row[3]}}</td>
23 <td class="{{row[4]}}">{{row[4]}}</td>
23 <td>24 <td>
24 {% if row[4] != "-" %}25 {% if row[5] != "-" %}
25 <a href="https://launchpad.net/~{{row[4]}}">{{row[4]}}</a>26 <a href="https://launchpad.net/~{{row[4]}}">{{row[4]}}</a>
26 {% else %}27 {% else %}
27 {{row[4]}}28 {{row[5]}}
28 {% endif %}29 {% endif %}
29 </td>30 </td>
30 <td class="{{row[5]}}">{{row[5]}}</td>
31 <td class="nowrap">31 <td class="nowrap">
32 <a href="{{row[7]}}/log.gz">log</a> &emsp;32 <a href="{{row[7]}}/log.gz">log</a> &emsp;
33 <a href="{{row[7]}}/artifacts.tar.gz">artifacts</a> &emsp;33 <a href="{{row[7]}}/artifacts.tar.gz">artifacts</a> &emsp;
34 {% if row[8] %}34 {% if row[8] %}
35 {% set ts = row[1].split()|map('urlencode')|join("&trigger=")|safe %}35 {% set ts = row[1].split()|map('urlencode')|join("&trigger=")|safe %}
36 {% set all_proposed = row[9] %}36 {% set all_proposed = row[9] %}
37 <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}{{all_proposed}}">&#9851;</a>37 {% if all_proposed %}
38 <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}&all-proposed=1">&#9851;</a>
39 {% else %}
40 <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}">&#9851;</a>
41 {% endif %}
38 {% endif %}42 {% endif %}
39 </td>43 </td>
40 </tr>44 </tr>

Subscribers

People subscribed via source and target branches