Merge ~andersson123/autopkgtest-cloud:all-proposed-patch into autopkgtest-cloud:master
- Git
- lp:~andersson123/autopkgtest-cloud
- all-proposed-patch
- Merge into master
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) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Skia | Approve | ||
Review via email: mp+459627@code.launchpad.net |
Commit message
Description of the change
Tim Andersson (andersson123) wrote : | # |
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.
Tim Andersson (andersson123) : | # |
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.
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_
Tim Andersson (andersson123) wrote : | # |
I'll also add comments to all my changes to explain why I made them.
Tim Andersson (andersson123) wrote : | # |
(and what the variables are for etc)
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.
Tim Andersson (andersson123) wrote : | # |
resource for me incase I lose it
Tim Andersson (andersson123) wrote : | # |
amended, I'm just going to test in staging now
Tim Andersson (andersson123) wrote : | # |
Tested in staging, ready for re-review
Skia (hyask) wrote : | # |
Last round of small fixes, nothing big
Tim Andersson (andersson123) : | # |
Tim Andersson (andersson123) wrote : | # |
I kept the sameas for the reason described here:
https:/
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.
Skia (hyask) : | # |
Tim Andersson (andersson123) wrote : | # |
I'll amend
Tim Andersson (andersson123) wrote : | # |
amended, please re-review
Tim Andersson (andersson123) wrote : | # |
Awesome, thank you. I'll wait for CI then I'll merge this.
Skia (hyask) wrote : | # |
Lint issues
Tim Andersson (andersson123) wrote : | # |
I amended the linting issues, just waiting for CI now
Tim Andersson (andersson123) wrote : | # |
CI is tempfail here, I'm merging this
Preview Diff
1 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker |
2 | index ea31096..3744f06 100755 |
3 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker |
4 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker |
5 | @@ -79,6 +79,8 @@ ARCH_RELEASE_ALLOW_MAPPING = { |
6 | |
7 | FAIL_CODES = (4, 6, 12, 14, 20) |
8 | |
9 | +KEYS_FOR_ADDITIONAL_PARAMS = ["all-proposed"] |
10 | + |
11 | # In the case of a tmpfail, look for these strings in the log and if they're |
12 | # found, consider this a real failure instead. This is useful if the test |
13 | # breaks the testbed so much that autopkgtest can't report a failure properly - |
14 | @@ -319,7 +321,9 @@ def request_matches_per_package(package, arch, release, s): |
15 | ) |
16 | |
17 | |
18 | -def process_output_dir(dir, pkgname, code, triggers, all_proposed): |
19 | +def process_output_dir( |
20 | + dir, pkgname, code, triggers, additional_params: dict = None |
21 | +): |
22 | """Post-process output directory""" |
23 | |
24 | files = set(os.listdir(dir)) |
25 | @@ -349,12 +353,12 @@ def process_output_dir(dir, pkgname, code, triggers, all_proposed): |
26 | json.dump(d, testinfo, indent=True) |
27 | files.add("testinfo.json") |
28 | |
29 | - # add all-proposed to testinfo.json if test was triggered with all-proposed=1 |
30 | - if all_proposed: |
31 | + if additional_params not in [None, {}]: |
32 | d = {} |
33 | with open(os.path.join(dir, "testinfo.json"), "r") as testinfo: |
34 | d = json.load(testinfo) |
35 | - d["all-proposed"] = 1 |
36 | + for key, val in additional_params.items(): |
37 | + d[key] = val |
38 | with open(os.path.join(dir, "testinfo.json"), "w") as testinfo: |
39 | json.dump(d, testinfo, indent=True) |
40 | |
41 | @@ -1243,12 +1247,23 @@ def request(msg): |
42 | else: |
43 | f.write("%s\n" % params["readable-by"]) |
44 | |
45 | + # List of key=value strings to be sent as a rabbitmq msg |
46 | + # These variables are optional additional parameters users |
47 | + # can employ when requesting a test which alters the behaviour |
48 | + additional_parameters = [] |
49 | + # We also create it as a dict to easily insert into a json file |
50 | + additional_parameters_for_testinfo = {} |
51 | + for key in KEYS_FOR_ADDITIONAL_PARAMS: |
52 | + if params.get(key, None) is not None: |
53 | + additional_parameters.append("%s=%s" % (key, params[key])) |
54 | + additional_parameters_for_testinfo[key] = params[key] |
55 | + |
56 | (testpkg_version, duration, requester) = process_output_dir( |
57 | out_dir, |
58 | pkgname, |
59 | code, |
60 | params.get("triggers", []), |
61 | - True if params.get("all-proposed", 0) == 1 else False, |
62 | + additional_parameters_for_testinfo, # embed additional parameters in testinfo.json |
63 | ) |
64 | |
65 | # If two tests for the same package with different triggers finish at the |
66 | @@ -1371,7 +1386,7 @@ def request(msg): |
67 | "requester": requester, |
68 | "swift_dir": swift_dir, |
69 | "triggers": triggers, |
70 | - "all-proposed": 1 if "all-proposed" in params else 0, |
71 | + "env": ",".join(additional_parameters), |
72 | } |
73 | ) |
74 | complete_amqp.basic_publish( |
75 | diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi |
76 | index 9a86a66..4772be2 100755 |
77 | --- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi |
78 | +++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi |
79 | @@ -305,7 +305,7 @@ def package_release_arch(package, release, arch, _=None): |
80 | code = human_exitcode(row[4]) |
81 | version = row[1] |
82 | triggers = row[2] |
83 | - env = row[ |
84 | + additional_params = row[ |
85 | 6 |
86 | ] # string of comma separated env variables e.g. all-proposed=1,test-name=mytest |
87 | |
88 | @@ -323,18 +323,22 @@ def package_release_arch(package, release, arch, _=None): |
89 | package, |
90 | row[0], |
91 | ) |
92 | + all_proposed = ( |
93 | + additional_params is not None |
94 | + and "all-proposed=1" in additional_params |
95 | + ) |
96 | results.append( |
97 | ( |
98 | version, |
99 | triggers, |
100 | - env, |
101 | + additional_params, |
102 | human_date(row[0]), |
103 | - human_sec(row[3]), |
104 | + human_sec(int(row[3])), |
105 | requester, |
106 | code, |
107 | url, |
108 | show_retry, |
109 | - "&all-proposed=1" if "all-proposed=1" in env else "", |
110 | + all_proposed, |
111 | ) |
112 | ) |
113 | |
114 | diff --git a/charms/focal/autopkgtest-web/webcontrol/download-results b/charms/focal/autopkgtest-web/webcontrol/download-results |
115 | index ca0de53..c36b5ab 100755 |
116 | --- a/charms/focal/autopkgtest-web/webcontrol/download-results |
117 | +++ b/charms/focal/autopkgtest-web/webcontrol/download-results |
118 | @@ -79,14 +79,6 @@ def process_message(msg, db_con): |
119 | msg.channel.basic_ack(msg.delivery_tag) |
120 | return |
121 | |
122 | - env_vars = [] |
123 | - env_spec = { |
124 | - "all-proposed": "all-proposed=1", |
125 | - } |
126 | - for env, spec in env_spec.items(): |
127 | - if env in info: |
128 | - env_vars.append(spec) |
129 | - |
130 | test_id = get_test_id(db_con, release, arch, package) |
131 | |
132 | try: |
133 | @@ -101,7 +93,7 @@ def process_message(msg, db_con): |
134 | duration, |
135 | exitcode, |
136 | requester, |
137 | - ",".join(env_vars), |
138 | + info.get("env", ""), |
139 | ), |
140 | ) |
141 | db_con.commit() |
142 | diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html |
143 | index 6ae5ab8..3da1e24 100644 |
144 | --- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html |
145 | +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html |
146 | @@ -20,21 +20,25 @@ |
147 | <td>{{row[1]}}</td> |
148 | <td>{{row[2]}}</td> |
149 | <td>{{row[3]}}</td> |
150 | + <td class="{{row[4]}}">{{row[4]}}</td> |
151 | <td> |
152 | - {% if row[4] != "-" %} |
153 | + {% if row[5] != "-" %} |
154 | <a href="https://launchpad.net/~{{row[4]}}">{{row[4]}}</a> |
155 | {% else %} |
156 | - {{row[4]}} |
157 | + {{row[5]}} |
158 | {% endif %} |
159 | </td> |
160 | - <td class="{{row[5]}}">{{row[5]}}</td> |
161 | <td class="nowrap"> |
162 | <a href="{{row[7]}}/log.gz">log</a>   |
163 | <a href="{{row[7]}}/artifacts.tar.gz">artifacts</a>   |
164 | {% if row[8] %} |
165 | {% set ts = row[1].split()|map('urlencode')|join("&trigger=")|safe %} |
166 | {% set all_proposed = row[9] %} |
167 | - <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}{{all_proposed}}">♻</a> |
168 | + {% if all_proposed %} |
169 | + <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}&all-proposed=1">♻</a> |
170 | + {% else %} |
171 | + <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}">♻</a> |
172 | + {% endif %} |
173 | {% endif %} |
174 | </td> |
175 | </tr> |
Needs testing in staging.