Merge ~sbaldassin/bileto:bileto_ust into bileto:master

Proposed by Santiago Baldassin
Status: Rejected
Rejected by: Robert Bruce Park
Proposed branch: ~sbaldassin/bileto:bileto_ust
Merge into: bileto:master
Diff against target: 117 lines (+54/-2)
4 files modified
bileto/models.py (+4/-0)
britney/iterate.py (+23/-1)
tests/data/tickets.json (+1/-1)
tests/test_ust.py (+26/-0)
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Needs Fixing
Bileto Developers Pending
Review via email: mp+307015@code.launchpad.net

Commit message

Trigger ubuntu system tests from bileto

Description of the change

Trigger ubuntu system tests from bileto

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

Good progress here, see comments inline, thanks!

review: Needs Fixing
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Thanks for the feedback Robert. I've added the unit tests and also replied to you inline

Revision history for this message
Robert Bruce Park (robru) wrote :

For now just write a file please. You can just write the status to /tmp/bileto/REQUESTID.ust, then you can check that file and see if it's started yet or not.

I really can't accept this branch with the schema changes, I need to do up a big schema migration with unrelated changes and I don't want to block on that.

Revision history for this message
Robert Bruce Park (robru) wrote :

Some comments on the tests too

review: Needs Fixing
Revision history for this message
Robert Bruce Park (robru) wrote :

Bileto is self-hosting so I created a ticket here:

https://bileto.ubuntu.com/#/ticket/2029

There's no bileto package in ubuntu so it's not necessary to publish the ticket, the ticket can just be finalized after tests pass and I try it out in staging.

Revision history for this message
Robert Bruce Park (robru) wrote :

argh, tests of course failed because the qakit dependency is missing.

Revision history for this message
Robert Bruce Park (robru) :
Revision history for this message
Robert Bruce Park (robru) wrote :

Ok, apologies again, our self-hosting ability was somewhat bitrotted, it's been a while since I had an MP from another developer ;-)

I've resolved the test failures that were unrelated to your branch, please rebase your work on the latest master.

Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Thanks Robert. I'll try to come up with something to avoid the changes in models

Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Hi Robert, I've addressed all your concerns last week. Would you please take a new look? thanks

Revision history for this message
Robert Bruce Park (robru) wrote :

Hi Santiago, sorry for the delay, Monday was a holiday and i was sick a couple days last week.

One question, once this starts triggering tests, where is the Jenkins located for checking results?

Also more comments inline.

review: Needs Fixing
Revision history for this message
Robert Bruce Park (robru) wrote :

Also these two test failure need to be resolved:

https://launchpadlibrarian.net/289230891/buildlog_ubuntu-xenial-amd64.bileto_1.0+16.04.20161011-0ubuntu1_BUILDING.txt.gz

Please make sure you are running the tests locally to confirm everything is working.

Revision history for this message
Robert Bruce Park (robru) wrote :

I've spoken with my manager (Steve) and he's requested that I just take over this from here, so don't worry about resolving the issues I pointed out in my previous reviews!

Unmerged commits

c89ca6c... by Santiago Baldassin

Triger ubuntu system tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bileto/models.py b/bileto/models.py
2index c4c133a..b6df014 100644
3--- a/bileto/models.py
4+++ b/bileto/models.py
5@@ -53,6 +53,10 @@ BRITNEY_SIGNOFF = """Automated Signoff
6 Indicates if britney has approved the ticket based on autopkgtests & other \
7 factors. Check the excuses page for details."""
8
9+UST_BUILD_URL = """Ubuntu System Tests Build url
10+
11+Indicates the url of the build"""
12+
13 CREATOR = """Request Creator
14
15 Launchpad nickname of the person who created this request."""
16diff --git a/britney/iterate.py b/britney/iterate.py
17index 7dede19..8470635 100755
18--- a/britney/iterate.py
19+++ b/britney/iterate.py
20@@ -13,14 +13,15 @@ from json import dumps
21 from time import strftime
22 from pprint import pformat
23 from datetime import datetime
24-from contextlib import suppress
25 from subprocess import Popen, PIPE
26 from fcntl import LOCK_EX, LOCK_NB, flock
27
28 from os import environ, unlink, symlink
29 from os.path import abspath, dirname, exists
30
31+import requests
32 from requests import get, post
33+from contextlib import suppress
34
35 HOME = dirname(abspath(__file__))
36 ROOT = dirname(HOME)
37@@ -30,6 +31,9 @@ sys.path.append(ROOT)
38 # pylint: disable=wrong-import-position
39 from bileto.settings import Config # noqa
40
41+with suppress(ImportError):
42+ from qakit.ust.worker import Worker, UstResult
43+
44
45 PUBLIC = '/static/britney/'
46 OUTPUT = '/tmp/britney_output/'
47@@ -191,6 +195,23 @@ def parallelize_fetching(all_series, runs):
48 update_request(ticket)
49
50
51+def compute_ust_signoff(reqs):
52+ """Notify the ticket status in ubuntu system tests.
53+ Once a silo is assigned to the ticket, ust is triggered only if
54+ the lander has approved the ticket. After triggering the tests,
55+ the worker is asked for results
56+ :return UstResult which has two attributes: status and build url
57+ which are both use in the UI"""
58+ for request in reqs:
59+ if request['siloname']:
60+ ust_worker = Worker()
61+ if request['lander_signoff'] == 'Approved':
62+ try:
63+ ust_worker.run_ust(request['siloname'])
64+ except Exception:
65+ pass
66+
67+
68 def print_proc(proc):
69 """Print the output from a subprocess."""
70 sys.stdout.buffer.write(BNEWLINE.join(
71@@ -207,6 +228,7 @@ def main():
72 sys.stderr = sys.stdout = open(LOG_NAME, 'x')
73 reqs = get_requests()
74 parallelize_fetching(*build_siloname_dict(reqs))
75+ compute_ust_signoff(reqs)
76 except BlockingIOError:
77 return 0
78 except (IOError, ConnectionRefusedError):
79diff --git a/tests/data/tickets.json b/tests/data/tickets.json
80index 177f15a..52da6d9 100644
81--- a/tests/data/tickets.json
82+++ b/tests/data/tickets.json
83@@ -1 +1 @@
84-{"admin":false,"assigned":58,"instance":"0774b9be-ca96-11e5-b59e-7365ce69eb31","ircnick":"","next":"limit=2&page=2","nickname":"","prev":"","requests":[{"artifacts":"https://ci-train.ubuntu.com/job/ubuntu-landing-029-1-build/lastBuild/","autopkgtest":"","britney_signoff":"","creator":"renatofilho","date":"2016-02-03T14:16:24.162764Z","description":"Fix bug #1450252","dest":"","distribution":"ubuntu","download_links":"","job_log":"https://ci-train.ubuntu.com/job/ubuntu-landing-029-0-status/4847/consoleFull","lander_signoff":"","landers":"renatofilho","published_versions":"{}","qa_signoff":"Required","request_id":961,"series":"xenial+vivid","siloname":"ubuntu/landing-029","sources":"address-book-app","status":"Successfully built","status_color":"black","sync_request":"","test_plan":"https://wiki.ubuntu.com/Process/Merges/TestPlan/address-book-app"},{"artifacts":"https://ci-train.ubuntu.com/job/ubuntu-landing-046-1-build/lastBuild/","autopkgtest":"/static/britney/xenial/landing-046/excuses.html\\n/static/britney/vivid/landing-046/excuses.html","britney_signoff":"Running","creator":"cjwatson","date":"2016-02-03T11:09:13.734136Z","description":"Click 0.4.43: More autopkgtest fixes, and rename python3-click out of the way of the PyPI \"click\" package.","dest":"","distribution":"ubuntu","download_links":"","job_log":"https://ci-train.ubuntu.com/job/ubuntu-landing-046-0-status/4831/consoleFull","lander_signoff":"Approved","landers":"cjwatson","published_versions":"{}","qa_signoff":"Required","request_id":960,"series":"xenial+vivid","siloname":"ubuntu/landing-046","sources":"click","status":"Successfully built","status_color":"black","sync_request":"","test_plan":"https://wiki.ubuntu.com/Process/Merges/TestPlan/click"}],"teams":""}
85+{"admin":false,"assigned":58,"instance":"0774b9be-ca96-11e5-b59e-7365ce69eb31","ircnick":"","next":"limit=2&page=2","nickname":"","prev":"","requests":[{"artifacts":"https://ci-train.ubuntu.com/job/ubuntu-landing-029-1-build/lastBuild/","autopkgtest":"","britney_signoff":"", "creator":"renatofilho","date":"2016-02-03T14:16:24.162764Z","description":"Fix bug #1450252","dest":"","distribution":"ubuntu","download_links":"","job_log":"https://ci-train.ubuntu.com/job/ubuntu-landing-029-0-status/4847/consoleFull","lander_signoff":"","landers":"renatofilho","published_versions":"{}","qa_signoff":"Required","request_id":961,"series":"xenial+vivid","siloname":"ubuntu/landing-029","sources":"address-book-app","status":"Successfully built","status_color":"black","sync_request":"","test_plan":"https://wiki.ubuntu.com/Process/Merges/TestPlan/address-book-app"},{"artifacts":"https://ci-train.ubuntu.com/job/ubuntu-landing-046-1-build/lastBuild/","autopkgtest":"/static/britney/xenial/landing-046/excuses.html\\n/static/britney/vivid/landing-046/excuses.html","britney_signoff":"Running","creator":"cjwatson","date":"2016-02-03T11:09:13.734136Z","description":"Click 0.4.43: More autopkgtest fixes, and rename python3-click out of the way of the PyPI \"click\" package.","dest":"","distribution":"ubuntu","download_links":"","job_log":"https://ci-train.ubuntu.com/job/ubuntu-landing-046-0-status/4831/consoleFull","lander_signoff":"Approved","landers":"cjwatson","published_versions":"{}","qa_signoff":"Required","request_id":960,"series":"xenial+vivid","siloname":"ubuntu/landing-046","sources":"click","status":"Successfully built","status_color":"black","sync_request":"","test_plan":"https://wiki.ubuntu.com/Process/Merges/TestPlan/click"}],"teams":""}
86diff --git a/tests/test_ust.py b/tests/test_ust.py
87new file mode 100644
88index 0000000..0daa6df
89--- /dev/null
90+++ b/tests/test_ust.py
91@@ -0,0 +1,26 @@
92+"""UST tests"""
93+
94+from os.path import join, dirname
95+from json import loads
96+from unittest import TestCase
97+
98+from unittest.mock import patch
99+
100+from britney.iterate import compute_ust_signoff
101+
102+DATA_DIR = join(dirname(__file__), 'data')
103+
104+
105+class TestUstIterate(TestCase):
106+ """Test the ust method within the iterate.py script."""
107+
108+ def setUp(self):
109+ with open(join(DATA_DIR, 'tickets.json'), 'r',
110+ encoding='utf-8') as ticketsfp:
111+ self.requests = loads(ticketsfp.read())['requests']
112+
113+ @patch('qakit.ust.worker.Worker.run_ust')
114+ def test_ust_triggered_for_lander_approved_only(self, worker):
115+ compute_ust_signoff(self.requests)
116+ self.assertTrue(worker.called)
117+ self.assertEqual(worker.call_count, 1)

Subscribers

People subscribed via source and target branches