Merge lp:~robru/cupstream2distro/moar-bileto into lp:cupstream2distro
- moar-bileto
- Merge into trunk
Proposed by
Robert Bruce Park
Status: | Merged |
---|---|
Approved by: | Robert Bruce Park |
Approved revision: | 1096 |
Merged at revision: | 1076 |
Proposed branch: | lp:~robru/cupstream2distro/moar-bileto |
Merge into: | lp:cupstream2distro |
Diff against target: |
670 lines (+104/-170) 10 files modified
citrain/prepare_silo.py (+0/-4) cupstream2distro/launchpadmanager.py (+2/-3) cupstream2distro/silomanager.py (+28/-62) tests/unit/__init__.py (+11/-2) tests/unit/test_recipe_base.py (+1/-1) tests/unit/test_recipe_sourcesync.py (+1/-1) tests/unit/test_script_prepare_silo.py (+4/-8) tests/unit/test_script_publisher.py (+3/-3) tests/unit/test_script_setup_citrain.py (+6/-6) tests/unit/test_silomanager.py (+48/-80) |
To merge this branch: | bzr merge lp:~robru/cupstream2distro/moar-bileto |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Bruce Park (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+270218@code.launchpad.net |
Commit message
Convert dual property to Bileto.
Description of the change
To post a comment you must log in.
- 1092. By Robert Bruce Park
-
Drop unused additional_targets.
- 1093. By Robert Bruce Park
-
Add TODO comment.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
- 1094. By Robert Bruce Park
-
Convert status to Bileto.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1094
http://
Executed test runs:
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
- 1095. By Robert Bruce Park
-
Convert ppa property to bileto.
- 1096. By Robert Bruce Park
-
Make assertEqual stop sucking out loud.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1096
http://
Executed test runs:
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote : | # |
Looking good in staging:
https:/
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'citrain/prepare_silo.py' |
2 | --- citrain/prepare_silo.py 2015-09-04 00:38:51 +0000 |
3 | +++ citrain/prepare_silo.py 2015-09-05 01:43:08 +0000 |
4 | @@ -109,8 +109,6 @@ |
5 | raise PrepError( |
6 | 'SOURCES and SYNC_REQUEST not supported by dual landings.') |
7 | env.SERIES = 'wily' |
8 | - env.DUAL = 'vivid' |
9 | - logging.info('Dual silo: {} and {}.'.format(env.SERIES, env.DUAL)) |
10 | |
11 | |
12 | def create_directories(): |
13 | @@ -158,8 +156,6 @@ |
14 | silo_state = SiloState.new_blank( |
15 | siloname=env.SILONAME, |
16 | requestid=env.REQUEST_ID) |
17 | - silo_state.dual = env.DUAL |
18 | - silo_state.ppa = lp.get_ppa(LANDING_SCHEME.format(env.SILONAME)) |
19 | if env.SYNC_REQUEST: |
20 | prepare_sync(silo_state) |
21 | return silo_state |
22 | |
23 | === modified file 'cupstream2distro/launchpadmanager.py' |
24 | --- cupstream2distro/launchpadmanager.py 2015-09-04 00:38:51 +0000 |
25 | +++ cupstream2distro/launchpadmanager.py 2015-09-05 01:43:08 +0000 |
26 | @@ -21,9 +21,7 @@ |
27 | from launchpadlib.launchpad import Launchpad |
28 | |
29 | from cupstream2distro.utils import env, memoize, os_path_join_safe, singleton |
30 | -from cupstream2distro.settings import ( |
31 | - COMMON_LAUNCHPAD_CACHE_DIR |
32 | -) |
33 | +from cupstream2distro.settings import COMMON_LAUNCHPAD_CACHE_DIR |
34 | |
35 | |
36 | CREDS_PATH = os.path.expanduser( |
37 | @@ -68,6 +66,7 @@ |
38 | """Return a lp resource from a launchpad url.""" |
39 | return self._launchpad.load(url.replace(MP_ROOT, self._api_root)) |
40 | |
41 | + @memoize |
42 | def get_series(self, series_name, dest=None, distro_name='ubuntu'): |
43 | """Return the launchpad object for the requested series name.""" |
44 | distro_name = dest.distribution.name if dest else distro_name |
45 | |
46 | === modified file 'cupstream2distro/silomanager.py' |
47 | --- cupstream2distro/silomanager.py 2015-09-04 00:38:51 +0000 |
48 | +++ cupstream2distro/silomanager.py 2015-09-05 01:43:08 +0000 |
49 | @@ -37,6 +37,7 @@ |
50 | BILETO_API, |
51 | BILETO_GET, |
52 | BILETO_IP, |
53 | + LANDING_SCHEME, |
54 | SILO_NAME_LIST, |
55 | SILOS_DIR, |
56 | ) |
57 | @@ -125,13 +126,14 @@ |
58 | return TOKEN_SCRUB.sub('token=XXX', message) |
59 | |
60 | |
61 | +# TODO: everything that references SiloState._config needs to be converted |
62 | +# to use Bileto instead, also all ".setter" properties should go. |
63 | class SiloState(object): |
64 | """This class stores and manipulates the silo config json blob.""" |
65 | CONFIG_FILENAME = 'config' |
66 | _bileto = None |
67 | _config = None |
68 | _configfile = None |
69 | - _ppa = None |
70 | |
71 | @classmethod |
72 | def iterate(cls, ignore=None): |
73 | @@ -174,7 +176,6 @@ |
74 | 'siloname': siloname, |
75 | 'mps': {}, |
76 | } |
77 | - silo_state._mtime = silo_state.get_mtime() |
78 | return silo_state |
79 | |
80 | @staticmethod |
81 | @@ -207,7 +208,6 @@ |
82 | def __init__(self, siloname, do_load=True, log=True): |
83 | """Create a new SiloState object for an already-assigned silo.""" |
84 | self.siloname = siloname |
85 | - self._mtime = None |
86 | if do_load: |
87 | self.load_config() |
88 | self.info = logging.info if log else lambda *ignore: None |
89 | @@ -222,6 +222,13 @@ |
90 | self.load_bileto() |
91 | return self._bileto[key.strip('_')] |
92 | |
93 | + def __setattr__(self, key, value): |
94 | + """Set Bileto attributes in Bileto.""" |
95 | + if key in ('status', 'job_log'): |
96 | + self._bileto[key] = value |
97 | + else: |
98 | + super().__setattr__(key, value) |
99 | + |
100 | def mark_others_dirty(self): |
101 | """Indicate that other silos need to be rebuilt.""" |
102 | projects = set(self.all_projects) |
103 | @@ -258,7 +265,6 @@ |
104 | """Read in the JSON blob.""" |
105 | with utf8_open(self.configfile) as data: |
106 | self._config = json.load(data) |
107 | - self._mtime = self.get_mtime() |
108 | |
109 | def push_to_ppa_description(self): |
110 | """Set the Silo PPA description to something meaningful.""" |
111 | @@ -275,7 +281,7 @@ |
112 | packages=' '.join(self.all_projects), |
113 | series=self.series.name, |
114 | status_url=env.BUILD_URL + 'consoleFull', |
115 | - status=self.message, |
116 | + status=self.status, |
117 | request_url=env.JENKINS_URL.replace('ci-', 'requests.ci-') + |
118 | '#/ticket/{}'.format(self.requestid)).replace( |
119 | 'api.launchpad.net/devel', 'launchpad.net') |
120 | @@ -291,7 +297,7 @@ |
121 | job_log=env.BUILD_URL + 'consoleFull', |
122 | published_versions=self.pkgversionlist, |
123 | request_id=self.requestid, |
124 | - status=self.message, |
125 | + status=self.status, |
126 | siloname=self.siloname, |
127 | ) |
128 | try: |
129 | @@ -309,22 +315,15 @@ |
130 | """Write out the JSON blob.""" |
131 | self.push_to_bileto() |
132 | self.push_to_ppa_description() |
133 | - if self._mtime != self.get_mtime(): |
134 | - prev = SiloState(self.siloname, do_load=False) |
135 | - prev._configfile = self.configfile |
136 | - prev.load_config() |
137 | - message = prev.message.strip('. ') |
138 | - self.message = '{}. {}'.format(message, self.message) |
139 | newfile = '{}.new'.format(self.configfile) |
140 | with utf8_open(newfile, 'w') as config_file: |
141 | json.dump(self._config, config_file) |
142 | os.rename(newfile, self.configfile) |
143 | - self._mtime = self.get_mtime() |
144 | |
145 | def set_config_status(self, state, message): |
146 | """Update to reflect the latest status.""" |
147 | self.url = env.BUILD_URL + 'console' |
148 | - self.message = scrub(message) |
149 | + self.status = scrub(message) |
150 | self.state = state |
151 | |
152 | def set_package_version_list(self, pkglist): |
153 | @@ -469,26 +468,6 @@ |
154 | self._config['global']['step'] = value |
155 | |
156 | @property |
157 | - def dual(self): |
158 | - """Report the secondary series name if this is a dual silo.""" |
159 | - return self._config.get('dual') |
160 | - |
161 | - @dual.setter |
162 | - def dual(self, value): |
163 | - """Record the secondary series name, indicating this is a dual silo.""" |
164 | - self._config['dual'] = value |
165 | - |
166 | - @property |
167 | - def message(self): |
168 | - """Fetch the silo status message.""" |
169 | - return self._config['global']['status']['message'] |
170 | - |
171 | - @message.setter |
172 | - def message(self, value): |
173 | - """Record the silo status message.""" |
174 | - self._config['global']['status']['message'] = value |
175 | - |
176 | - @property |
177 | def mps(self): |
178 | """Identify the merge proposal URLs configured for this silo. |
179 | |
180 | @@ -502,18 +481,6 @@ |
181 | self._config['mps'] = value |
182 | |
183 | @property |
184 | - def ppa(self): |
185 | - """Return launchpadlib object representing the silo ppa.""" |
186 | - if self._ppa is None: |
187 | - self._ppa = lp.load(self._config['global']['ppa']) |
188 | - return self._ppa |
189 | - |
190 | - @ppa.setter |
191 | - def ppa(self, value): |
192 | - """Record the launchpadlib API URL representing the silo ppa.""" |
193 | - self._config['global']['ppa'] = value.self_link |
194 | - |
195 | - @property |
196 | def requestid(self): |
197 | """Identify the requestid for this silo.""" |
198 | return self._config['requestid'] |
199 | @@ -524,6 +491,19 @@ |
200 | self._config['requestid'] = value |
201 | |
202 | @property |
203 | + def ppa(self): |
204 | + """Return the lplib object representing the silo ppa.""" |
205 | + return lp.get_ppa(LANDING_SCHEME.format(env.SILONAME)) |
206 | + |
207 | + @property |
208 | + def dual(self): |
209 | + """Report the secondary series name if this is a dual silo.""" |
210 | + if self._series == 'dual': |
211 | + return 'vivid' |
212 | + if '+' in self._series: |
213 | + return self._series.split('+')[-1] |
214 | + |
215 | + @property |
216 | def sources(self): |
217 | """Identify the manual source packages configured for this silo.""" |
218 | archive = self.sync_request.split(',')[0] |
219 | @@ -556,7 +536,8 @@ |
220 | @property |
221 | def series(self): |
222 | """Return the launchpadlib object representing the distro series.""" |
223 | - series = 'wily' if self._series == 'dual' else self._series |
224 | + series = self._series.split('+')[0] |
225 | + series = dict(dual='wily').get(series, series) |
226 | return lp.load('{}/{}'.format(self._distribution, series)) |
227 | |
228 | @property |
229 | @@ -599,25 +580,10 @@ |
230 | """Record the jenkins job URL that is setting this status.""" |
231 | self._config['global']['status']['url'] = value |
232 | |
233 | - @property |
234 | - def additional_targets(self): |
235 | - """Identify the additional targets this silo is also built for.""" |
236 | - return self._config.get('additional_targets') |
237 | - |
238 | - @additional_targets.setter |
239 | - def additional_targets(self, value): |
240 | - """Record additional targets for this silo to build for.""" |
241 | - self._config['additional_targets'] = value |
242 | - |
243 | def append_mp(self, source_package, mp_link): |
244 | """Record a new MP URL that this silo will build.""" |
245 | self._config['mps'].setdefault(source_package, []).append(mp_link) |
246 | |
247 | - def get_mtime(self): |
248 | - """Return the mtime of our configfile.""" |
249 | - with suppress(OSError): |
250 | - return os.path.getmtime(self.configfile) |
251 | - |
252 | |
253 | def save_error_message(message): |
254 | """Load the silo state, set an error message, then save it back.""" |
255 | |
256 | === modified file 'tests/unit/__init__.py' |
257 | --- tests/unit/__init__.py 2015-08-30 08:24:36 +0000 |
258 | +++ tests/unit/__init__.py 2015-09-05 01:43:08 +0000 |
259 | @@ -80,6 +80,15 @@ |
260 | infix, name, 'Rename {}.{} to include "{}".'.format( |
261 | cls.__name__, name, infix)) |
262 | |
263 | + def assertEqual(self, first, *args, **kwargs): |
264 | + """Give me useful diffs, I mean, really!""" |
265 | + if type(first) in (tuple, list): |
266 | + self.assertSequenceEqual(first, *args, **kwargs) |
267 | + elif type(first) is dict: |
268 | + self.assertDictEqual(first, *args, **kwargs) |
269 | + else: |
270 | + super().assertEqual(first, *args, **kwargs) |
271 | + |
272 | |
273 | class BaseTestCase(DirectoryAwareTestCase): |
274 | """Test module with helpers and keeping track of temp directories.""" |
275 | @@ -95,7 +104,7 @@ |
276 | |
277 | def assert_files_identical(self, filename1, filename2): |
278 | """Assert if the files contents are identical.""" |
279 | - self.assertEquals( |
280 | + self.assertEqual( |
281 | utf8_open(filename1).read().strip(), |
282 | utf8_open(filename2).read().strip()) |
283 | |
284 | @@ -103,7 +112,7 @@ |
285 | """Assert changelog files are identical, removing days/hours.""" |
286 | with utf8_open(alpha) as one: |
287 | with utf8_open(beta) as two: |
288 | - self.assertSequenceEqual( |
289 | + self.assertEqual( |
290 | [clean(line) for line in one.readlines()], |
291 | [clean(line) for line in two.readlines()]) |
292 | |
293 | |
294 | === modified file 'tests/unit/test_recipe_base.py' |
295 | --- tests/unit/test_recipe_base.py 2015-09-03 18:50:16 +0000 |
296 | +++ tests/unit/test_recipe_base.py 2015-09-05 01:43:08 +0000 |
297 | @@ -193,7 +193,7 @@ |
298 | build.timed_out(started=90, timeout=110, message='passed')) |
299 | self.assertIsNone( |
300 | build.timed_out(started=0, timeout=9, message='', condition=False)) |
301 | - self.assertSequenceEqual(BuildBase.failures, set([ |
302 | + self.assertEqual(BuildBase.failures, set([ |
303 | 'failed at 10', |
304 | 'failed at 99', |
305 | ])) |
306 | |
307 | === modified file 'tests/unit/test_recipe_sourcesync.py' |
308 | --- tests/unit/test_recipe_sourcesync.py 2015-08-31 06:25:46 +0000 |
309 | +++ tests/unit/test_recipe_sourcesync.py 2015-09-05 01:43:08 +0000 |
310 | @@ -129,7 +129,7 @@ |
311 | self.assertEqual(os_mock.remove.mock_calls, [ |
312 | call(self.tempdir + '/sink_1.dsc'), |
313 | ]) |
314 | - self.assertSequenceEqual(sh_mock.move.mock_calls, [ |
315 | + self.assertEqual(sh_mock.move.mock_calls, [ |
316 | call(self.tempdir + '/sink_1.orig.tar.gz', |
317 | self.tempdir + '/sink_1+15.04.20150210.orig.tar.gz'), |
318 | ]) |
319 | |
320 | === modified file 'tests/unit/test_script_prepare_silo.py' |
321 | --- tests/unit/test_script_prepare_silo.py 2015-09-04 00:38:51 +0000 |
322 | +++ tests/unit/test_script_prepare_silo.py 2015-09-05 01:43:08 +0000 |
323 | @@ -123,7 +123,6 @@ |
324 | env.SYNC_REQUEST = '' |
325 | self.script.validate_variables() |
326 | self.assertEqual(env.SERIES, 'wily') |
327 | - self.assertEqual(env.DUAL, 'vivid') |
328 | |
329 | def test_validate_variables_fail(self): |
330 | """Halt preparation if variables are missing.""" |
331 | @@ -187,12 +186,12 @@ |
332 | env.DISTRIBUTION = 'ubuntu' |
333 | self.script.join = Mock() |
334 | self.script.create_directories() |
335 | - self.assertSequenceEqual( |
336 | + self.assertEqual( |
337 | self.script.os.mkdir.mock_calls, |
338 | [call(expanduser('~/silos'))]) |
339 | - self.assertSequenceEqual(self.script.os.makedirs.mock_calls, [ |
340 | + self.assertEqual(self.script.os.makedirs.mock_calls, [ |
341 | call(self.script.join.return_value, exist_ok=True)] * 10) |
342 | - self.assertSequenceEqual( |
343 | + self.assertEqual( |
344 | self.script.join.mock_calls, |
345 | [call(expanduser('~/silos'), siloname) |
346 | for siloname in self.script.SILO_NAME_LIST[env.DISTRIBUTION]]) |
347 | @@ -229,9 +228,6 @@ |
348 | self.script.lp.distributions = dict(ubuntu=Mock()) |
349 | self.script.prepare_sync = Mock() |
350 | self.script.create_new_state() |
351 | - self.assertEqual(self.script.lp.get_ppa.mock_calls, [ |
352 | - call('ci-train-staging-area/ubuntu/landing-123'), |
353 | - ]) |
354 | self.script.SiloState.new_blank.assert_called_once_with( |
355 | siloname='ubuntu/landing-123', |
356 | requestid='42') |
357 | @@ -350,7 +346,7 @@ |
358 | self.assertEqual(self.script.lp.load.mock_calls, [ |
359 | call('http://example.com/a'), call('http://example.com/b'), |
360 | ]) |
361 | - self.assertSequenceEqual( |
362 | + self.assertEqual( |
363 | self.script.Branch.get_package_name_from_branch.mock_calls, [call( |
364 | self.script.lp.load.return_value.target_branch.display_name |
365 | )] * 2) |
366 | |
367 | === modified file 'tests/unit/test_script_publisher.py' |
368 | --- tests/unit/test_script_publisher.py 2015-09-02 03:32:52 +0000 |
369 | +++ tests/unit/test_script_publisher.py 2015-09-05 01:43:08 +0000 |
370 | @@ -221,8 +221,8 @@ |
371 | self.script.write_rsync_file(sources, dest) |
372 | self.script.PackageList.assert_called_once_with() |
373 | publish_source = self.script.PackageList().publish_source |
374 | - self.assertSequenceEqual(publish_source.mock_calls, [call(sources[1])]) |
375 | - self.assertSequenceEqual( |
376 | + self.assertEqual(publish_source.mock_calls, [call(sources[1])]) |
377 | + self.assertEqual( |
378 | self.script.DotProject.mock_calls, |
379 | [call('bar'), call().mark_as_published('2.0-0ubuntu1')]) |
380 | self.assertEqual(self.script.logging.error.call_count, 0) |
381 | @@ -256,7 +256,7 @@ |
382 | else: |
383 | self.assertNotIn(*args) |
384 | get_ppa = self.script.lp.get_ppa.return_value |
385 | - self.assertSequenceEqual(self.script.copy_to_dest.mock_calls, [ |
386 | + self.assertEqual(self.script.copy_to_dest.mock_calls, [ |
387 | call([sources[1]], dest=get_ppa, record=False), |
388 | call([sources[3]], dest=get_ppa, record=False), |
389 | ]) |
390 | |
391 | === modified file 'tests/unit/test_script_setup_citrain.py' |
392 | --- tests/unit/test_script_setup_citrain.py 2015-08-22 03:29:10 +0000 |
393 | +++ tests/unit/test_script_setup_citrain.py 2015-09-05 01:43:08 +0000 |
394 | @@ -44,8 +44,8 @@ |
395 | with utf8_open(listfile, 'w') as data: |
396 | data.write(json.dumps(expected)) |
397 | silos, distro = read_silo_names(listfile) |
398 | - self.assertSequenceEqual(silos, expected) |
399 | - self.assertDictEqual(distro, dict(ubuntu=silos)) |
400 | + self.assertEqual(silos, expected) |
401 | + self.assertEqual(distro, dict(ubuntu=silos)) |
402 | |
403 | def test_discover_silos(self): |
404 | """Ensure that we can query launchpad for existing PPAs.""" |
405 | @@ -57,11 +57,11 @@ |
406 | self.script.SILO_NAME_LIST = defaultdict(list) |
407 | self.script.SILO_NAMES_FILE = '/tmp/ci-train-silo-names' |
408 | self.script.discover_silos() |
409 | - self.assertSequenceEqual(self.script.ALL_SILO_NAMES, [ |
410 | + self.assertEqual(self.script.ALL_SILO_NAMES, [ |
411 | 'ubuntu/landing-000', |
412 | 'ubuntu/landing-999', |
413 | ]) |
414 | - self.assertDictEqual( |
415 | + self.assertEqual( |
416 | self.script.SILO_NAME_LIST, |
417 | dict(ubuntu=self.script.ALL_SILO_NAMES)) |
418 | |
419 | @@ -123,10 +123,10 @@ |
420 | self.script.setup_silo = Mock() |
421 | self.script.setup_job = Mock() |
422 | self.assertEqual(self.script.main(), 0) |
423 | - self.assertSequenceEqual(self.script.setup_silo.mock_calls, [ |
424 | + self.assertEqual(self.script.setup_silo.mock_calls, [ |
425 | call('ubuntu/landing-{:03d}'.format(x)) for x in range(0, 10) |
426 | ]) |
427 | - self.assertSequenceEqual(self.script.setup_job.mock_calls, [ |
428 | + self.assertEqual(self.script.setup_job.mock_calls, [ |
429 | call('cyphermox-test'), |
430 | call('prepare-silo'), |
431 | call('check-publication-migration'), |
432 | |
433 | === modified file 'tests/unit/test_silomanager.py' |
434 | --- tests/unit/test_silomanager.py 2015-09-04 00:38:51 +0000 |
435 | +++ tests/unit/test_silomanager.py 2015-09-05 01:43:08 +0000 |
436 | @@ -64,6 +64,7 @@ |
437 | landers='jim bob', |
438 | series='wily', |
439 | sources='', |
440 | + status='Hello from SiloManagerTestCase.setUp()', |
441 | sync_request='', |
442 | ) |
443 | self.state._configfile = join( |
444 | @@ -109,7 +110,7 @@ |
445 | ] |
446 | pre, expected = zip(*cases) |
447 | result = [silomanager.scrub(case) for case in pre] |
448 | - self.assertSequenceEqual(result, expected) |
449 | + self.assertEqual(result, expected) |
450 | |
451 | @patch('cupstream2distro.silomanager.SiloState.__init__') |
452 | @patch('cupstream2distro.silomanager.glob') |
453 | @@ -313,7 +314,7 @@ |
454 | preferred_email_address=Mock(email='r@example.com'))) |
455 | self.load_bileto() |
456 | req_mock.get.return_value.json.assert_called_once_with() |
457 | - self.assertDictEqual(self.state._bileto, dict(creator='robru')) |
458 | + self.assertEqual(self.state._bileto, dict(creator='robru')) |
459 | self.assertEqual(env.CREATOR_NAME, 'Robert') |
460 | self.assertEqual(env.CREATOR_EMAIL, 'r@example.com') |
461 | |
462 | @@ -333,21 +334,29 @@ |
463 | self.assertRaises(IOError, self.state.load_config) |
464 | |
465 | @patch('cupstream2distro.silomanager.SiloState.dest', Mock()) |
466 | - def test_silostate_push_to_ppa_description(self): |
467 | + @patch('cupstream2distro.silomanager.lp') |
468 | + def test_silostate_push_to_ppa_description(self, lp_mock): |
469 | """Invoke the correct lplib runes for ppa description setting.""" |
470 | + env.SILONAME = 'cool/description' |
471 | + ppa = lp_mock.get_ppa.return_value |
472 | self.state._bileto.update(distribution='ubuntu') |
473 | - self.state._ppa = Mock() |
474 | self.state.push_to_ppa_description() |
475 | - self.assertIn('Landers: jim bob', self.state._ppa.description) |
476 | - self.assertNotIn( |
477 | - 'https://api.launchpad.net/devel/', |
478 | - self.state._ppa.description) |
479 | - self.state._ppa.lp_save.assert_called_once_with() |
480 | + self.assertIn('Landers: jim bob', ppa.description) |
481 | + self.assertNotIn('https://api.launchpad.net/devel/', ppa.description) |
482 | + ppa.lp_save.assert_called_once_with() |
483 | + # lp.get_ppa() is called twice but this is ok because it caches the |
484 | + # returned object, so it's the same reference to the same obj each time |
485 | + self.assertEqual(lp_mock.get_ppa.mock_calls, [ |
486 | + call('ci-train-staging-area/cool/description'), |
487 | + call('ci-train-staging-area/cool/description'), |
488 | + call().lp_save(), |
489 | + ]) |
490 | |
491 | @patch('cupstream2distro.silomanager.BILETO_IP', '8.8.8.8') |
492 | @patch('cupstream2distro.silomanager.BILETO_API', 'example.com') |
493 | def test_silostate_push_to_bileto(self): |
494 | """Ensure that we push status messages to Bileto.""" |
495 | + self.state.status = 'Packages built' |
496 | self.state.push_to_bileto() |
497 | data = silomanager.requests.post.mock_calls[0][2]['data'] |
498 | self.assertIn('"status": "Packages built"', data) |
499 | @@ -373,6 +382,7 @@ |
500 | @patch('cupstream2distro.silomanager.BILETO_API', 'example.com') |
501 | def test_silostate_push_to_bileto_bad_response(self): |
502 | """Report failures from Bileto.""" |
503 | + self.state.status = 'Packages built' |
504 | silomanager.requests.post.return_value.ok = False |
505 | self.state.push_to_bileto() |
506 | data = silomanager.requests.post.mock_calls[0][2]['data'] |
507 | @@ -393,7 +403,6 @@ |
508 | """Save config to disk.""" |
509 | tmp = join(self.tempdir, 'config') |
510 | self.state._configfile = tmp |
511 | - self.state._mtime = self.state.get_mtime() |
512 | self.state.push_to_ppa_description = Mock() |
513 | self.state.push_to_bileto = Mock() |
514 | self.state.load_bileto = Mock() |
515 | @@ -410,7 +419,6 @@ |
516 | """Can save twice in a row without mtime check screwing us.""" |
517 | tmp = join(self.tempdir, 'config') |
518 | self.state._configfile = tmp |
519 | - self.state._mtime = self.state.get_mtime() |
520 | self.state.push_to_ppa_description = Mock() |
521 | self.state.push_to_bileto = Mock() |
522 | self.state.save_config() |
523 | @@ -419,27 +427,6 @@ |
524 | time.sleep(0.01) |
525 | self.state.save_config() |
526 | |
527 | - @patch('cupstream2distro.silomanager.os.makedirs') |
528 | - @patch('cupstream2distro.silomanager.SiloState.load_bileto', Mock()) |
529 | - def test_silostate_save_config_bad_mtime(self, mkdir): |
530 | - """Merge status messages if it changed since loading.""" |
531 | - tmp = join(self.tempdir, 'config') |
532 | - self.state._configfile = tmp |
533 | - self.state._mtime = self.state.get_mtime() |
534 | - self.state.message = 'First.' |
535 | - self.state.push_to_ppa_description = Mock() |
536 | - self.state.push_to_bileto = Mock() |
537 | - self.state.save_config() |
538 | - self.state.push_to_ppa_description.assert_called_once_with() |
539 | - self.state.push_to_bileto.assert_called_once_with() |
540 | - self.state._mtime = 0 |
541 | - self.state.message = 'Second.' |
542 | - self.state.save_config() |
543 | - new = SiloState('phony-siloname', do_load=False) |
544 | - new._configfile = tmp |
545 | - new.load_config() |
546 | - self.assertEqual(new.message, 'First. Second.') |
547 | - |
548 | def test_silostate_config_step(self): |
549 | """Read the config step.""" |
550 | self.assertEqual(self.state.config_step, 1) |
551 | @@ -453,21 +440,16 @@ |
552 | """Set the config status.""" |
553 | silomanager.env.BUILD_URL = 'http://example.com/jenkins/' |
554 | self.state.set_config_status(-1, 'Everything is broken!') |
555 | + self.assertEqual(self.state._status, 'Everything is broken!') |
556 | self.assertEqual( |
557 | - self.state._config['global']['status'], |
558 | - dict( |
559 | - message='Everything is broken!', |
560 | - ping=True, |
561 | - state=-1, |
562 | - url='http://example.com/jenkins/console')) |
563 | + self.state._config['global']['status']['url'], |
564 | + 'http://example.com/jenkins/console') |
565 | |
566 | def test_silostate_set_config_status_scrubbed(self): |
567 | """Scrub the config status.""" |
568 | silomanager.env.BUILD_URL = 'http://example.com/jenkins/' |
569 | self.state.set_config_status(-1, 'Exception: token=LEAKED') |
570 | - self.assertEqual( |
571 | - self.state._config['global']['status']['message'], |
572 | - 'Exception: token=XXX') |
573 | + self.assertEqual(self.state._status, 'Exception: token=XXX') |
574 | |
575 | @patch('cupstream2distro.silomanager.SiloState') |
576 | def test_silostate_sources_sync_silo(self, ss_mock): |
577 | @@ -478,6 +460,31 @@ |
578 | self.assertEqual(self.state.sources, ss_mock.return_value.all_projects) |
579 | ss_mock.assert_called_once_with('ubuntu/landing-005') |
580 | |
581 | + def test_silostate_dual(self): |
582 | + """Ensure that dual property reflects correct series.""" |
583 | + self.state._bileto.update(series='wily+vivid') |
584 | + self.assertEqual(self.state.dual, 'vivid') |
585 | + self.state._bileto.update(series='dual') |
586 | + self.assertEqual(self.state.dual, 'vivid') |
587 | + self.state._bileto.update(series='wily') |
588 | + self.assertIsNone(self.state.dual) |
589 | + |
590 | + @patch('cupstream2distro.silomanager.lp') |
591 | + def test_silostate_series(self, lp_mock): |
592 | + """Ensure that series property reflects correct series.""" |
593 | + self.state._bileto.update(distribution='ubuntu') |
594 | + cases = ( |
595 | + ('wily+vivid', 'wily'), |
596 | + ('dual', 'wily'), |
597 | + ('wily', 'wily'), |
598 | + ('vivid', 'vivid'), |
599 | + ) |
600 | + for inn, out in cases: |
601 | + self.state._bileto.update(series=inn) |
602 | + self.assertEqual(self.state.series, lp_mock.load.return_value) |
603 | + lp_mock.load.assert_called_once_with('ubuntu/' + out) |
604 | + lp_mock.reset_mock() |
605 | + |
606 | @patch('cupstream2distro.silomanager.lp') |
607 | def test_silostate_dest_archive(self, lp_mock): |
608 | """Ensure that dest property reflects correct archive.""" |
609 | @@ -619,10 +626,6 @@ |
610 | 'https://api.launchpad.net/devel/~gerboland/platform-api/' |
611 | 'exposeOrientation/+merge/232250' |
612 | ]}) |
613 | - self.assertEqual( |
614 | - self.state.ppa.self_link, |
615 | - 'https://api.launchpad.net/devel/~ci-train-ppa-service/+archive/' |
616 | - 'ubuntu/landing-123') |
617 | self.assertEqual(self.state.state, 3) |
618 | self.assertEqual(self.state.requestid, '1411123362781') |
619 | self.assertEqual(self.state.siloname, 'ubuntu/landing-123') |
620 | @@ -636,12 +639,8 @@ |
621 | """Set various state properties.""" |
622 | self.state.config_step = 9000 |
623 | self.assertEqual(self.state._config['global']['step'], 9000) |
624 | - self.state.dual = 'vivid' |
625 | - self.assertEqual(self.state._config['dual'], 'vivid') |
626 | self.state.mps = 'flibbyjib' |
627 | self.assertEqual(self.state._config['mps'], 'flibbyjib') |
628 | - self.state.ppa = Mock(self_link='my ppa') |
629 | - self.assertEqual(self.state._config['global']['ppa'], 'my ppa') |
630 | self.state.requestid = 'bazinga' |
631 | self.assertEqual(self.state._config['requestid'], 'bazinga') |
632 | self.state.source_archive = 'ubuntu' |
633 | @@ -684,37 +683,6 @@ |
634 | {'foobar': ['example.com', 'example.com/zip'], |
635 | 'fringle': ['example.com/futz']}) |
636 | |
637 | - @patch('cupstream2distro.silomanager.os.makedirs', Mock()) |
638 | - def test_get_mtime(self): |
639 | - """Get the modified time of the config file.""" |
640 | - tmp = join(self.tempdir, 'config') |
641 | - first = self.state.get_mtime() |
642 | - self.assertGreater(first, 0) |
643 | - self.state._configfile = tmp |
644 | - self.state._mtime = self.state.get_mtime() |
645 | - self.state.push_to_ppa_description = Mock() |
646 | - self.state.push_to_bileto = Mock() |
647 | - self.state.save_config() |
648 | - self.state.push_to_ppa_description.assert_called_once_with() |
649 | - self.state.push_to_bileto.assert_called_once_with() |
650 | - second = self.state.get_mtime() |
651 | - self.assertGreater(second, first) |
652 | - time.sleep(0.01) |
653 | - self.assertEqual(second, self.state.get_mtime()) |
654 | - |
655 | - def test_get_mtime_file_missing(self): |
656 | - """Return None if file is missing.""" |
657 | - self.state._configfile = '/totally/not/even/there' |
658 | - self.assertIsNone(self.state.get_mtime()) |
659 | - |
660 | - def test_additional_targets(self): |
661 | - """Get and set the additional targets list.""" |
662 | - self.assertEqual(self.state.additional_targets, None) |
663 | - self.state.additional_targets = list('abc') |
664 | - self.assertEqual(self.state.additional_targets, ['a', 'b', 'c']) |
665 | - self.assertEqual( |
666 | - self.state._config['additional_targets'], ['a', 'b', 'c']) |
667 | - |
668 | def test_signal_handler(self): |
669 | """Our signal handler is installed globally.""" |
670 | self.assertTrue( |
PASSED: Continuous integration, rev:1093 jenkins. qa.ubuntu. com/job/ cu2d-choo- choo-ci/ 752/
http://
Executed test runs:
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/cu2d- choo-choo- ci/752/ rebuild
http://