Merge lp:~robru/cupstream2distro/orthogonal-push into lp:cupstream2distro

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 1096
Merged at revision: 1095
Proposed branch: lp:~robru/cupstream2distro/orthogonal-push
Merge into: lp:cupstream2distro
Diff against target: 114 lines (+17/-25)
2 files modified
cupstream2distro/silomanager.py (+16/-16)
tests/unit/test_silomanager.py (+1/-9)
To merge this branch: bzr merge lp:~robru/cupstream2distro/orthogonal-push
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+270779@code.launchpad.net

Commit message

Avoid validating bileto request during silo assignment.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~robru/cupstream2distro/orthogonal-push/+merge/270779/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1096
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~robru/cupstream2distro/orthogonal-push/+merge/270779/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/cu2d-choo-choo-ci/778/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/cu2d-choo-choo-ci/778/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/silomanager.py'
2--- cupstream2distro/silomanager.py 2015-09-11 03:38:43 +0000
3+++ cupstream2distro/silomanager.py 2015-09-11 08:38:15 +0000
4@@ -39,7 +39,6 @@
5 from cupstream2distro.settings import (
6 BILETO_API,
7 BILETO_GET,
8- BILETO_IP,
9 LANDING_SCHEME,
10 SILO_NAME_LIST,
11 SILOS_DIR,
12@@ -123,6 +122,20 @@
13 return TOKEN_SCRUB.sub('token=XXX', message)
14
15
16+def update_bileto(**kwargs):
17+ """Send details to bileto."""
18+ try:
19+ response = requests.post(
20+ BILETO_API, data=json.dumps(kwargs), headers=JSON)
21+ except IOError as err:
22+ logging.error(
23+ 'Failed to contact Bileto: {}'.format(scrub(str(err))))
24+ return
25+ if not response.ok:
26+ logging.warning('Bileto says: {} {}'.format(
27+ response.status_code, response.reason))
28+
29+
30 class SiloState(object):
31 """This class stores and manipulates the silo config json blob."""
32 REQUEST_ID_FILE = 'request_id_{}'
33@@ -152,7 +165,7 @@
34 @staticmethod
35 def new_blank(siloname, requestid=''):
36 """Create a new SiloState object for a newly-assigned silo."""
37- silo_state = SiloState(siloname, primary=True)
38+ silo_state = SiloState(siloname)
39 silo_state.requestid = requestid
40 return silo_state
41
42@@ -329,26 +342,13 @@
43
44 def push_to_bileto(self):
45 """Submit status information to Bileto."""
46- if not BILETO_IP:
47- logging.warning('Bileto IP unknown: skipping.')
48- return
49- payload = dict(
50+ update_bileto(
51 job_log=self.job_log,
52 published_versions=self.published_versions,
53 request_id=self.requestid,
54 status=self.status,
55 siloname=self.siloname,
56 )
57- try:
58- response = requests.post(
59- BILETO_API, data=json.dumps(payload), headers=JSON)
60- except IOError as err:
61- logging.warning(
62- 'Failed to contact Bileto: {}'.format(scrub(str(err))))
63- return
64- if not response.ok:
65- logging.warning('Bileto says: {} {}'.format(
66- response.status_code, response.reason))
67
68 def save_config(self):
69 """Save status messages to appropriate places."""
70
71=== modified file 'tests/unit/test_silomanager.py'
72--- tests/unit/test_silomanager.py 2015-09-11 03:38:43 +0000
73+++ tests/unit/test_silomanager.py 2015-09-11 08:38:15 +0000
74@@ -488,7 +488,6 @@
75 ])
76
77 @patch('cupstream2distro.silomanager.SiloState.requestid', '121')
78- @patch('cupstream2distro.silomanager.BILETO_IP', '8.8.8.8')
79 @patch('cupstream2distro.silomanager.BILETO_API', 'example.com')
80 def test_silostate_push_to_bileto(self):
81 """Ensure that we push status messages to Bileto."""
82@@ -504,7 +503,6 @@
83 headers={'content-type': 'application/json'})
84
85 @patch('cupstream2distro.silomanager.SiloState.requestid', '121')
86- @patch('cupstream2distro.silomanager.BILETO_IP', '8.8.8.8')
87 @patch('cupstream2distro.silomanager.BILETO_API', 'example.com')
88 @patch('cupstream2distro.silomanager.requests')
89 @patch('cupstream2distro.silomanager.logging')
90@@ -512,11 +510,10 @@
91 """Report failures to reach Bileto."""
92 req_mock.post.side_effect = IOError('token=hello')
93 self.state.push_to_bileto()
94- log_mock.warning.assert_called_once_with(
95+ log_mock.error.assert_called_once_with(
96 'Failed to contact Bileto: token=XXX')
97
98 @patch('cupstream2distro.silomanager.SiloState.requestid', '121')
99- @patch('cupstream2distro.silomanager.BILETO_IP', '8.8.8.8')
100 @patch('cupstream2distro.silomanager.BILETO_API', 'example.com')
101 def test_silostate_push_to_bileto_bad_response(self):
102 """Report failures from Bileto."""
103@@ -531,11 +528,6 @@
104 data=data,
105 headers={'content-type': 'application/json'})
106
107- def test_silostate_push_to_bileto_ip_missing(self):
108- """Don't explode if data missing."""
109- self.state.push_to_bileto()
110- self.assertEqual(silomanager.requests.post.mock_calls, [])
111-
112 def test_silostate_save_config(self):
113 """Save config to places."""
114 self.state.push_to_ppa_description = Mock()

Subscribers

People subscribed via source and target branches