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: | 1124 |
Merged at revision: | 1079 |
Proposed branch: | lp:~robru/cupstream2distro/moar-bileto |
Merge into: | lp:cupstream2distro |
Diff against target: |
456 lines (+104/-141) 7 files modified
citrain/build.py (+2/-4) citrain/prepare_silo.py (+0/-25) citrain/recipes/base.py (+1/-0) cupstream2distro/silomanager.py (+34/-18) tests/unit/test_script_build.py (+1/-5) tests/unit/test_script_prepare_silo.py (+0/-78) tests/unit/test_silomanager.py (+66/-11) |
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+270258@code.launchpad.net |
Commit message
Convert source_archive and source_series to Bileto.
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
- 1124. By Robert Bruce Park
-
Print silo summary early during build.
Revision history for this message
Robert Bruce Park (robru) wrote : | # |
Looks good in staging.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'citrain/build.py' | |||
2 | --- citrain/build.py 2015-09-05 03:54:05 +0000 | |||
3 | +++ citrain/build.py 2015-09-06 00:07:30 +0000 | |||
4 | @@ -60,7 +60,6 @@ | |||
5 | 60 | from citrain.recipes.sourcesync import SourceSync | 60 | from citrain.recipes.sourcesync import SourceSync |
6 | 61 | from citrain.recipes.binarysync import BinarySync | 61 | from citrain.recipes.binarysync import BinarySync |
7 | 62 | from cupstream2distro.silomanager import SiloState | 62 | from cupstream2distro.silomanager import SiloState |
8 | 63 | from cupstream2distro.launchpadmanager import lp | ||
9 | 64 | from cupstream2distro.errors import BuildError, CITrainError | 63 | from cupstream2distro.errors import BuildError, CITrainError |
10 | 65 | from cupstream2distro.utils import ( | 64 | from cupstream2distro.utils import ( |
11 | 66 | env, | 65 | env, |
12 | @@ -124,9 +123,8 @@ | |||
13 | 124 | Source: self.names & set(self.silo_state.sources), | 123 | Source: self.names & set(self.silo_state.sources), |
14 | 125 | } | 124 | } |
15 | 126 | if self.silo_state.source_archive: | 125 | if self.silo_state.source_archive: |
19 | 127 | Sync.from_archive = lp.load(self.silo_state.source_archive) | 126 | Sync.from_archive = self.silo_state.source_archive |
20 | 128 | Sync.from_series = lp.get_series( | 127 | Sync.from_series = self.silo_state.source_series |
18 | 129 | self.silo_state.source_series, dest=Sync.from_archive) | ||
21 | 130 | Merge.all_mps = self.silo_state.mps | 128 | Merge.all_mps = self.silo_state.mps |
22 | 131 | 129 | ||
23 | 132 | def instantiate_build_objects(self): | 130 | def instantiate_build_objects(self): |
24 | 133 | 131 | ||
25 | === modified file 'citrain/prepare_silo.py' | |||
26 | --- citrain/prepare_silo.py 2015-09-05 19:41:20 +0000 | |||
27 | +++ citrain/prepare_silo.py 2015-09-06 00:07:30 +0000 | |||
28 | @@ -45,10 +45,8 @@ | |||
29 | 45 | 45 | ||
30 | 46 | from cupstream2distro.settings import ( | 46 | from cupstream2distro.settings import ( |
31 | 47 | BILETO_GET, | 47 | BILETO_GET, |
32 | 48 | LANDING_SCHEME, | ||
33 | 49 | SILO_NAME_LIST, | 48 | SILO_NAME_LIST, |
34 | 50 | SILOS_DIR, | 49 | SILOS_DIR, |
35 | 51 | STABLE_OVERLAY_PPA, | ||
36 | 52 | ) | 50 | ) |
37 | 53 | from cupstream2distro.utils import ( | 51 | from cupstream2distro.utils import ( |
38 | 54 | SILO_DIR, | 52 | SILO_DIR, |
39 | @@ -133,32 +131,9 @@ | |||
40 | 133 | silo_state = SiloState.new_blank( | 131 | silo_state = SiloState.new_blank( |
41 | 134 | siloname=env.SILONAME, | 132 | siloname=env.SILONAME, |
42 | 135 | requestid=env.REQUEST_ID) | 133 | requestid=env.REQUEST_ID) |
43 | 136 | if env.SYNC_REQUEST: | ||
44 | 137 | prepare_sync(silo_state) | ||
45 | 138 | return silo_state | 134 | return silo_state |
46 | 139 | 135 | ||
47 | 140 | 136 | ||
48 | 141 | def prepare_sync(silo_state): | ||
49 | 142 | """Process sync request.""" | ||
50 | 143 | archive, comma, series = env.SYNC_REQUEST.partition(',') | ||
51 | 144 | source_series = series or env.SERIES | ||
52 | 145 | if archive.startswith('ppa:'): | ||
53 | 146 | source_archive = lp.get_ppa(archive.split(':')[1].strip('~')) | ||
54 | 147 | elif archive.isdigit(): | ||
55 | 148 | siloname = '{}/landing-{:03d}'.format(env.DISTRIBUTION, int(archive)) | ||
56 | 149 | source_archive = lp.get_ppa(LANDING_SCHEME.format(siloname)) | ||
57 | 150 | source_state = SiloState(siloname) | ||
58 | 151 | source_series = source_state.series.name | ||
59 | 152 | elif archive == 'stable-overlay': | ||
60 | 153 | source_archive = lp.get_ppa(STABLE_OVERLAY_PPA) | ||
61 | 154 | else: | ||
62 | 155 | source_archive = lp.distributions[archive].main_archive | ||
63 | 156 | logging.info('Syncing from {} {}.'.format( | ||
64 | 157 | source_series, source_archive.web_link)) | ||
65 | 158 | silo_state.source_archive = source_archive.self_link | ||
66 | 159 | silo_state.source_series = source_series | ||
67 | 160 | |||
68 | 161 | |||
69 | 162 | def check_merge_status(merge): | 137 | def check_merge_status(merge): |
70 | 163 | """Raise PrepError if merge is in wrong state.""" | 138 | """Raise PrepError if merge is in wrong state.""" |
71 | 164 | try: | 139 | try: |
72 | 165 | 140 | ||
73 | === modified file 'citrain/recipes/base.py' | |||
74 | --- citrain/recipes/base.py 2015-09-03 18:50:16 +0000 | |||
75 | +++ citrain/recipes/base.py 2015-09-06 00:07:30 +0000 | |||
76 | @@ -168,6 +168,7 @@ | |||
77 | 168 | silo_state.set_empty() | 168 | silo_state.set_empty() |
78 | 169 | silo_state.set_preparing() | 169 | silo_state.set_preparing() |
79 | 170 | silo_state.save_config() | 170 | silo_state.save_config() |
80 | 171 | logging.info(silo_state.summarize()) | ||
81 | 171 | 172 | ||
82 | 172 | def clean_phase(self): | 173 | def clean_phase(self): |
83 | 173 | """Delete files leftover from previous builds.""" | 174 | """Delete files leftover from previous builds.""" |
84 | 174 | 175 | ||
85 | === modified file 'cupstream2distro/silomanager.py' | |||
86 | --- cupstream2distro/silomanager.py 2015-09-05 20:33:19 +0000 | |||
87 | +++ cupstream2distro/silomanager.py 2015-09-06 00:07:30 +0000 | |||
88 | @@ -41,9 +41,9 @@ | |||
89 | 41 | LANDING_SCHEME, | 41 | LANDING_SCHEME, |
90 | 42 | SILO_NAME_LIST, | 42 | SILO_NAME_LIST, |
91 | 43 | SILOS_DIR, | 43 | SILOS_DIR, |
92 | 44 | STABLE_OVERLAY_PPA, | ||
93 | 44 | ) | 45 | ) |
94 | 45 | from cupstream2distro.utils import ( | 46 | from cupstream2distro.utils import ( |
95 | 46 | SILO_DIR, | ||
96 | 47 | env, | 47 | env, |
97 | 48 | memoize, | 48 | memoize, |
98 | 49 | log_value_of, | 49 | log_value_of, |
99 | @@ -176,7 +176,7 @@ | |||
100 | 176 | @property | 176 | @property |
101 | 177 | def request_id_file(self): | 177 | def request_id_file(self): |
102 | 178 | """Identify the file that contains the requestid.""" | 178 | """Identify the file that contains the requestid.""" |
104 | 179 | return SILO_DIR('request_id') | 179 | return join(SILOS_DIR, self.siloname, 'request_id') |
105 | 180 | 180 | ||
106 | 181 | @staticmethod | 181 | @staticmethod |
107 | 182 | def find_first_available(distribution='ubuntu'): | 182 | def find_first_available(distribution='ubuntu'): |
108 | @@ -463,7 +463,7 @@ | |||
109 | 463 | @property | 463 | @property |
110 | 464 | def step_file(self): | 464 | def step_file(self): |
111 | 465 | """Define filename indicating silo has been published.""" | 465 | """Define filename indicating silo has been published.""" |
113 | 466 | return SILO_DIR('step') | 466 | return join(SILOS_DIR, self.siloname, 'step') |
114 | 467 | 467 | ||
115 | 468 | @property | 468 | @property |
116 | 469 | def step(self): | 469 | def step(self): |
117 | @@ -537,9 +537,10 @@ | |||
118 | 537 | return self._series.split('+')[-1] | 537 | return self._series.split('+')[-1] |
119 | 538 | 538 | ||
120 | 539 | @property | 539 | @property |
121 | 540 | @memoize | ||
122 | 540 | def sources(self): | 541 | def sources(self): |
123 | 541 | """Identify the manual source packages configured for this silo.""" | 542 | """Identify the manual source packages configured for this silo.""" |
125 | 542 | archive = self.sync_request.split(',')[0] | 543 | archive = self.sync_request.partition(',')[0] |
126 | 543 | sources = splitter(self._sources) | 544 | sources = splitter(self._sources) |
127 | 544 | if not sources and archive.isdigit(): | 545 | if not sources and archive.isdigit(): |
128 | 545 | return self.load_source_sync_sources(int(archive)) | 546 | return self.load_source_sync_sources(int(archive)) |
129 | @@ -549,7 +550,7 @@ | |||
130 | 549 | def load_source_sync_sources(self, silonum): | 550 | def load_source_sync_sources(self, silonum): |
131 | 550 | """Check what packages are configured in a different silo.""" | 551 | """Check what packages are configured in a different silo.""" |
132 | 551 | self.info('Inferring source names from silo {}.'.format(silonum)) | 552 | self.info('Inferring source names from silo {}.'.format(silonum)) |
134 | 552 | return SiloState( | 553 | return self.get_source_state( |
135 | 553 | '{}/landing-{:03d}'.format(self._distribution, silonum) | 554 | '{}/landing-{:03d}'.format(self._distribution, silonum) |
136 | 554 | ).all_projects | 555 | ).all_projects |
137 | 555 | 556 | ||
138 | @@ -574,24 +575,39 @@ | |||
139 | 574 | return lp.load('{}/{}'.format(self._distribution, series)) | 575 | return lp.load('{}/{}'.format(self._distribution, series)) |
140 | 575 | 576 | ||
141 | 576 | @property | 577 | @property |
142 | 578 | @memoize | ||
143 | 577 | def source_archive(self): | 579 | def source_archive(self): |
151 | 578 | """Identify the archive we are synching from.""" | 580 | """Identify the archive we are syncing from.""" |
152 | 579 | return self._config.get('source_archive') | 581 | archive = self._sync_request.partition(',')[0] |
153 | 580 | 582 | if archive.startswith('ppa:'): | |
154 | 581 | @source_archive.setter | 583 | return lp.get_ppa(archive.split(':')[1].strip('~')) |
155 | 582 | def source_archive(self, value): | 584 | elif archive.isdigit(): |
156 | 583 | """Record the archive we are syncing from.""" | 585 | siloname = '{}/landing-{:03d}'.format( |
157 | 584 | self._config['source_archive'] = value | 586 | self._distribution, int(archive)) |
158 | 587 | return lp.get_ppa(LANDING_SCHEME.format(siloname)) | ||
159 | 588 | elif archive == 'stable-overlay': | ||
160 | 589 | return lp.get_ppa(STABLE_OVERLAY_PPA) | ||
161 | 590 | elif archive: | ||
162 | 591 | return lp.distributions[archive].main_archive | ||
163 | 585 | 592 | ||
164 | 586 | @property | 593 | @property |
165 | 594 | @memoize | ||
166 | 587 | def source_series(self): | 595 | def source_series(self): |
167 | 588 | """Identify the distro series we are syncing from.""" | 596 | """Identify the distro series we are syncing from.""" |
169 | 589 | return self._config.get('source_series') | 597 | archive, comma, series = self._sync_request.partition(',') |
170 | 598 | if archive.isdigit(): | ||
171 | 599 | siloname = '{}/landing-{:03d}'.format( | ||
172 | 600 | self._distribution, int(archive)) | ||
173 | 601 | return self.get_source_state(siloname).series | ||
174 | 602 | elif archive: | ||
175 | 603 | return lp.load('{}/{}'.format( | ||
176 | 604 | self.source_archive.distribution.name, | ||
177 | 605 | series or self._series)) | ||
178 | 590 | 606 | ||
183 | 591 | @source_series.setter | 607 | @memoize |
184 | 592 | def source_series(self, value): | 608 | def get_source_state(self, siloname): |
185 | 593 | """Record the distro series we are syncing from.""" | 609 | """Fetch SiloState object representing some other silo.""" |
186 | 594 | self._config['source_series'] = value | 610 | return SiloState(siloname) |
187 | 595 | 611 | ||
188 | 596 | def append_mp(self, source_package, mp_link): | 612 | def append_mp(self, source_package, mp_link): |
189 | 597 | """Record a new MP URL that this silo will build.""" | 613 | """Record a new MP URL that this silo will build.""" |
190 | @@ -604,7 +620,7 @@ | |||
191 | 604 | logging.error(message) | 620 | logging.error(message) |
192 | 605 | if env.SILONAME: | 621 | if env.SILONAME: |
193 | 606 | silo_state = SiloState(env.SILONAME) | 622 | silo_state = SiloState(env.SILONAME) |
195 | 607 | silo_state.set_config_status(-1, message) | 623 | silo_state.set_config_status(message) |
196 | 608 | silo_state.save_config() | 624 | silo_state.save_config() |
197 | 609 | 625 | ||
198 | 610 | 626 | ||
199 | 611 | 627 | ||
200 | === modified file 'tests/unit/test_script_build.py' | |||
201 | --- tests/unit/test_script_build.py 2015-09-05 03:54:05 +0000 | |||
202 | +++ tests/unit/test_script_build.py 2015-09-06 00:07:30 +0000 | |||
203 | @@ -112,13 +112,9 @@ | |||
204 | 112 | self.script.SourceSync: set(['b']), | 112 | self.script.SourceSync: set(['b']), |
205 | 113 | }) | 113 | }) |
206 | 114 | self.assertEqual(self.script.Merge.all_mps, silo_state.mps) | 114 | self.assertEqual(self.script.Merge.all_mps, silo_state.mps) |
207 | 115 | self.assertEqual(self.script.lp.get_series.mock_calls, [ | ||
208 | 116 | call(silo_state.source_series, | ||
209 | 117 | dest=self.script.SourceSync.from_archive), | ||
210 | 118 | ]) | ||
211 | 119 | self.assertEqual( | 115 | self.assertEqual( |
212 | 120 | self.script.SourceSync.from_series, | 116 | self.script.SourceSync.from_series, |
214 | 121 | self.script.lp.get_series.return_value) | 117 | silo_state.source_series) |
215 | 122 | 118 | ||
216 | 123 | def test_buildmanager_instantiate_build_objects(self): | 119 | def test_buildmanager_instantiate_build_objects(self): |
217 | 124 | """Create all build objects.""" | 120 | """Create all build objects.""" |
218 | 125 | 121 | ||
219 | === modified file 'tests/unit/test_script_prepare_silo.py' | |||
220 | --- tests/unit/test_script_prepare_silo.py 2015-09-05 19:16:06 +0000 | |||
221 | +++ tests/unit/test_script_prepare_silo.py 2015-09-06 00:07:30 +0000 | |||
222 | @@ -23,7 +23,6 @@ | |||
223 | 23 | from cupstream2distro import project | 23 | from cupstream2distro import project |
224 | 24 | from cupstream2distro.utils import env, os_path_join_safe | 24 | from cupstream2distro.utils import env, os_path_join_safe |
225 | 25 | from cupstream2distro.errors import PrepError | 25 | from cupstream2distro.errors import PrepError |
226 | 26 | from cupstream2distro.settings import STABLE_OVERLAY_PPA | ||
227 | 27 | 26 | ||
228 | 28 | from tests.unit import CITrainScriptTestCase | 27 | from tests.unit import CITrainScriptTestCase |
229 | 29 | 28 | ||
230 | @@ -169,87 +168,10 @@ | |||
231 | 169 | env.DISTRIBUTION = 'ubuntu' | 168 | env.DISTRIBUTION = 'ubuntu' |
232 | 170 | env.SERIES = 'wily' | 169 | env.SERIES = 'wily' |
233 | 171 | self.script.lp.distributions = dict(ubuntu=Mock()) | 170 | self.script.lp.distributions = dict(ubuntu=Mock()) |
234 | 172 | self.script.prepare_sync = Mock() | ||
235 | 173 | self.script.create_new_state() | 171 | self.script.create_new_state() |
236 | 174 | self.script.SiloState.new_blank.assert_called_once_with( | 172 | self.script.SiloState.new_blank.assert_called_once_with( |
237 | 175 | siloname='ubuntu/landing-123', | 173 | siloname='ubuntu/landing-123', |
238 | 176 | requestid='42') | 174 | requestid='42') |
239 | 177 | self.script.prepare_sync.assert_called_once_with( | ||
240 | 178 | self.script.SiloState.new_blank.return_value) | ||
241 | 179 | |||
242 | 180 | def test_prepare_sync_ppa(self): | ||
243 | 181 | """Configure syncs correctly from a PPA.""" | ||
244 | 182 | silo_state = Mock() | ||
245 | 183 | env.DISTRIBUTION = 'ubuntu' | ||
246 | 184 | env.SERIES = 'wily' | ||
247 | 185 | env.SOURCES = 'foo, bar, baz' | ||
248 | 186 | env.SYNC_REQUEST = 'ppa:some/ubuntu/place,vivid' | ||
249 | 187 | self.script.prepare_sync(silo_state) | ||
250 | 188 | self.script.lp.get_ppa.assert_called_once_with('some/ubuntu/place') | ||
251 | 189 | self.assertEqual(silo_state.source_series, 'vivid') | ||
252 | 190 | self.assertEqual( | ||
253 | 191 | silo_state.source_archive, | ||
254 | 192 | self.script.lp.get_ppa.return_value.self_link) | ||
255 | 193 | |||
256 | 194 | def test_prepare_sync_silo(self): | ||
257 | 195 | """Configure syncs correctly from a silo.""" | ||
258 | 196 | silo_state = Mock() | ||
259 | 197 | env.DISTRIBUTION = 'ubuntu' | ||
260 | 198 | env.SERIES = 'wily' | ||
261 | 199 | env.SOURCES = 'foo, bar, baz' | ||
262 | 200 | env.SYNC_REQUEST = '8' | ||
263 | 201 | self.script.SiloState.return_value.series.name = 'utopic' | ||
264 | 202 | self.script.prepare_sync(silo_state) | ||
265 | 203 | self.script.lp.get_ppa.assert_called_once_with( | ||
266 | 204 | 'ci-train-staging-area/ubuntu/landing-008') | ||
267 | 205 | self.assertEqual(silo_state.source_series, 'utopic') | ||
268 | 206 | self.assertEqual( | ||
269 | 207 | silo_state.source_archive, | ||
270 | 208 | self.script.lp.get_ppa.return_value.self_link) | ||
271 | 209 | |||
272 | 210 | def test_prepare_sync_silo_sources(self): | ||
273 | 211 | """Configure syncs correctly from a silo.""" | ||
274 | 212 | silo_state = Mock() | ||
275 | 213 | env.DISTRIBUTION = 'ubuntu' | ||
276 | 214 | env.SERIES = 'wily' | ||
277 | 215 | env.SOURCES = '' | ||
278 | 216 | env.SYNC_REQUEST = '8' | ||
279 | 217 | self.script.SiloState.return_value.series.name = 'vivid' | ||
280 | 218 | self.script.prepare_sync(silo_state) | ||
281 | 219 | self.script.lp.get_ppa.assert_called_once_with( | ||
282 | 220 | 'ci-train-staging-area/ubuntu/landing-008') | ||
283 | 221 | self.assertEqual(silo_state.source_series, 'vivid') | ||
284 | 222 | self.assertEqual( | ||
285 | 223 | silo_state.source_archive, | ||
286 | 224 | self.script.lp.get_ppa.return_value.self_link) | ||
287 | 225 | |||
288 | 226 | def test_prepare_sync_overlay(self): | ||
289 | 227 | """Configure syncs correctly from the overlay.""" | ||
290 | 228 | silo_state = Mock() | ||
291 | 229 | env.DISTRIBUTION = 'ubuntu' | ||
292 | 230 | env.SERIES = 'wily' | ||
293 | 231 | env.SOURCES = 'foo, bar, baz' | ||
294 | 232 | env.SYNC_REQUEST = 'stable-overlay' | ||
295 | 233 | self.script.prepare_sync(silo_state) | ||
296 | 234 | self.script.lp.get_ppa.assert_called_once_with(STABLE_OVERLAY_PPA) | ||
297 | 235 | self.assertEqual(silo_state.source_series, 'wily') | ||
298 | 236 | self.assertEqual( | ||
299 | 237 | silo_state.source_archive, | ||
300 | 238 | self.script.lp.get_ppa.return_value.self_link) | ||
301 | 239 | |||
302 | 240 | def test_prepare_sync_main(self): | ||
303 | 241 | """Configure syncs correctly from the main archive.""" | ||
304 | 242 | silo_state = Mock() | ||
305 | 243 | env.DISTRIBUTION = 'ubuntu' | ||
306 | 244 | env.SERIES = 'wily' | ||
307 | 245 | env.SOURCES = 'foo, bar, baz' | ||
308 | 246 | env.SYNC_REQUEST = 'ubuntu,vivid' | ||
309 | 247 | ubuntu = Mock() | ||
310 | 248 | self.script.lp.distributions = dict(ubuntu=ubuntu) | ||
311 | 249 | self.script.prepare_sync(silo_state) | ||
312 | 250 | self.assertEqual(silo_state.source_series, 'vivid') | ||
313 | 251 | self.assertEqual( | ||
314 | 252 | silo_state.source_archive, ubuntu.main_archive.self_link) | ||
315 | 253 | 175 | ||
316 | 254 | def test_check_merge_status(self): | 176 | def test_check_merge_status(self): |
317 | 255 | """Ensure that merges are in acceptable states.""" | 177 | """Ensure that merges are in acceptable states.""" |
318 | 256 | 178 | ||
319 | === modified file 'tests/unit/test_silomanager.py' | |||
320 | --- tests/unit/test_silomanager.py 2015-09-05 20:18:00 +0000 | |||
321 | +++ tests/unit/test_silomanager.py 2015-09-06 00:07:30 +0000 | |||
322 | @@ -86,15 +86,74 @@ | |||
323 | 86 | silomanager.SILO_NAME_LIST = dict( | 86 | silomanager.SILO_NAME_LIST = dict( |
324 | 87 | ubuntu=['ubuntu/landing-00{}'.format(x) for x in range(0, 10)]) | 87 | ubuntu=['ubuntu/landing-00{}'.format(x) for x in range(0, 10)]) |
325 | 88 | 88 | ||
326 | 89 | def test_silomanager_refuse_SILO_DIR(self): | ||
327 | 90 | """Prevent badness from baddening.""" | ||
328 | 91 | self.assertFalse( | ||
329 | 92 | hasattr(silomanager, 'SILO_DIR'), | ||
330 | 93 | 'SILO_DIR() cannot be trusted inside SiloState class.') | ||
331 | 94 | |||
332 | 89 | def test_silostate_requestid(self): | 95 | def test_silostate_requestid(self): |
333 | 90 | """Ensure requestid property behaves sensible.""" | 96 | """Ensure requestid property behaves sensible.""" |
335 | 91 | func = 'cupstream2distro.silomanager.SILO_DIR' | 97 | func = 'cupstream2distro.silomanager.join' |
336 | 92 | with patch(func, lambda *ingore: self.tempdir + '/step'): | 98 | with patch(func, lambda *ingore: self.tempdir + '/step'): |
337 | 93 | self.state.requestid = '42' | 99 | self.state.requestid = '42' |
338 | 94 | self.assertEqual(self.state._config['requestid'], '42') | 100 | self.assertEqual(self.state._config['requestid'], '42') |
339 | 95 | self.state._config['requestid'] = None | 101 | self.state._config['requestid'] = None |
340 | 96 | self.assertEqual(self.state.requestid, '42') | 102 | self.assertEqual(self.state.requestid, '42') |
341 | 97 | 103 | ||
342 | 104 | @patch('cupstream2distro.silomanager.lp') | ||
343 | 105 | def test_silostate_source_archive_ppa(self, lp_mock): | ||
344 | 106 | """Ensure source_archive property has correct return values.""" | ||
345 | 107 | lp_mock.get_ppa.return_value.distribution.name = 'ubuntu' | ||
346 | 108 | self.state._bileto.update(sync_request='ppa:team/ubuntu/ppa,vivid') | ||
347 | 109 | self.assertEqual( | ||
348 | 110 | self.state.source_archive, lp_mock.get_ppa.return_value) | ||
349 | 111 | lp_mock.get_ppa.assert_called_once_with('team/ubuntu/ppa') | ||
350 | 112 | self.assertEqual(self.state.source_series, lp_mock.load.return_value) | ||
351 | 113 | lp_mock.load.assert_called_once_with('ubuntu/vivid') | ||
352 | 114 | |||
353 | 115 | @patch('cupstream2distro.silomanager.lp') | ||
354 | 116 | @patch('cupstream2distro.silomanager.SiloState') | ||
355 | 117 | def test_silostate_source_archive_digit(self, ss_mock, lp_mock): | ||
356 | 118 | """Ensure source_archive property has correct return values.""" | ||
357 | 119 | ss_mock.return_value.series = 'zip' | ||
358 | 120 | self.state._bileto.update(sync_request='12', distribution='blah') | ||
359 | 121 | self.assertEqual( | ||
360 | 122 | self.state.source_archive, lp_mock.get_ppa.return_value) | ||
361 | 123 | lp_mock.get_ppa.assert_called_once_with( | ||
362 | 124 | 'ci-train-staging-area/blah/landing-012') | ||
363 | 125 | self.assertEqual(self.state.source_series, 'zip') | ||
364 | 126 | |||
365 | 127 | @patch('cupstream2distro.silomanager.lp') | ||
366 | 128 | def test_silostate_source_archive_stable(self, lp_mock): | ||
367 | 129 | """Ensure source_archive property has correct return values.""" | ||
368 | 130 | lp_mock.get_ppa.return_value.distribution.name = 'ubuntu' | ||
369 | 131 | self.state._bileto.update(sync_request='stable-overlay,vivid') | ||
370 | 132 | self.assertEqual( | ||
371 | 133 | self.state.source_archive, lp_mock.get_ppa.return_value) | ||
372 | 134 | lp_mock.get_ppa.assert_called_once_with( | ||
373 | 135 | 'ci-train-staging-area/ubuntu/stable-phone-overlay') | ||
374 | 136 | self.assertEqual(self.state.source_series, lp_mock.load.return_value) | ||
375 | 137 | lp_mock.load.assert_called_once_with('ubuntu/vivid') | ||
376 | 138 | |||
377 | 139 | @patch('cupstream2distro.silomanager.lp') | ||
378 | 140 | def test_silostate_source_archive_other(self, lp_mock): | ||
379 | 141 | """Ensure source_archive property has correct return values.""" | ||
380 | 142 | rtm = Mock() | ||
381 | 143 | lp_mock.distributions = {'ubuntu-rtm': rtm} | ||
382 | 144 | rtm.main_archive.distribution.name = 'ubuntu-rtm' | ||
383 | 145 | self.state._bileto.update(sync_request='ubuntu-rtm,14.09') | ||
384 | 146 | self.assertEqual(self.state.source_archive, rtm.main_archive) | ||
385 | 147 | self.assertEqual(self.state.source_series, lp_mock.load.return_value) | ||
386 | 148 | lp_mock.load.assert_called_once_with('ubuntu-rtm/14.09') | ||
387 | 149 | |||
388 | 150 | @patch('cupstream2distro.silomanager.lp') | ||
389 | 151 | def test_silostate_source_archive_none(self, lp_mock): | ||
390 | 152 | """Ensure source_archive property has correct return values.""" | ||
391 | 153 | self.state._bileto.update(sync_request='') | ||
392 | 154 | self.assertIsNone(self.state.source_archive) | ||
393 | 155 | self.assertIsNone(self.state.source_series) | ||
394 | 156 | |||
395 | 98 | def test_mark_packages_dirty(self): | 157 | def test_mark_packages_dirty(self): |
396 | 99 | """Create dirty package marker files.""" | 158 | """Create dirty package marker files.""" |
397 | 100 | names = ['bleep', 'blorp'] | 159 | names = ['bleep', 'blorp'] |
398 | @@ -250,7 +309,7 @@ | |||
399 | 250 | 309 | ||
400 | 251 | def test_silostate_new_blank(self): | 310 | def test_silostate_new_blank(self): |
401 | 252 | """Create a new SiloState instance for a fresh silo assignment.""" | 311 | """Create a new SiloState instance for a fresh silo assignment.""" |
403 | 253 | methodname = 'cupstream2distro.silomanager.SILO_DIR' | 312 | methodname = 'cupstream2distro.silomanager.join' |
404 | 254 | with patch(methodname, lambda *ignore: self.tempdir + '/request_id'): | 313 | with patch(methodname, lambda *ignore: self.tempdir + '/request_id'): |
405 | 255 | silo_state = SiloState.new_blank( | 314 | silo_state = SiloState.new_blank( |
406 | 256 | siloname='ubuntu/landing-789', | 315 | siloname='ubuntu/landing-789', |
407 | @@ -620,7 +679,7 @@ | |||
408 | 620 | 679 | ||
409 | 621 | def test_silostate_step_setters(self): | 680 | def test_silostate_step_setters(self): |
410 | 622 | """Set various silo steps.""" | 681 | """Set various silo steps.""" |
412 | 623 | func = 'cupstream2distro.silomanager.SILO_DIR' | 682 | func = 'cupstream2distro.silomanager.join' |
413 | 624 | with patch(func, lambda *ingore: self.tempdir + '/step'): | 683 | with patch(func, lambda *ingore: self.tempdir + '/step'): |
414 | 625 | self.state.set_empty() | 684 | self.state.set_empty() |
415 | 626 | self.assertEqual(self.state._config['global']['step'], 0) | 685 | self.assertEqual(self.state._config['global']['step'], 0) |
416 | @@ -686,14 +745,10 @@ | |||
417 | 686 | """Set various state properties.""" | 745 | """Set various state properties.""" |
418 | 687 | self.state.mps = 'flibbyjib' | 746 | self.state.mps = 'flibbyjib' |
419 | 688 | self.assertEqual(self.state._config['mps'], 'flibbyjib') | 747 | self.assertEqual(self.state._config['mps'], 'flibbyjib') |
420 | 689 | self.state.source_archive = 'ubuntu' | ||
421 | 690 | self.assertEqual(self.state._config['source_archive'], 'ubuntu') | ||
422 | 691 | self.state.source_series = 'vivid' | ||
423 | 692 | self.assertEqual(self.state._config['source_series'], 'vivid') | ||
424 | 693 | 748 | ||
425 | 694 | def test_silostate_set_ready(self): | 749 | def test_silostate_set_ready(self): |
426 | 695 | """Set ready to build status.""" | 750 | """Set ready to build status.""" |
428 | 696 | func = 'cupstream2distro.silomanager.SILO_DIR' | 751 | func = 'cupstream2distro.silomanager.join' |
429 | 697 | with patch(func, lambda *ingore: self.tempdir + '/step'): | 752 | with patch(func, lambda *ingore: self.tempdir + '/step'): |
430 | 698 | status_mock = self.state.set_config_status = Mock() | 753 | status_mock = self.state.set_config_status = Mock() |
431 | 699 | self.state.set_ready() | 754 | self.state.set_ready() |
432 | @@ -702,7 +757,7 @@ | |||
433 | 702 | 757 | ||
434 | 703 | def test_silostate_set_reconfigure_failed(self): | 758 | def test_silostate_set_reconfigure_failed(self): |
435 | 704 | """Set reconfigure failed status.""" | 759 | """Set reconfigure failed status.""" |
437 | 705 | func = 'cupstream2distro.silomanager.SILO_DIR' | 760 | func = 'cupstream2distro.silomanager.join' |
438 | 706 | with patch(func, lambda *ingore: self.tempdir + '/step'): | 761 | with patch(func, lambda *ingore: self.tempdir + '/step'): |
439 | 707 | status_mock = self.state.set_config_status = Mock() | 762 | status_mock = self.state.set_config_status = Mock() |
440 | 708 | self.state.set_reconfigure_failed('You did a bad thing.') | 763 | self.state.set_reconfigure_failed('You did a bad thing.') |
441 | @@ -742,7 +797,7 @@ | |||
442 | 742 | silomanager.save_error_message('Whoa, errors galore!') | 797 | silomanager.save_error_message('Whoa, errors galore!') |
443 | 743 | silostate.assert_called_once_with('my/fake/silo') | 798 | silostate.assert_called_once_with('my/fake/silo') |
444 | 744 | silostate().set_config_status.assert_called_once_with( | 799 | silostate().set_config_status.assert_called_once_with( |
446 | 745 | -1, 'Whoa, errors galore!') | 800 | 'Whoa, errors galore!') |
447 | 746 | silostate().save_config.assert_called_once_with() | 801 | silostate().save_config.assert_called_once_with() |
448 | 747 | 802 | ||
449 | 748 | @patch('cupstream2distro.silomanager.SiloState') | 803 | @patch('cupstream2distro.silomanager.SiloState') |
450 | @@ -778,5 +833,5 @@ | |||
451 | 778 | silomanager.cleanup_on_exception(None, Exception('It broke'), None) | 833 | silomanager.cleanup_on_exception(None, Exception('It broke'), None) |
452 | 779 | silostate.assert_called_once_with('ubuntu/landing-negative-one') | 834 | silostate.assert_called_once_with('ubuntu/landing-negative-one') |
453 | 780 | silostate().set_config_status.assert_called_once_with( | 835 | silostate().set_config_status.assert_called_once_with( |
455 | 781 | -1, 'Uncaught exception: Exception: It broke') | 836 | 'Uncaught exception: Exception: It broke') |
456 | 782 | silostate().save_config.assert_called_once_with() | 837 | silostate().save_config.assert_called_once_with() |
PASSED: Continuous integration, rev:1123 jenkins. qa.ubuntu. com/job/ cu2d-choo- choo-ci/ 763/
http://
Executed test runs:
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/cu2d- choo-choo- ci/763/ rebuild
http://