Merge ~kissiel/hwcert-tools:add-beta-snap-build-step into hwcert-tools:master
- Git
- lp:~kissiel/hwcert-tools
- add-beta-snap-build-step
- Merge into master
Status: | Superseded |
---|---|
Proposed branch: | ~kissiel/hwcert-tools:add-beta-snap-build-step |
Merge into: | hwcert-tools:master |
Diff against target: |
1308 lines (+1200/-0) 18 files modified
LICENSE (+29/-0) README.md (+2/-0) src/cgi/plainbox-submit.cgi (+422/-0) src/cgi/preseed.cgi (+56/-0) src/cgi/unit-test.sh (+14/-0) src/crontab/autopilot/run-autopilot (+93/-0) src/crontab/autopilot/run-autopilot-staging (+7/-0) src/crontab/backup_mini_ci_result (+10/-0) src/crontab/checkbox/run-mini-ci (+146/-0) src/crontab/checkbox/run-mini-ci-staging (+7/-0) src/crontab/crontab (+233/-0) src/crontab/snapcraft/run-snapcraft (+9/-0) src/crontab/snapcraft/run-snapcraft-staging (+7/-0) src/www/autopilot/run-autopilot-auto.desktop (+8/-0) src/www/autopilot/run-autopilot-test.sh (+33/-0) src/www/snapcraft/run-snapcraft-test-launcher.sh (+17/-0) src/www/snapcraft/run-snapcraft-test.desktop (+8/-0) src/www/snapcraft/run-snapcraft-test.sh (+99/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Taihsiang Ho | Pending | ||
Canonical Hardware Certification | Pending | ||
Review via email: mp+320713@code.launchpad.net |
This proposal has been superseded by a proposal from 2017-03-28.
Commit message
Description of the change
Snapcraft Testing: bring testing of beta branch and tidy up the scripts
Taihsiang Ho (tai271828) wrote : | # |
Unmerged commits
- 7391692... by Maciej Kisielewski
-
add checking of the beta branch of checkbox-snappy
Also:
use lp:checkbox-snappy instead of the packaging branch from ~checkbox-dev
make failing one branch not stop the whole script
invoke checkbox-snappy from ~/ to avoid problems with calling from tmpsSigned-off-by: Maciej Kisielewski <email address hidden>
- 0f7c180... by Taihsiang Ho
-
Ask preseed.cgi to remove old grub loader.
- a04a106... by Taihsiang Ho
-
crontab: staging is stable. mv them to production.
- edbd241... by Taihsiang Ho
-
routine update of crontab
- de81f15... by Taihsiang Ho
-
add one more step to update snapcraft.
- 34caf44... by Taihsiang Ho
-
fix typo
- 555bac8... by Taihsiang Ho
-
specify correct staging conditions
- a7463a1... by Taihsiang Ho
-
use rtncode to check the checkbox-snappy build status.
- fb28361... by Taihsiang Ho
-
add staging switch
- a168be9... by Taihsiang Ho
-
use rtncode to check the checkbox-snappy build status.
Preview Diff
1 | diff --git a/LICENSE b/LICENSE |
2 | new file mode 100644 |
3 | index 0000000..4d1bea3 |
4 | --- /dev/null |
5 | +++ b/LICENSE |
6 | @@ -0,0 +1,29 @@ |
7 | +BSD 3-Clause License |
8 | + |
9 | +Copyright (c) 2016, taipei-cert-lab |
10 | +All rights reserved. |
11 | + |
12 | +Redistribution and use in source and binary forms, with or without |
13 | +modification, are permitted provided that the following conditions are met: |
14 | + |
15 | +* Redistributions of source code must retain the above copyright notice, this |
16 | + list of conditions and the following disclaimer. |
17 | + |
18 | +* Redistributions in binary form must reproduce the above copyright notice, |
19 | + this list of conditions and the following disclaimer in the documentation |
20 | + and/or other materials provided with the distribution. |
21 | + |
22 | +* Neither the name of the copyright holder nor the names of its |
23 | + contributors may be used to endorse or promote products derived from |
24 | + this software without specific prior written permission. |
25 | + |
26 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
27 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
28 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
29 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
30 | +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
31 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
32 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
33 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
34 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
35 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
36 | diff --git a/README.md b/README.md |
37 | new file mode 100644 |
38 | index 0000000..f848402 |
39 | --- /dev/null |
40 | +++ b/README.md |
41 | @@ -0,0 +1,2 @@ |
42 | +# mini-ci-legacy |
43 | +legacy mini CI |
44 | diff --git a/src/cgi/plainbox-submit.cgi b/src/cgi/plainbox-submit.cgi |
45 | new file mode 100755 |
46 | index 0000000..be6f5ad |
47 | --- /dev/null |
48 | +++ b/src/cgi/plainbox-submit.cgi |
49 | @@ -0,0 +1,422 @@ |
50 | +#!/usr/bin/env python |
51 | +# |
52 | +# put this file in: |
53 | +# /srv/enablement/cgi-bin/ |
54 | +# |
55 | + |
56 | +import os |
57 | +import posixpath |
58 | +import re |
59 | +import cgi |
60 | +import smtplib |
61 | +from email.mime.text import MIMEText |
62 | +from email.utils import formataddr |
63 | +from tempfile import NamedTemporaryFile |
64 | +from subprocess import Popen, PIPE |
65 | +from time import gmtime, strftime |
66 | +import pickle |
67 | +import shutil |
68 | +import sys |
69 | +from collections import defaultdict |
70 | + |
71 | + |
72 | +# delete the summary after it was sent? |
73 | +# WARNING: you have to remove the summary file |
74 | +# otherwise it will append and append the new results. |
75 | +DELETE_SUMMARY = True |
76 | +# 1 or True for debug mode on |
77 | +# False for off |
78 | +# if True, ce-qa mailing list will not get emails. |
79 | +DEBUG = False |
80 | +# send real email when debug mode is on |
81 | +# set True to get the email |
82 | +# only effective when using together with DEBUG |
83 | +DEBUG_EMAIL = True |
84 | + |
85 | +form = cgi.FieldStorage() |
86 | +if DEBUG: |
87 | + SUMMARY_FILE_NAME = "/tmp/plainbox-ci-summary.debug" |
88 | + SUMMARY_AUTOPILOT = "/tmp/minici-autopilot-summary.debug" |
89 | + SUMMARY_SNAPCRAFT = "/tmp/minici-snapcraft-summary.debug" |
90 | +else: |
91 | + SUMMARY_FILE_NAME = "/tmp/plainbox-ci-summary" |
92 | + SUMMARY_AUTOPILOT = "/tmp/minici-autopilot-summary" |
93 | + SUMMARY_SNAPCRAFT = "/tmp/minici-snapcraft-summary" |
94 | +PICKLE_FILE_NAME = "/tmp/plainbox-ci-old-status" |
95 | +INSTALLED_FILE_NAME = "/tmp/plainbox-ci-installed" |
96 | + |
97 | +print "Content-type: text/plain" |
98 | +print "\n" |
99 | + |
100 | +def rtn_code_to_status(code): |
101 | + if code == '0' or code == 0: |
102 | + return "PASS" |
103 | + else: |
104 | + return "FAIL" |
105 | + |
106 | +def get_subject(message): |
107 | + subject = "" |
108 | + if DEBUG: subject += "[TEST AND PLEASE IGNORE]" |
109 | + #subject += if_missing_run(message) |
110 | + subject += if_worse(message) |
111 | + subject += if_checkbox_crash(message) |
112 | + subject += if_fail_to_run(message) |
113 | + return subject |
114 | + |
115 | +def get_subject_build_snap(message, status): |
116 | + subject = "" |
117 | + if DEBUG: subject += "[TEST AND PLEASE IGNORE]" |
118 | + subject += '[' + rtn_code_to_status(status) + ']' |
119 | + return subject |
120 | + |
121 | +def if_missing_run(message): |
122 | + # TODO: |
123 | + # for fail to run jobs |
124 | + # the string should be the same |
125 | + subject = "" |
126 | + list_cid = ["201302-12681", |
127 | + "201212-12224", |
128 | + "201212-12226"] |
129 | + list_distribute = ["Ubuntu 12.04.5 LTS desktop", |
130 | + "Ubuntu 14.04.1 LTS desktop", |
131 | + "Ubuntu Vivid Vervet (development branch) desktop", |
132 | + "Ubuntu 12.04.5 LTS server", |
133 | + "Ubuntu 14.04.1 LTS server", |
134 | + "Ubuntu Vivid Vervet (development branch) server"] |
135 | + for i in list_cid + list_distribute: |
136 | + if i not in message: |
137 | + subject = "[run missing]" |
138 | + return subject |
139 | + |
140 | +def if_worse(message): |
141 | + subject = "" |
142 | + if "Overall trend: WORSE" in message: |
143 | + subject = "[run getting worse]" |
144 | + return subject |
145 | + |
146 | +def if_checkbox_crash(message): |
147 | + # TODO |
148 | + subject = "" |
149 | + return subject |
150 | + |
151 | +def if_fail_to_run(message): |
152 | + # TODO: will warn after failing to run in the recent 3 loops. |
153 | + subject = "" |
154 | + if "pass: 0, fail: 0" in message: |
155 | + subject = "[run failing]" |
156 | + return subject |
157 | + |
158 | + |
159 | +def create_data_obj(lines): |
160 | + """ |
161 | + create a data object |
162 | + |
163 | + return a data object to host the data of mini-CI reports. |
164 | + This report entries are separated by an empty lines for each cluster. |
165 | + |
166 | + :param lines: the lines given by the opened file readlines() |
167 | + :return mini-CI report data object |
168 | + """ |
169 | + obj = [] |
170 | + obj_sub = [] |
171 | + for line in lines: |
172 | + if line == "\n": |
173 | + obj.append(obj_sub) |
174 | + obj_sub = [] |
175 | + else: |
176 | + obj_sub.append(line) |
177 | + |
178 | + return obj |
179 | + |
180 | + |
181 | +def dump_to_string(minici_rpt_obj): |
182 | + """ |
183 | + dump mini-CI report data object to a string |
184 | + |
185 | + dump the data as a string so MIMEText could use it |
186 | + to send an email. |
187 | + |
188 | + :param minici_rpt_obj: mini-CI report data object |
189 | + :return string |
190 | + """ |
191 | + rtn_string = "" |
192 | + for entry in minici_rpt_obj: |
193 | + for line in entry: |
194 | + rtn_string += line |
195 | + rtn_string += "\n" |
196 | + |
197 | + return rtn_string |
198 | + |
199 | +################ begin of the mini-CI mailing flow ############## |
200 | +if 'emailit' in form: |
201 | + to_addr = [] |
202 | + try: |
203 | + summary_f = open(SUMMARY_FILE_NAME, "r") |
204 | + mini_ci_rpt_obj = create_data_obj(summary_f.readlines()) |
205 | + # sort the report so it is more readable. |
206 | + mini_ci_rpt_obj.sort() |
207 | + msg = MIMEText(dump_to_string(mini_ci_rpt_obj)) |
208 | + summary_f.close() |
209 | + if DELETE_SUMMARY: |
210 | + os.unlink(summary_f.name) |
211 | + except (IOError, OSError): |
212 | + print("Error trying to open the file %s" % SUMMARY_FILE_NAME) |
213 | + print(sys.exc_info()) |
214 | + sys.exit(1) |
215 | + msg_subject = get_subject(msg.as_string()) + " Summary of Plainbox mini-CI test runs" |
216 | + if 'dailyimage' in form: |
217 | + msg_subject = msg_subject + ' (daily build)' |
218 | + if 'amdgpu' in form: |
219 | + msg_subject = msg_subject + ' (AMD GPU on Xenial)' |
220 | + msg['Subject'] = msg_subject |
221 | + msg['From'] = formataddr(('mini-CI', 'certification@yantok.canonical.com')) |
222 | + msg['reply-to'] = 'ce-certification-qa@lists.canonical.com' |
223 | + if DEBUG: |
224 | + msg['To'] = 'yung.shen@canonical.com' |
225 | + to_addr.append(msg['To']) |
226 | + # add secondary email for testing: |
227 | + to_addr.append("taihsiang.ho@canonical.com") |
228 | + print(msg['Subject']) |
229 | + if not DEBUG_EMAIL: |
230 | + sys.exit(0) |
231 | + else: |
232 | + #msg['To'] = 'hardware-certification-team@lists.canonical.com' |
233 | + #msg['To'] = 'pes-tools-cert@lists.canonical.com' |
234 | + msg['To'] = 'ce-certification-qa@lists.canonical.com' |
235 | + to_addr.append(msg['To']) |
236 | + to_addr.append("will.cooke@canonical.com") |
237 | + s = smtplib.SMTP('localhost') |
238 | + s.sendmail(msg['From'], to_addr, msg.as_string()) |
239 | + s.quit() |
240 | +elif 'plainbox_output' in form and 'subject' in form: |
241 | + pickle_file = None |
242 | + previous_status = {} |
243 | + try: |
244 | + pickle_file = open(PICKLE_FILE_NAME, "r") |
245 | + previous_status = pickle.load(pickle_file) |
246 | + except: |
247 | + pass |
248 | + finally: |
249 | + if pickle_file: |
250 | + pickle_file.close() |
251 | + |
252 | + preamble = "This is output of the plainbox mini-ci run in Taipei\n\n" |
253 | + text = preamble + form['plainbox_output'].value |
254 | + f = NamedTemporaryFile() |
255 | + f.write(text) |
256 | + f.flush() |
257 | + #Curl it here and get the URL |
258 | + command=('curl -v -H "Expect:" --data-urlencode ' |
259 | + '"content@%s" -d "poster=roadmr@ubuntu.com" ' |
260 | + '-d "syntax=text" http://paste.ubuntu.com') % f.name |
261 | + process = Popen(command, stdout=PIPE, stderr=PIPE, shell=True) |
262 | + (output, sterr) = process.communicate() |
263 | + regex = re.compile(r"Location: (.+)") |
264 | + match = regex.search(sterr) |
265 | + if match: |
266 | + url = match.group(1) |
267 | + else: |
268 | + url = "No url, I probably had a problem pastebinning the log :(" |
269 | + f.close() # Auto deletes after closing |
270 | + |
271 | + status_tuples = re.findall(r"- (.+): (fail|pass)", text) |
272 | + status_dict = {} |
273 | + for (test, status) in status_tuples: |
274 | + status_dict[test] = status |
275 | + pass_count = len([s for s in status_dict.values() if s == 'pass']) |
276 | + fail_count = len([s for s in status_dict.values() if s == 'fail']) |
277 | + #Write to summary file |
278 | + sum_f = open(SUMMARY_FILE_NAME, "a") |
279 | + sum_f.write("%s at %s: results here: %s\n" % |
280 | + (form['subject'].value, |
281 | + strftime("%Y-%m-%d %H:%M UTC", gmtime()), |
282 | + url, )) |
283 | + sum_f.write("pass: %s, fail: %s" % (pass_count, fail_count)) |
284 | + # Figure out a trend |
285 | + old_status_dict = previous_status.get(form['subject'].value) |
286 | + if old_status_dict: |
287 | + # We need to report: |
288 | + # Tests that transitioned from pass to fail |
289 | + # Tests that transitioned from fail to pass |
290 | + # Tests that appeared (added) |
291 | + # Tests that disappeared (removed) |
292 | + # Overall trend (HOW TO DEFINE THIS?) |
293 | + trends = defaultdict(list) |
294 | + for (test, current_status) in status_dict.items(): |
295 | + old_status = old_status_dict.get(test) |
296 | + if old_status: |
297 | + # Existing test, trend it |
298 | + if old_status == "pass" and current_status == "fail": |
299 | + trends['pass_to_fail'].append(test) |
300 | + if old_status == "fail" and current_status == "pass": |
301 | + trends['fail_to_pass'].append(test) |
302 | + else: |
303 | + trends['added'].append(test) |
304 | + overall = 0 |
305 | + if 'pass_to_fail' in trends: |
306 | + overall = overall - len(trends['pass_to_fail']) |
307 | + sum_f.write("\n%s Tests got worse (%s)" % |
308 | + (len(trends['pass_to_fail']), |
309 | + ", ".join(trends['pass_to_fail']))) |
310 | + if 'fail_to_pass' in trends: |
311 | + overall = overall + len(trends['fail_to_pass']) |
312 | + sum_f.write("\n%s Tests got better (%s)" % |
313 | + (len(trends['fail_to_pass']), |
314 | + ", ".join(trends['fail_to_pass']))) |
315 | + if (overall < 0): overall_sign = " WORSE " |
316 | + elif (overall > 0): overall_sign = " BETTER " |
317 | + else: overall_sign = " STABLE " |
318 | + sum_f.write("\nOverall trend: %s" % overall_sign) |
319 | + sum_f.write("\n\n") |
320 | + sum_f.close() |
321 | + |
322 | + #Now pickle the fail/pass counts for later trending |
323 | + previous_status[form['subject'].value] = status_dict |
324 | + pickle_file = None |
325 | + try: |
326 | + pickle_file = open(PICKLE_FILE_NAME, "w") |
327 | + pickle.dump(previous_status, pickle_file) |
328 | + except: |
329 | + pass |
330 | + finally: |
331 | + if pickle_file: |
332 | + pickle_file.close() |
333 | +elif 'mini_ci_notification_installed' in form: |
334 | + installed_file = None |
335 | + try: |
336 | + installed_file = open(INSTALLED_FILE_NAME, "a") |
337 | + installed_file.write("%s at %s\n" % |
338 | + (form['mini_ci_notification_installed'].value, |
339 | + strftime("%Y-%m-%d %H:%M UTC", gmtime()))) |
340 | + except: |
341 | + pass |
342 | + finally: |
343 | + if installed_file: |
344 | + installed_file.close() |
345 | +elif 'mini_ci_notification_installed_reset' in form: |
346 | + installed_file = None |
347 | + try: |
348 | + installed_file = open(INSTALLED_FILE_NAME, "w") |
349 | + installed_file.write("%s at %s\n" % |
350 | + (form['mini_ci_notification_installed_reset'].value, |
351 | + strftime("%Y-%m-%d %H:%M UTC", gmtime()))) |
352 | + except: |
353 | + pass |
354 | + finally: |
355 | + if installed_file: |
356 | + installed_file.close() |
357 | +elif 'rm_summary_report' in form: |
358 | + # usage: |
359 | + # curl -F rm_summary_report="yes" http://localhost/cgi-bin/plainbox-submit.cgi |
360 | + try: |
361 | + os.unlink(SUMMARY_FILE_NAME) |
362 | + except: |
363 | + print "something is wrong when removing %s" % SUMMARY_FILE_NAME |
364 | +elif 'create_test_file' in form: |
365 | + # usage: |
366 | + # curl -F create_test_file="yes" http://localhost/cgi-bin/plainbox-submit.cgi |
367 | + test_file = open("/tmp/plainbox-ci-test", "w") |
368 | + test_file.close() |
369 | +elif 'email_mini_ci_autopilot' in form: |
370 | + try: |
371 | + summary_f = open(SUMMARY_AUTOPILOT, "r") |
372 | + msg = MIMEText(summary_f.read()) |
373 | + summary_f.close() |
374 | + os.unlink(summary_f.name) |
375 | + except (IOError, OSError): |
376 | + print("Error trying to open the file") |
377 | + print(sys.exc_info()) |
378 | + sys.exit(1) |
379 | + msg['Subject'] = get_subject(msg.as_string()) + " Summary of autopilot mini-CI test runs" |
380 | + msg['From'] = formataddr(('autopilot mini-CI', 'certification@yantok.canonical.com')) |
381 | + msg['reply-to'] = 'ce-certification-qa@lists.canonical.com' |
382 | + if DEBUG: |
383 | + msg['To'] = 'taihsiang.ho@canonical.com' |
384 | + print(msg['Subject']) |
385 | + if not DEBUG_EMAIL: |
386 | + sys.exit(0) |
387 | + else: |
388 | + #msg['To'] = 'hardware-certification-team@lists.canonical.com' |
389 | + #msg['To'] = 'pes-tools-cert@lists.canonical.com' |
390 | + msg['To'] = 'ce-certification-qa@lists.canonical.com' |
391 | + s = smtplib.SMTP('localhost') |
392 | + s.sendmail(msg['From'],[msg['To']], msg.as_string()) |
393 | + s.quit() |
394 | +elif 'autopilot_output' in form and 'autopilot_subject' in form: |
395 | + preamble = "This is output of the auto mini-ci run in Taipei\n\n" |
396 | + text = preamble + form['autopilot_output'].value |
397 | + if DEBUG: |
398 | + print text |
399 | + f = NamedTemporaryFile() |
400 | + f.write(text) |
401 | + f.flush() |
402 | + #Curl it here and get the URL |
403 | + command=('curl -v -H "Expect:" --data-urlencode ' |
404 | + '"content@%s" -d "poster=roadmr@ubuntu.com" ' |
405 | + '-d "syntax=text" http://paste.ubuntu.com') % f.name |
406 | + process = Popen(command, stdout=PIPE, stderr=PIPE, shell=True) |
407 | + (output, sterr) = process.communicate() |
408 | + regex = re.compile(r"Location: (.+)") |
409 | + match = regex.search(sterr) |
410 | + if match: |
411 | + url = match.group(1) |
412 | + if DEBUG: |
413 | + print url |
414 | + else: |
415 | + url = "No url, I probably had a problem pastebinning the log :(" |
416 | + f.close() # Auto deletes after closing |
417 | + |
418 | + #Write to summary file |
419 | + sum_f = open(SUMMARY_AUTOPILOT, "a") |
420 | + sum_f.write("%s at %s: results here: %s\n" % |
421 | + (form['autopilot_subject'].value, |
422 | + strftime("%Y-%m-%d %H:%M UTC", gmtime()), |
423 | + url, )) |
424 | + overall_result = text.splitlines()[-3:-1] |
425 | + sum_f.write("Overall result: %s" % str(overall_result)) |
426 | +elif 'email_mini_ci_snapcraft' in form and 'snapcraft_status' in form: |
427 | + try: |
428 | + summary_f = open(SUMMARY_SNAPCRAFT, "r") |
429 | + msg = MIMEText(summary_f.read()) |
430 | + summary_f.close() |
431 | + os.unlink(summary_f.name) |
432 | + except (IOError, OSError): |
433 | + print("Error trying to open the file") |
434 | + print(sys.exc_info()) |
435 | + sys.exit(1) |
436 | + msg['Subject'] = get_subject_build_snap(msg.as_string(), form['snapcraft_status'].value) + "[mini-CI] snapcraft build checkbox-snappy.snap" |
437 | + msg['From'] = formataddr(('Taipei Lab mini-CI', 'certification@yantok.canonical.com')) |
438 | + msg['reply-to'] = 'ce-certification-qa@lists.canonical.com' |
439 | + if DEBUG: |
440 | + msg['To'] = 'taihsiang.ho@canonical.com' |
441 | + print(msg['Subject']) |
442 | + if not DEBUG_EMAIL: |
443 | + sys.exit(0) |
444 | + else: |
445 | + #msg['To'] = 'hardware-certification-team@lists.canonical.com' |
446 | + #msg['To'] = 'pes-tools-cert@lists.canonical.com' |
447 | + msg['To'] = 'ce-certification-qa@lists.canonical.com' |
448 | + s = smtplib.SMTP('localhost') |
449 | + s.sendmail(msg['From'],[msg['To']], msg.as_string()) |
450 | + if DEBUG: |
451 | + print "emamil sent." |
452 | + s.quit() |
453 | +elif 'snapcraft_output' in form and 'snapcraft_subject' in form and 'snapcraft_status' in form: |
454 | + preamble = "=========================\n" |
455 | + preamble += "mini-CI Run in Taipei Lab\n" |
456 | + preamble += "=========================\n" |
457 | + preamble += "SUBMITTING TIME:\n" |
458 | + preamble += strftime("%Y-%m-%d %H:%M UTC", gmtime()) + "\n" |
459 | + preamble += "=========================\n" |
460 | + preamble += form['snapcraft_subject'].value + "\n" |
461 | + preamble += "=========================\n" |
462 | + preamble += "OVERALL STATUS: " + rtn_code_to_status(form['snapcraft_status'].value) + "\n" |
463 | + preamble += "=========================\n" |
464 | + text = preamble + form['snapcraft_output'].value |
465 | + if DEBUG: |
466 | + print text |
467 | + sum_f = open(SUMMARY_SNAPCRAFT, "w") |
468 | + sum_f.write(text + "\n") |
469 | + sum_f.close() |
470 | +else: |
471 | + print("unknown curl data") |
472 | diff --git a/src/cgi/preseed.cgi b/src/cgi/preseed.cgi |
473 | new file mode 100755 |
474 | index 0000000..51ed809 |
475 | --- /dev/null |
476 | +++ b/src/cgi/preseed.cgi |
477 | @@ -0,0 +1,56 @@ |
478 | +#!/usr/bin/env python |
479 | + |
480 | +import os |
481 | +import posixpath |
482 | +import logging |
483 | +FORMATTER = '[%(asctime)s] {%(lineno)d} %(message)s' |
484 | +logging.basicConfig(filename='/tmp/preseed-cgi.log',level=logging.INFO, format=FORMATTER) |
485 | + |
486 | +# Required environment variables |
487 | +SERVER_ADDR = os.environ["SERVER_ADDR"] |
488 | +REMOTE_ADDR = os.environ["REMOTE_ADDR"] |
489 | + |
490 | +# Optional environment variables |
491 | +CHECKBOX_PXELINUX_CFG = os.environ.get("CHECKBOX_PXELINUX_CFG", |
492 | + "/srv/enablement/tftpboot/pxelinux.cfg") |
493 | +CHECKBOX_GRUB_CFG = os.environ.get("CHECKBOX_GRUB_CFG", |
494 | + "/srv/enablement/tftpboot/grub") |
495 | +CHECKBOX_PRESEEDS = os.environ.get("CHECKBOX_PRESEEDS", |
496 | + "preseeds") |
497 | + |
498 | +# Convert the remote address to hex format |
499 | +hex_address = "".join("%02X" % int(x) for x in REMOTE_ADDR.split(".")) |
500 | + |
501 | +logging.info(SERVER_ADDR) |
502 | +logging.info(CHECKBOX_PRESEEDS) |
503 | +logging.info(REMOTE_ADDR) |
504 | +logging.info(hex_address) |
505 | + |
506 | +# Remove pxelinux configuration file for the host |
507 | +# 1. for legacy boot |
508 | +pxelinux_filename = posixpath.join(CHECKBOX_PXELINUX_CFG, hex_address) |
509 | +old_pxelinux_filename = pxelinux_filename + ".old" |
510 | +if posixpath.exists(pxelinux_filename): |
511 | + logging.info('boot over legacy.') |
512 | + if posixpath.exists(old_pxelinux_filename): |
513 | + os.unlink(old_pxelinux_filename) |
514 | + logging.info('done unlink.') |
515 | + os.rename(pxelinux_filename, old_pxelinux_filename) |
516 | + logging.info('done rename to be old.') |
517 | +# 2. for secure boot (using grub.cfg instead of hex_address preseed) |
518 | +# this naming style is defined by checkbox-satellite |
519 | +grubcfg_filename = posixpath.join(CHECKBOX_GRUB_CFG, REMOTE_ADDR + ".grub.cfg") |
520 | +old_grubcfg_filename = grubcfg_filename + ".old" |
521 | +if posixpath.exists(grubcfg_filename): |
522 | + logging.info('boot over grub.') |
523 | + if posixpath.exists(old_grubcfg_filename): |
524 | + logging.info(old_grubcfg_filename) |
525 | + os.unlink(old_grubcfg_filename) |
526 | + logging.info('done unlink') |
527 | + os.rename(grubcfg_filename, old_grubcfg_filename) |
528 | + logging.info('done rename to be old.') |
529 | + |
530 | +# Redirect to the preseed file |
531 | +print "Location: http://%s/%s/%s" % (SERVER_ADDR, CHECKBOX_PRESEEDS, hex_address) |
532 | +print "" |
533 | + |
534 | diff --git a/src/cgi/unit-test.sh b/src/cgi/unit-test.sh |
535 | new file mode 100755 |
536 | index 0000000..31db330 |
537 | --- /dev/null |
538 | +++ b/src/cgi/unit-test.sh |
539 | @@ -0,0 +1,14 @@ |
540 | +test_log="$HOME/mini-ci-log/for-dev" |
541 | +rm ${test_log}/plainbox-ci-summary |
542 | +ln -s ${test_log}/plainbox-ci-summary-01-ok ${test_log}/plainbox-ci-summary |
543 | +./plainbox-submit.cgi |
544 | + |
545 | +rm ${test_log}/plainbox-ci-summary |
546 | +ln -s ${test_log}/plainbox-ci-summary-02-fail-to-run ${test_log}/plainbox-ci-summary |
547 | +./plainbox-submit.cgi |
548 | + |
549 | +rm ${test_log}/plainbox-ci-summary |
550 | +ln -s ${test_log}/plainbox-ci-summary-03-worse-better ${test_log}/plainbox-ci-summary |
551 | +./plainbox-submit.cgi |
552 | + |
553 | +rm ${test_log}/plainbox-ci-summary |
554 | diff --git a/src/crontab/autopilot/run-autopilot b/src/crontab/autopilot/run-autopilot |
555 | new file mode 100755 |
556 | index 0000000..9f671ff |
557 | --- /dev/null |
558 | +++ b/src/crontab/autopilot/run-autopilot |
559 | @@ -0,0 +1,93 @@ |
560 | +#!/bin/bash |
561 | +# |
562 | +# $0 $1 $2 $3 $4 $5 $6 |
563 | +# run-mini-ci launch-reset 12.04.5 server CID |
564 | +# run-mini-ci installed-reboot 12.04.5 server CID |
565 | +# run-mini-ci installed-launch 12.04.5 server CID |
566 | +# run-mini-ci launch-done 12.04.5 server CID 12.04.4 desktop |
567 | +# |
568 | +#set -x |
569 | +# |
570 | +# alias |
571 | +# lt_minici 12.04.5 server CID |
572 | + |
573 | +if [ -z "$STAGING" ]; then |
574 | + export CHECKBOX_SRC=${CHECKBOX_SRC:-${HOME}/src} |
575 | +else |
576 | + export CHECKBOX_SRC=${CHECKBOX_SRC:-${HOME}/src.staging} |
577 | +fi |
578 | + |
579 | +lt_minici="$CHECKBOX_SRC/checkbox-message/trunk/bin/launch_testrun --autopilot --ppa=dev" |
580 | +dir_checkbox_message_outlet="$CHECKBOX_SRC/checkbox-message/trunk/outlets" |
581 | +command_manage_power="$CHECKBOX_SRC/checkbox-satellite/trunk/scripts/manage_power" |
582 | +pdu_setting_off='--retry=6 --sleep=0 --timeout=30 off apc://apc:apc@pdu11.yantok.taipei' |
583 | +pdu_setting_on='--retry=6 --sleep=0 --timeout=30 on apc://apc:apc@pdu11.yantok.taipei' |
584 | +cgi_url="http://localhost/cgi-bin/plainbox-submit.cgi" |
585 | +subject="CheckBox NG CI testing run for" |
586 | +message="after several reboots, it seems not to begin to run or completed the run." |
587 | + |
588 | +function reset_previous_results { |
589 | + curl -F mini_ci_notification_installed_reset="New mini ci loop cycle" $cgi_url |
590 | +} |
591 | + |
592 | +function launch_mini_ci { |
593 | + case $2 in |
594 | + "desktop") |
595 | + echo "$lt_minici $1 $2 $3" |
596 | + $lt_minici $1 $2 $3 > /tmp/mini-ci-${1}-${2}-${3}-autopilot-`date +%y%m%d` 2>&1 |
597 | + ;; |
598 | + "server") |
599 | + echo "$lt_minici $1 $2 $3" |
600 | + $lt_minici $1 $2 $3 > /tmp/mini-ci-${1}-${2}-${3}-`date +%y%m%d` 2>&1 |
601 | + esac |
602 | +} |
603 | + |
604 | +function pdu_off_on { |
605 | + local outlet=`grep outlet ${dir_checkbox_message_outlet}/$1 | awk -F: {'print $2'} | sed -e 's/^ *//'` |
606 | + $command_manage_power $pdu_setting_off "$outlet" |
607 | + # for some machines especially laptops with big or stable adapters |
608 | + # you have to off the power for longer time to wait the voltage is exactly down. |
609 | + sleep 60 |
610 | + $command_manage_power $pdu_setting_on "$outlet" |
611 | +} |
612 | + |
613 | +case $1 in |
614 | + "launch-reset") |
615 | + # reset the installed status summary and launch the machine |
616 | + # usually used in the beginning of a mini ci cycle |
617 | + reset_previous_results |
618 | + launch_mini_ci $2 $3 $4 |
619 | + ;; |
620 | + "launch") |
621 | + # launch <point-release> <desktop-server> CID |
622 | + launch_mini_ci $2 $3 $4 |
623 | + ;; |
624 | + "installed-reboot") |
625 | + # check the installed status of <desktop-server> CID |
626 | + # if no installed record is found, |
627 | + # power off and on the machine |
628 | + [ `grep -i $2 /tmp/plainbox-ci-installed | grep $3 | grep $4 | wc -l` -eq 0 ] && pdu_off_on $4 |
629 | + ;; |
630 | + "installed-launch") |
631 | + # check the installed status of <desktop-server> CID |
632 | + # if no installed record is found, |
633 | + # relaunch the machine |
634 | + [ `grep -i $2 /tmp/plainbox-ci-installed | grep $3 | grep $4 | wc -l` -eq 0 ] && launch_mini_ci $2 $3 $4 |
635 | + ;; |
636 | + "done-desktop") |
637 | + # to see whether the previous testing for desktop completed or not |
638 | + # if not, mark it as failure run. |
639 | + done_number=`grep $5 /tmp/plainbox-ci-summary | grep $6 | grep $4 | grep results | grep -v FAILED | wc -l` |
640 | + [ $done_number -eq 0 ] && curl -F subject="${subject} Ubuntu $5 $6 on $4 FAILED to run." -F plainbox_output="$message" $cgi_url |
641 | + ;; |
642 | + "done-server") |
643 | + # to see whether the previous testing for server completed or not |
644 | + # if not, mark it as failure run. |
645 | + # a workaround for server release that not using etho0 as its ethernet device, |
646 | + # so in plainbox-ci-summary the CID would not be shown. |
647 | + # Skip to grep CID otherwise it will always regard the result as FAILED. |
648 | + # Thus this command should be used specifically to server log. |
649 | + #done_number=`grep $5 /tmp/plainbox-ci-summary | grep $6 | grep $4 | grep results | grep -v FAILED | wc -l` |
650 | + done_number=`grep $5 /tmp/plainbox-ci-summary | grep $6 | grep $6 | grep results | grep -v FAILED | wc -l` |
651 | + [ $done_number -eq 0 ] && curl -F subject="${subject} Ubuntu $5 $6 on $4 FAILED to run." -F plainbox_output="$message" $cgi_url |
652 | +esac |
653 | diff --git a/src/crontab/autopilot/run-autopilot-staging b/src/crontab/autopilot/run-autopilot-staging |
654 | new file mode 100755 |
655 | index 0000000..f2ad17a |
656 | --- /dev/null |
657 | +++ b/src/crontab/autopilot/run-autopilot-staging |
658 | @@ -0,0 +1,7 @@ |
659 | +#!/bin/bash |
660 | + |
661 | +# if STAGING is not empty, $HOME/src.staging will be used instead of $HOME/src |
662 | +export STAGING='.src' |
663 | +dir=`dirname $0` |
664 | +$dir/run-autopilot "$@" |
665 | + |
666 | diff --git a/src/crontab/backup_mini_ci_result b/src/crontab/backup_mini_ci_result |
667 | new file mode 100755 |
668 | index 0000000..c50920c |
669 | --- /dev/null |
670 | +++ b/src/crontab/backup_mini_ci_result |
671 | @@ -0,0 +1,10 @@ |
672 | +#set -x |
673 | +for var in today yesterday |
674 | +do |
675 | + var_date_h=`date --date=$var +%y%m%d-%H` |
676 | + var_date=`date --date=$var +%y%m%d` |
677 | + dir_dest=/home/$USER/mini-ci-log/$var_date_h |
678 | + mkdir -p $dir_dest |
679 | + cp -a /tmp/plainbox-ci-* /tmp/mini-ci-*-$var_date $dir_dest |
680 | + rm /tmp/mini-ci-*-$var_date |
681 | +done |
682 | diff --git a/src/crontab/checkbox/run-mini-ci b/src/crontab/checkbox/run-mini-ci |
683 | new file mode 100755 |
684 | index 0000000..ee0a366 |
685 | --- /dev/null |
686 | +++ b/src/crontab/checkbox/run-mini-ci |
687 | @@ -0,0 +1,146 @@ |
688 | +#!/bin/bash |
689 | +# |
690 | +# $0 $1 $2 $3 $4 $5 $6 $7 |
691 | +# run-mini-ci launch-reset 12.04.5 server CID |
692 | +# run-mini-ci installed-reboot 12.04.5 server CID |
693 | +# run-mini-ci installed-launch 12.04.5 server CID |
694 | +# run-mini-ci launch-done 12.04.5 server CID 12.04.4 desktop |
695 | +# run-mini-ci launch-done 12.04.5 server CID 12.04.4 desktop -p |
696 | +# |
697 | +# $4 $5 $6 are key words used to can the plainbox summary report. |
698 | +# |
699 | +#set -x |
700 | +# |
701 | +# alias |
702 | +# lt_minici 12.04.5 server CID |
703 | + |
704 | +if [ -z "$STAGING" ]; then |
705 | + export CHECKBOX_SRC=${CHECKBOX_SRC:-${HOME}/src} |
706 | +else |
707 | + export CHECKBOX_SRC=${CHECKBOX_SRC:-${HOME}/src.staging} |
708 | +fi |
709 | + |
710 | +lt_minici="$CHECKBOX_SRC/checkbox-message/trunk/bin/launch_testrun --mini-ci --ppa=dev --plainbox" |
711 | +dir_checkbox_message_outlet="$CHECKBOX_SRC/checkbox-message/trunk/outlets" |
712 | +command_manage_power="$CHECKBOX_SRC/checkbox-satellite/trunk/scripts/manage_power" |
713 | +pdu_setting_off='--retry=6 --sleep=0 --timeout=30 off apc://apc:apc@pdu11.yantok.taipei' |
714 | +pdu_setting_on='--retry=6 --sleep=0 --timeout=30 on apc://apc:apc@pdu11.yantok.taipei' |
715 | +cgi_url="http://localhost/cgi-bin/plainbox-submit.cgi" |
716 | +subject="CheckBox NG CI testing run for" |
717 | +message="after several reboots, it seems not to begin to run or completed the run." |
718 | +# if you want to debug $cgi_url |
719 | +# make sure this file name is set up accordingly. |
720 | +if [ "$MINICIDEBUG" == "" ]; then |
721 | + summary_report="/tmp/plainbox-ci-summary" |
722 | +else |
723 | + summary_report="/tmp/plainbox-ci-summary.debug" |
724 | +fi |
725 | + |
726 | + |
727 | +function reset_previous_results { |
728 | + # clean old installed-flag-file and create a new one |
729 | + curl -F mini_ci_notification_installed_reset="New mini ci loop cycle" $cgi_url |
730 | + # remove the existing summary report |
731 | + curl -F rm_summary_report="yes" $cgi_url |
732 | +} |
733 | + |
734 | +function launch_mini_ci { |
735 | + case $2 in |
736 | + "desktop") |
737 | + echo "$lt_minici -w autotesting.whitelist $1 $2 $3 $4" |
738 | + $lt_minici -w autotesting.whitelist $1 $2 $3 $4 > /tmp/mini-ci-${1}-${2}-${3}-`date +%y%m%d` 2>&1 |
739 | + ;; |
740 | + "server") |
741 | + echo "$lt_minici $1 $2 $3 $4" |
742 | + $lt_minici $1 $2 $3 $4 > /tmp/mini-ci-${1}-${2}-${3}-`date +%y%m%d` 2>&1 |
743 | + esac |
744 | +} |
745 | + |
746 | + |
747 | +# tweak sleep time manually |
748 | +# so we could make the on-off switch longer |
749 | +# and the power supply of machines |
750 | +# could fully discharge and then wake up on power resume. |
751 | +# |
752 | +# pdu_off_on <cid> |
753 | +# |
754 | +function pdu_off_on { |
755 | + local outlet=`grep outlet ${dir_checkbox_message_outlet}/$1 | awk -F: {'print $2'} | sed -e 's/^ *//'` |
756 | + $command_manage_power $pdu_setting_off "$outlet" |
757 | + # for some machines especially laptops with big or stable adapters |
758 | + # you have to off the power for longer time to wait the voltage is exactly down. |
759 | + sleep 60 |
760 | + $command_manage_power $pdu_setting_on "$outlet" |
761 | +} |
762 | + |
763 | + |
764 | +function check_summary_rpt_name { |
765 | + number_of_rpt=`ls {/tmp/plainbox-ci-summary,/tmp/plainbox-ci-summary.debug} | grep -v "No such file or directory" | wc -l` |
766 | +} |
767 | + |
768 | +case $1 in |
769 | + "launch-reset") |
770 | + # reset the installed status summary and launch the machine |
771 | + # usually used in the beginning of a mini ci cycle |
772 | + reset_previous_results |
773 | + launch_mini_ci $2 $3 $4 |
774 | + ;; |
775 | + "launch") |
776 | + # launch <point-release> <desktop-server> CID |
777 | + launch_mini_ci $2 $3 $4 $7 |
778 | + ;; |
779 | + "installed-reboot") |
780 | + # seems no need to use this because we add kernel parameter no_hung to reboot the system. |
781 | + # |
782 | + # check the installed status of <desktop-server> CID |
783 | + # if no installed record is found, |
784 | + # power off and on the machine |
785 | + # |
786 | + # $0 $1 $2 $3 $4 $5 $6 |
787 | + # run-mini-ci launch-reset 12.04.5 server CID |
788 | + # |
789 | + # debug command: |
790 | + # grep -i 12.04.5 ./plainbox-ci-installed | grep server | grep 201209-11625 |
791 | + # |
792 | + # TODO: for server, the hostname is not shown as CID so check CID will always fail. |
793 | + # refer to the option "done-server" |
794 | + [ `grep -i $2 /tmp/plainbox-ci-installed | grep $3 | grep $4 | wc -l` -eq 0 ] && pdu_off_on $4 |
795 | + ;; |
796 | + "installed-launch") |
797 | + # seems no need to use this because we add kernel parameter no_hung to reboot the system. |
798 | + # |
799 | + # check the installed status of <desktop-server> CID |
800 | + # if no installed record is found, |
801 | + # relaunch the machine |
802 | + [ `grep -i $2 /tmp/plainbox-ci-installed | grep $3 | grep $4 | wc -l` -eq 0 ] && launch_mini_ci $2 $3 $4 |
803 | + ;; |
804 | + "done-desktop") |
805 | + # to see whether the previous testing for desktop completed or not |
806 | + # if not, mark it as failure run. |
807 | + # |
808 | + # $0 $1 $2 $3 $4 $5 $6 |
809 | + # run-mini-ci launch-done 12.04.5 server CID 12.04.4 desktop |
810 | + # grep 12.04.5 plainbox-ci-summary | grep desktop | grep 201302-12843 | grep results | grep -v FAILED | wc -l |
811 | + done_number=`grep $5 $summary_report | grep $6 | grep $4 | grep results | grep -v FAILED | wc -l` |
812 | + [ $done_number -eq 0 ] && curl -F subject="${subject} Ubuntu $5 $6 on $4 FAILED to run." -F plainbox_output="$message" $cgi_url |
813 | + ;; |
814 | + "done-server") |
815 | + # to see whether the previous testing for server completed or not |
816 | + # if not, mark it as failure run. |
817 | + # a workaround for server release that not using eth0 as its ethernet device, |
818 | + # so in plainbox-ci-summary the CID would not be shown. |
819 | + # Skip to grep CID otherwise it will always regard the result as FAILED. |
820 | + # Thus this command should be used specifically to server log. |
821 | + #done_number=`grep $5 /tmp/plainbox-ci-summary | grep $6 | grep $4 | grep results | grep -v FAILED | wc -l` |
822 | + done_number=`grep $5 $summary_report | grep $6 | grep $6 | grep results | grep -v FAILED | wc -l` |
823 | + [ $done_number -eq 0 ] && curl -F subject="${subject} Ubuntu $5 $6 on $4 FAILED to run." -F plainbox_output="$message" $cgi_url |
824 | + ;; |
825 | + "dry") |
826 | + # for testing |
827 | + # |
828 | + check_summary_rpt_name |
829 | + # one and only one summary report could exist |
830 | + [ $number_of_rpt -eq 1 ] || echo "plainbox-ci-summary name setting is incorrect." |
831 | + echo $summary_report |
832 | + echo $MINICIDEBUG |
833 | +esac |
834 | diff --git a/src/crontab/checkbox/run-mini-ci-staging b/src/crontab/checkbox/run-mini-ci-staging |
835 | new file mode 100755 |
836 | index 0000000..5cde4ff |
837 | --- /dev/null |
838 | +++ b/src/crontab/checkbox/run-mini-ci-staging |
839 | @@ -0,0 +1,7 @@ |
840 | +#!/bin/bash |
841 | +# |
842 | +# if STAGING is not empty, $HOME/src.staging will be used instead of $HOME/src |
843 | +export STAGING='.src' |
844 | +dir=`dirname $0` |
845 | +$dir/run-mini-ci "$@" |
846 | + |
847 | diff --git a/src/crontab/crontab b/src/crontab/crontab |
848 | new file mode 100644 |
849 | index 0000000..cebad1f |
850 | --- /dev/null |
851 | +++ b/src/crontab/crontab |
852 | @@ -0,0 +1,233 @@ |
853 | +# Edit this file to introduce tasks to be run by cron. |
854 | +# |
855 | +# Each task to run has to be defined through a single line |
856 | +# indicating with different fields when the task will be run |
857 | +# and what command to run for the task |
858 | +# |
859 | +# To define the time you can provide concrete values for |
860 | +# minute (m), hour (h), day of month (dom), month (mon), |
861 | +# and day of week (dow) or use '*' in these fields (for 'any').# |
862 | +# Notice that tasks will be started based on the cron's system |
863 | +# daemon's notion of time and timezones. |
864 | +# |
865 | +# Output of the crontab jobs (including errors) is sent through |
866 | +# email to the user the crontab file belongs to (unless redirected). |
867 | +# |
868 | +# For example, you can run a backup of all your user accounts |
869 | +# at 5 a.m every week with: |
870 | +# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ |
871 | +# |
872 | +# For more information see the manual pages of crontab(5) and cron(8) |
873 | +# |
874 | +# m h dom mon dow command |
875 | + |
876 | +# yantok time + 8hr = Taipei lab time |
877 | + |
878 | +# crontab action notifications |
879 | +MAILTO="taihsiang.ho@canonical.com" |
880 | + |
881 | +################ MINI CI LOOP SETTING ############################# |
882 | +# for launch_testrun |
883 | +# please use your own yantok username, replace following "certification"s to your login |
884 | +USER=taihsiang |
885 | +# setting PATH is necessary to use |
886 | +# sudo /usr/bin/service isc-dhcp-server restart |
887 | +# (requested by checkbox-satellite) |
888 | +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games |
889 | +# alias |
890 | +lt=/home/taihsiang/src/checkbox-message/trunk/bin/launch_testrun |
891 | +lt_staging=/home/taihsiang/src.staging/checkbox-message/trunk/bin/launch_testrun |
892 | +run_mini_ci=/srv/enablement/www/mini-ci-legacy/src/crontab/checkbox/run-mini-ci |
893 | +run_mini_ci_staging=/srv/enablement/www/mini-ci-legacy/src/crontab/checkbox/run-mini-ci-staging |
894 | +run_autopilot=/srv/enablement/www/mini-ci-legacy/src/crontab/autopilot/run-autopilot |
895 | +run_autopilot_staging=/srv/enablement/www/mini-ci-legacy/src/crontab/autopilot/run-autopilot-staging |
896 | +run_snapcraft=/srv/enablement/www/mini-ci-legacy/src/crontab/snapcraft/run-snapcraft |
897 | +run_snapcraft_staging=/srv/enablement/www/mini-ci-legacy/src/crontab/snapcraft/run-snapcraft-staging |
898 | +backup_mini_ci_result=/srv/enablement/www/mini-ci-legacy/src/crontab/backup_mini_ci_result |
899 | +# local variables |
900 | +satellite_ip=10.101.47.1 |
901 | + |
902 | +############ test hardware CID #################################### |
903 | +# fake |
904 | +#mini_ci_machine_c=111111-11111 |
905 | + |
906 | +# Lenovo ThinkCentre Edge 91z |
907 | +# back to OEM |
908 | +mini_ci_machine_a=201212-12224 |
909 | + |
910 | +# HP Pavilion Slimline 400 Desktop PC certied with 14.04 |
911 | +#mini_ci_machine_b=201305-13517 |
912 | + |
913 | +# Dell OptiPlex 3011 |
914 | +# 14.04 certificated |
915 | +mini_ci_machine_b=201302-12681 |
916 | + |
917 | +# Lenovo ThinkCentre M62z |
918 | +# BCM failed |
919 | +mini_ci_machine_c=201212-12226 |
920 | + |
921 | +# Acer AT110 F2 |
922 | +mini_ci_machine_d=201209-11625 |
923 | + |
924 | +#HP Pavilion P2 |
925 | +mini_ci_machine_e=201206-11407 |
926 | + |
927 | +# Dell Optiplex 3030 |
928 | +# 14.04.1 will fail to have ethernet at the last stage. |
929 | +#mini_ci_machine_d=201401-14498 |
930 | + |
931 | +#system broken |
932 | +#mini_ci_machine_f=201109-9789 swap to below: |
933 | +mini_ci_machine_f=201209-11784 |
934 | + |
935 | +# Dell Optiplex 9020 AIO |
936 | +# needs BCM proprietary driver |
937 | +mini_ci_machine_g=201211-12157 |
938 | + |
939 | +# HP Pavilion 23 AIO - Heineken |
940 | +# needs BCM proprietary driver |
941 | +mini_ci_machine_h=201206-11396 |
942 | + |
943 | +# SRU precise 3.13 test unit |
944 | +# no bluetooth, so sad |
945 | +mini_ci_machine_i=201302-12728 |
946 | + |
947 | +# Dell Latitude 3330 - Austin |
948 | +# a laptop without bt |
949 | +# 12.04.5 certified |
950 | +mini_ci_machine_j=201302-12843 |
951 | + |
952 | +# SRU trusty 3.13 test unit |
953 | +mini_ci_machine_k=201301-12632 |
954 | + |
955 | +# was for 15.04, but now for xenial desktop only |
956 | +mini_ci_machine_l=201401-14498 |
957 | + |
958 | + |
959 | +########################################### |
960 | +# |
961 | +# machine usage list |
962 | +# |
963 | +# convention: m for machine |
964 | +# |
965 | +########################################### |
966 | +m_12_04_5_desktop=201302-12843 |
967 | +m_14_04_4_desktop=201401-14498 |
968 | +m_16_04_desktop=201302-12843 |
969 | +m_16_10_desktop=201302-12681 |
970 | +m_zesty_daily_desktop=201302-12681 |
971 | + |
972 | +m_12_04_5_server=201209-11625 |
973 | +m_14_04_4_server=201209-11625 |
974 | +m_16_04_server=201209-11625 |
975 | +m_yakkety_daily_server=201302-12681 |
976 | + |
977 | +m_16_04_amdgpu_1=201302-12843 |
978 | +m_16_04_amdgpu_2=201302-12681 |
979 | +#m_16_04_amdgpu_2=$mini_ci_machine_a |
980 | +m_16_04_amdgpu_4=$m_14_04_4_desktop |
981 | + |
982 | +m_autopilot=201401-14498 |
983 | +m_snapcraft=201401-14498 |
984 | + |
985 | +############# daily schedule ################# |
986 | +# |
987 | +# Taipei time |
988 | +# 2000 - 1400: mini-ci running |
989 | +# 1200 - 0600 (yantok) |
990 | +# 1400 - 2000: debug time lol |
991 | +# 0600 - 1200 (yantok) |
992 | +# |
993 | +# |
994 | +# Time required: |
995 | +# desktop precise: 00h 55m --> 02h |
996 | +# desktop trusty: 01h 00m --> 02h |
997 | +# desktop Xenial: 01h 10m --> 02h |
998 | +# |
999 | +# server precise: 03h 30m --> 05h |
1000 | +# server trusty: 03h 30m --> 05h |
1001 | +# server Xenial: 05h 50m --> 07h |
1002 | +############################################## |
1003 | + |
1004 | + |
1005 | +########################################### |
1006 | +# yantok/C3 Taipei |
1007 | +# 12:00/13:00 20:00 |
1008 | +# |
1009 | +# mini-ci begins on 20:00 (Taipei) each day |
1010 | +# |
1011 | +# Mon Wen Fri (Taipei) |
1012 | +# desktop and server |
1013 | +# |
1014 | +# Tue Thr Sat (Taipei) |
1015 | +# AMD GPU systems |
1016 | +# |
1017 | +# Sunday does nothing! (Bible says) |
1018 | +# |
1019 | +# Every day: autopilot for checkbox-coverged |
1020 | +# |
1021 | +########################################### |
1022 | + |
1023 | + |
1024 | +######################################################################## |
1025 | +# dont launch_testrun at the same time otherwise dhcp table will mess up |
1026 | +#######################################################################u |
1027 | +############################### desktop ################################################## |
1028 | +01 12 * * 2,4,6 $run_mini_ci launch-reset 12.04.5 desktop $m_12_04_5_desktop |
1029 | +00 14 * * 2,4,6 $run_mini_ci done-desktop 12.04.5 desktop $m_12_04_5_desktop 12.04.5 desktop |
1030 | + |
1031 | +01 14 * * 2,4,6 $run_mini_ci launch 14.04.4 desktop $m_14_04_4_desktop |
1032 | +00 16 * * 2,4,6 $run_mini_ci done-desktop 14.04.4 desktop $m_14_04_4_desktop 14.04.4 desktop |
1033 | + |
1034 | +# mini_ci_machine_l did not suspend successfully. - 160512 |
1035 | +# a failure entry in checkbox test result - 1605xx |
1036 | +01 16 * * 2,4,6 $run_mini_ci launch 16.04 desktop $m_16_04_desktop |
1037 | +00 18 * * 2,4,6 $run_mini_ci done-desktop 16.04 desktop $m_16_04_desktop 16.04 desktop |
1038 | + |
1039 | +01 19 * * 2,4,6 $run_mini_ci launch 16.10 desktop $m_16_10_desktop |
1040 | +00 21 * * 2,4,6 $run_mini_ci done-desktop 16.10 desktop $m_16_10_desktop 16.10 desktop |
1041 | +# daily image so we need to sync up it each time before testing |
1042 | +01 15 * * 2,4,6 $lt -S 17.04 desktop |
1043 | +01 22 * * 2,4,6 $run_mini_ci launch 17.04 desktop $m_zesty_daily_desktop |
1044 | +00 23 * * 2,4,6 $run_mini_ci done-desktop 17.04 desktop $m_zesty_daily_desktop Zesty desktop |
1045 | + |
1046 | +############################## server #################################################### |
1047 | +05 12 * * 2,4,6 $run_mini_ci launch 12.04.5 server $m_12_04_5_server |
1048 | +04 17 * * 2,4,6 $run_mini_ci done-server 12.04.5 server $m_12_04_5_server 12.04.5 server |
1049 | + |
1050 | +05 17 * * 2,4,6 $run_mini_ci launch 14.04.4 server $m_14_04_4_server |
1051 | +04 22 * * 2,4,6 $run_mini_ci done-server 14.04.4 server $m_14_04_4_server 14.04.4 server |
1052 | + |
1053 | +05 22 * * 2,4,6 $run_mini_ci launch 16.04 server $m_16_04_server |
1054 | +# another day |
1055 | +04 05 * * 3,5,7 $run_mini_ci done-server 16.04 server $m_16_04_server 16.04 server |
1056 | + |
1057 | +# FIX ME: |
1058 | +# Dont test completely |
1059 | +#05 13 * * 2,4,6 $run_mini_ci launch 16.10 server $m_yakkety_daily_desktop |
1060 | +#04 18 * * 2,4,6 $run_mini_ci done-desktop 16.10 server $m_yakkety_daily_desktop 16.10 server |
1061 | + |
1062 | + |
1063 | +################# amd gpu test for Xenial ################################################# |
1064 | +00 12 * * 1,3,5 $run_mini_ci launch 16.04 desktop $m_16_04_amdgpu_1 dummy dummy -p |
1065 | +00 14 * * 1,3,5 $run_mini_ci done-desktop 16.04 desktop $m_16_04_amdgpu_1 16.04 desktop -p |
1066 | + |
1067 | +10 14 * * 1,3,5 $run_mini_ci launch 16.04 desktop $m_16_04_amdgpu_2 dummy dummy -p |
1068 | +10 16 * * 1,3,5 $run_mini_ci done-desktop 16.04 desktop $m_16_04_amdgpu_2 16.04 desktop -p |
1069 | +############################################################################################# |
1070 | + |
1071 | + |
1072 | +################# checkbox-converged autopilot on Xenial ################################### |
1073 | +00 18 * * * $run_autopilot launch 16.04 desktop $m_autopilot |
1074 | + |
1075 | +################# checkbox-converged snapcraft on Xenial ################################### |
1076 | +00 20 * * * $run_snapcraft 16.04 desktop $m_snapcraft |
1077 | + |
1078 | +############################### email ###################################################### |
1079 | +59 05 * * * $backup_mini_ci_result |
1080 | +# 14:00 (Taipei) |
1081 | +00 06 * * 3,5,7 /usr/bin/curl -d "emailit=yes" http://$satellite_ip/cgi-bin/plainbox-submit.cgi |
1082 | +# separate official release and daily build test |
1083 | +#00 06 * * 3,5 /usr/bin/curl -d "emailit=yes" -d "dailyimage=yes" http://$satellite_ip/cgi-bin/plainbox-submit.cgi |
1084 | +# separate official release and amd gpu test |
1085 | +00 06 * * 2,4,6 /usr/bin/curl -d "emailit=yes" -d "amdgpu=yes" http://$satellite_ip/cgi-bin/plainbox-submit.cgi |
1086 | diff --git a/src/crontab/snapcraft/run-snapcraft b/src/crontab/snapcraft/run-snapcraft |
1087 | new file mode 100755 |
1088 | index 0000000..98a9b68 |
1089 | --- /dev/null |
1090 | +++ b/src/crontab/snapcraft/run-snapcraft |
1091 | @@ -0,0 +1,9 @@ |
1092 | +#!/bin/bash |
1093 | +if [ -z "$STAGING" ]; then |
1094 | + export CHECKBOX_SRC=${CHECKBOX_SRC:-${HOME}/src} |
1095 | +else |
1096 | + export CHECKBOX_SRC=${CHECKBOX_SRC:-${HOME}/src.staging} |
1097 | +fi |
1098 | + |
1099 | +lt_minici="$CHECKBOX_SRC/checkbox-message/trunk/bin/launch_testrun --snapcraft --ppa=dev" |
1100 | +$lt_minici $1 $2 $3 > /tmp/mini-ci-${1}-${2}-${3}-snapcraft-`date +%y%m%d` 2>&1 |
1101 | diff --git a/src/crontab/snapcraft/run-snapcraft-staging b/src/crontab/snapcraft/run-snapcraft-staging |
1102 | new file mode 100755 |
1103 | index 0000000..eebb578 |
1104 | --- /dev/null |
1105 | +++ b/src/crontab/snapcraft/run-snapcraft-staging |
1106 | @@ -0,0 +1,7 @@ |
1107 | +#!/bin/bash |
1108 | + |
1109 | +# if STAGING is not empty, $HOME/src.staging will be used instead of $HOME/src |
1110 | +export STAGING='.src' |
1111 | +dir=`dirname $0` |
1112 | +$dir/run-snapcraft "$@" |
1113 | + |
1114 | diff --git a/src/www/autopilot/run-autopilot-auto.desktop b/src/www/autopilot/run-autopilot-auto.desktop |
1115 | new file mode 100644 |
1116 | index 0000000..25d4e58 |
1117 | --- /dev/null |
1118 | +++ b/src/www/autopilot/run-autopilot-auto.desktop |
1119 | @@ -0,0 +1,8 @@ |
1120 | +[Desktop Entry] |
1121 | +Encoding=UTF-8 |
1122 | +Name=Autopilot |
1123 | +Comment=Autopilot can run after login to test a system automatically. |
1124 | +Exec=sh /home/ubuntu/run-autopilot-test.sh |
1125 | +Terminal=false |
1126 | +Type=Application |
1127 | +Categories= |
1128 | diff --git a/src/www/autopilot/run-autopilot-test.sh b/src/www/autopilot/run-autopilot-test.sh |
1129 | new file mode 100644 |
1130 | index 0000000..37652c7 |
1131 | --- /dev/null |
1132 | +++ b/src/www/autopilot/run-autopilot-test.sh |
1133 | @@ -0,0 +1,33 @@ |
1134 | +# script to make the autopilot test automatical |
1135 | +cgi_url="http://10.101.47.1/cgi-bin/plainbox-submit.cgi" |
1136 | +log_autopilot="/tmp/minici_make-autopilot.log" |
1137 | +log_autopilot_xvfb="/tmp/minici_make-autopilot-xvfb-run.log" |
1138 | +log_pastebinit="/tmp/minici_pastebinit.log" |
1139 | +# to wait and make sure the network connects after xdg lauched. |
1140 | +sleep 60 |
1141 | +# prepare |
1142 | +cd $HOME |
1143 | +mkdir checkbox && cd checkbox |
1144 | +git clone git://git.launchpad.net/plainbox |
1145 | +git clone git://git.launchpad.net/checkbox-converged |
1146 | +cd checkbox-converged/ |
1147 | +# for running on local machine |
1148 | +#make autopilot > $log_autopilot 2>&1 |
1149 | +# for virtual framebuffer analysis |
1150 | +echo "xvfb-run --server-args='-screen 0 1024x768x24 -ac +render -noreset' make autopilot" > $log_autopilot_xvfb |
1151 | +xvfb-run --server-args='-screen 0 1024x768x24 -ac +render -noreset' make autopilot >> $log_autopilot_xvfb 2>&1 |
1152 | +# pass the test log files to pastebin and ready for further using |
1153 | +#pastebinit $log_autopilot > $log_pastebinit 2>&1 |
1154 | +#pastebinit $log_autopilot_xvfb >> $log_pastebinit 2>&1 |
1155 | +#curl -F autopilot_subject="make autopilot" -F autopilot_output=@$log_autopilot $cgi_url |
1156 | +curl -F autopilot_subject="make autopilot xvfb-run" -F autopilot_output=@$log_autopilot_xvfb $cgi_url |
1157 | + |
1158 | +# send the nofification email |
1159 | +# in this case we only run the test on one machine within one day |
1160 | +# if we would like to wait for many test from different fresh installation |
1161 | +# we need to apply this command on a server which waiting for other test results. |
1162 | +curl -d "email_mini_ci_autopilot=yes" $cgi_url |
1163 | + |
1164 | +# save the polar bear and protect the hardware! |
1165 | +sudo shutdown -h now |
1166 | + |
1167 | diff --git a/src/www/snapcraft/run-snapcraft-test-launcher.sh b/src/www/snapcraft/run-snapcraft-test-launcher.sh |
1168 | new file mode 100755 |
1169 | index 0000000..1d76ffe |
1170 | --- /dev/null |
1171 | +++ b/src/www/snapcraft/run-snapcraft-test-launcher.sh |
1172 | @@ -0,0 +1,17 @@ |
1173 | +#!/bin/bash |
1174 | +cgi_url="http://10.101.47.1/cgi-bin/plainbox-submit.cgi" |
1175 | +minici_snapcraft_log="/home/ubuntu/minici-snapcraft/minici-snapcraft.log" |
1176 | +# wait for the ethernet getting ready |
1177 | +sleep 60 |
1178 | +# run the real test and fetch the log |
1179 | +cd /home/ubuntu/minici-snapcraft |
1180 | +./run-snapcraft-test.sh > ./minici-snapcraft.log 2>&1 |
1181 | +execute_status=$? |
1182 | + |
1183 | +# TODO: submit the hostname to cgi |
1184 | + |
1185 | +curl -F snapcraft_subject="./run-snapcraft-test.sh" -F snapcraft_output=@${minici_snapcraft_log} -F snapcraft_status="$execute_status" $cgi_url |
1186 | +echo "snapcraft_status=$execute_status" |
1187 | +curl -d "email_mini_ci_snapcraft=yes" -d "snapcraft_status=$execute_status" $cgi_url |
1188 | +# protect the test machine and polar bears! |
1189 | +shutdown -h now |
1190 | diff --git a/src/www/snapcraft/run-snapcraft-test.desktop b/src/www/snapcraft/run-snapcraft-test.desktop |
1191 | new file mode 100644 |
1192 | index 0000000..6b59c3e |
1193 | --- /dev/null |
1194 | +++ b/src/www/snapcraft/run-snapcraft-test.desktop |
1195 | @@ -0,0 +1,8 @@ |
1196 | +[Desktop Entry] |
1197 | +Encoding=UTF-8 |
1198 | +Name=Snapcraft P-P-S test |
1199 | +Comment=Test whether plainbox-provider-snappy is snappable with snapcraft |
1200 | +Exec=sh /home/ubuntu/run-snapcraft-test-launcher.sh |
1201 | +Terminal=false |
1202 | +Type=Application |
1203 | +Categories= |
1204 | diff --git a/src/www/snapcraft/run-snapcraft-test.sh b/src/www/snapcraft/run-snapcraft-test.sh |
1205 | new file mode 100755 |
1206 | index 0000000..c54522c |
1207 | --- /dev/null |
1208 | +++ b/src/www/snapcraft/run-snapcraft-test.sh |
1209 | @@ -0,0 +1,99 @@ |
1210 | +#!/usr/bin/env bash |
1211 | +# This file is part of Checkbox. |
1212 | +# |
1213 | +# Copyright 2016-2017 Canonical Ltd. |
1214 | +# Written by: |
1215 | +# Maciej Kisielewski <maciej.kisielewski@canonical.com> |
1216 | +# |
1217 | +# Checkbox is free software: you can redistribute it and/or modify |
1218 | +# it under the terms of the GNU General Public License version 3, |
1219 | +# as published by the Free Software Foundation. |
1220 | + |
1221 | +SAVED_DIR=$PWD |
1222 | +WORK_DIR=`mktemp -d` |
1223 | + |
1224 | +cd $WORK_DIR |
1225 | +mkdir -p logs |
1226 | +LOG_DIR=$WORK_DIR/logs |
1227 | + |
1228 | +function clean_up { |
1229 | + cd $SAVED_DIR |
1230 | + rm -rf $WORK_DIR |
1231 | +} |
1232 | + |
1233 | +function time_it { |
1234 | + /usr/bin/time -f "%E elapsed. %P CPU" -o $LOG_DIR/timing.dat $@ |
1235 | +} |
1236 | + |
1237 | +function pastebin_logs { |
1238 | + if [ -s $LOG_DIR/stdout ]; then |
1239 | + echo stdout: $(pastebinit $LOG_DIR/stdout) |
1240 | + else |
1241 | + echo stdout: empty |
1242 | + fi |
1243 | + if [ -s $LOG_DIR/stderr ]; then |
1244 | + echo stderr: $(pastebinit $LOG_DIR/stderr) |
1245 | + else |
1246 | + echo stderr: empty |
1247 | + fi |
1248 | +} |
1249 | + |
1250 | +function run_step { |
1251 | + echo -n Step \"$1\" |
1252 | + if ! time_it $2 >>$LOG_DIR/stdout 2>>$LOG_DIR/stderr; then |
1253 | + echo -n "- FAIL - " |
1254 | + outcome=1 |
1255 | + else |
1256 | + echo -n "- PASS - " |
1257 | + outcome=0 |
1258 | + fi |
1259 | + echo -n elapsed: ; cat $LOG_DIR/timing.dat |
1260 | + if [ $outcome -ne 0 ]; then |
1261 | + pastebin_logs |
1262 | + return 1 |
1263 | + fi |
1264 | +} |
1265 | + |
1266 | +# master branch test |
1267 | +function test_master { |
1268 | + run_step "git-clone" "git clone -b master https://git.launchpad.net/checkbox-snappy packaging" || return 1 |
1269 | + run_step "update-snapcraft" "snapcraft update" || return 1 |
1270 | + (cd packaging && run_step "run-snapcraft" "snapcraft snap -o ../checkbox-snappy.snap") || return 1 |
1271 | + run_step "verify-build" "ls -al checkbox-snappy.snap" || return 1 |
1272 | + run_step "install-checkbox-snappy" "sudo snap install --devmode ./checkbox-snappy.snap" || return 1 |
1273 | + (cd && run_step "run smoke-test" "checkbox-snappy.smoke-test") || return 1 |
1274 | + return 0 |
1275 | +} |
1276 | +test_master |
1277 | +master_result=$? |
1278 | +if [[ $master_result -eq 1 ]]; then |
1279 | + echo "Testing Checkbox snap for branch master failed!" |
1280 | +fi |
1281 | +pastebin_logs |
1282 | + |
1283 | +# beta branch test |
1284 | +function test_beta { |
1285 | + run_step "git-clone" "git clone -b beta https://git.launchpad.net/checkbox-snappy packaging-beta" || return 1 |
1286 | + run_step "update-snapcraft" "snapcraft update" || return 1 |
1287 | + (cd packaging-beta && run_step "run-snapcraft" "snapcraft snap -o ../checkbox-snappy-beta.snap") || return 1 |
1288 | + run_step "verify-build" "ls -al checkbox-snappy-beta.snap" || return 1 |
1289 | + run_step "install-checkbox-snappy" "sudo snap install --devmode ./checkbox-snappy-beta.snap" || return 1 |
1290 | + (cd && run_step "run smoke-test" "checkbox-snappy.smoke-test") || return 1 |
1291 | + return 0 |
1292 | +} |
1293 | +test_beta |
1294 | +beta_result=$? |
1295 | +if [[ $beta_result -eq 1 ]]; then |
1296 | + echo "Testing Checkbox snap for branch beta failed!" |
1297 | +fi |
1298 | +pastebin_logs |
1299 | + |
1300 | +clean_up |
1301 | +echo "$master_result" |
1302 | +echo "$beta_result" |
1303 | +if [[ $master_result -eq 0 && $beta_result -eq 0 ]]; then |
1304 | + echo "ALL STEPS PASSED" |
1305 | + exit 0 |
1306 | +else |
1307 | + exit 1 |
1308 | +fi |
We need this story https:/ /trello. com/c/zzQ1cetn/ 552-when- i-work- on-tools- scripts- for-the- tpe-lab- i-want- them-to- be-organized- under-a- sub-project- like-checkbox- project- so-i-can- know
to avoid using branches as repos ; )