Merge lp:~wgrant/launchpad/bi-uB-no-bfjb into lp:launchpad
- bi-uB-no-bfjb
- Merge into devel
Proposed by
William Grant
Status: | Merged |
---|---|
Approved by: | Steve Kowalik |
Approved revision: | no longer in the source branch. |
Merged at revision: | 16792 |
Proposed branch: | lp:~wgrant/launchpad/bi-uB-no-bfjb |
Merge into: | lp:launchpad |
Diff against target: |
409 lines (+77/-153) 5 files modified
lib/lp/buildmaster/interactor.py (+50/-96) lib/lp/buildmaster/interfaces/builder.py (+0/-8) lib/lp/buildmaster/manager.py (+4/-4) lib/lp/buildmaster/tests/test_interactor.py (+20/-43) lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py (+3/-2) |
To merge this branch: | bzr merge lp:~wgrant/launchpad/bi-uB-no-bfjb |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Steve Kowalik (community) | code | Approve | |
Review via email: mp+188766@code.launchpad.net |
Commit message
BuilderInteract
Description of the change
More BuilderInteractor refactorment. In this episode, updateBuild retrieves the Builder and constructs a BuildFarmJobBeh
To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) : | # |
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/buildmaster/interactor.py' | |||
2 | --- lib/lp/buildmaster/interactor.py 2013-10-01 00:38:38 +0000 | |||
3 | +++ lib/lp/buildmaster/interactor.py 2013-10-02 05:56:53 +0000 | |||
4 | @@ -25,7 +25,6 @@ | |||
5 | 25 | BuildDaemonError, | 25 | BuildDaemonError, |
6 | 26 | CannotFetchFile, | 26 | CannotFetchFile, |
7 | 27 | CannotResumeHost, | 27 | CannotResumeHost, |
8 | 28 | CorruptBuildCookie, | ||
9 | 29 | ) | 28 | ) |
10 | 30 | from lp.buildmaster.interfaces.buildfarmjobbehavior import ( | 29 | from lp.buildmaster.interfaces.buildfarmjobbehavior import ( |
11 | 31 | IBuildFarmJobBehavior, | 30 | IBuildFarmJobBehavior, |
12 | @@ -267,29 +266,15 @@ | |||
13 | 267 | status['logtail'] = status_sentence[2] | 266 | status['logtail'] = status_sentence[2] |
14 | 268 | defer.returnValue((status_sentence, status)) | 267 | defer.returnValue((status_sentence, status)) |
15 | 269 | 268 | ||
16 | 270 | @staticmethod | ||
17 | 271 | def verifySlaveBuildCookie(behavior, slave_cookie): | ||
18 | 272 | """See `IBuildFarmJobBehavior`.""" | ||
19 | 273 | if behavior is None: | ||
20 | 274 | if slave_cookie is not None: | ||
21 | 275 | raise CorruptBuildCookie('Slave building when should be idle.') | ||
22 | 276 | else: | ||
23 | 277 | good_cookie = behavior.getBuildCookie() | ||
24 | 278 | if slave_cookie != good_cookie: | ||
25 | 279 | raise CorruptBuildCookie( | ||
26 | 280 | "Invalid slave build cookie: got %r, expected %r." | ||
27 | 281 | % (slave_cookie, good_cookie)) | ||
28 | 282 | |||
29 | 283 | @classmethod | 269 | @classmethod |
30 | 284 | @defer.inlineCallbacks | 270 | @defer.inlineCallbacks |
32 | 285 | def rescueIfLost(cls, vitals, slave, behavior, logger=None): | 271 | def rescueIfLost(cls, vitals, slave, expected_cookie, logger=None): |
33 | 286 | """Reset the slave if its job information doesn't match the DB. | 272 | """Reset the slave if its job information doesn't match the DB. |
34 | 287 | 273 | ||
40 | 288 | This checks the build ID reported in the slave status against the | 274 | This checks the build ID reported in the slave status against |
41 | 289 | database. If it isn't building what we think it should be, the current | 275 | the given cookie. If it isn't building what we think it should |
42 | 290 | build will be aborted and the slave cleaned in preparation for a new | 276 | be, the current build will be aborted and the slave cleaned in |
43 | 291 | task. The decision about the slave's correctness is left up to | 277 | preparation for a new task. |
39 | 292 | `IBuildFarmJobBehavior.verifySlaveBuildCookie`. | ||
44 | 293 | 278 | ||
45 | 294 | :return: A Deferred that fires when the dialog with the slave is | 279 | :return: A Deferred that fires when the dialog with the slave is |
46 | 295 | finished. Its return value is True if the slave is lost, | 280 | finished. Its return value is True if the slave is lost, |
47 | @@ -315,14 +300,12 @@ | |||
48 | 315 | else: | 300 | else: |
49 | 316 | slave_cookie = status_sentence[ident_position[status]] | 301 | slave_cookie = status_sentence[ident_position[status]] |
50 | 317 | 302 | ||
57 | 318 | # verifySlaveBuildCookie will raise CorruptBuildCookie if the | 303 | if slave_cookie == expected_cookie: |
58 | 319 | # slave cookie doesn't match the expected one, including | 304 | # The master and slave agree about the current job. Continue. |
53 | 320 | # verifying that the slave cookie is None iff we expect the | ||
54 | 321 | # slave to be idle. | ||
55 | 322 | try: | ||
56 | 323 | cls.verifySlaveBuildCookie(behavior, slave_cookie) | ||
59 | 324 | defer.returnValue(False) | 305 | defer.returnValue(False) |
61 | 325 | except CorruptBuildCookie as reason: | 306 | else: |
62 | 307 | # The master and slave disagree. The master is our master, | ||
63 | 308 | # so try to rescue the slave. | ||
64 | 326 | # An IDLE slave doesn't need rescuing (SlaveScanner.scan | 309 | # An IDLE slave doesn't need rescuing (SlaveScanner.scan |
65 | 327 | # will rescue the DB side instead), and we just have to wait | 310 | # will rescue the DB side instead), and we just have to wait |
66 | 328 | # out an ABORTING one. | 311 | # out an ABORTING one. |
67 | @@ -332,8 +315,8 @@ | |||
68 | 332 | yield slave.abort() | 315 | yield slave.abort() |
69 | 333 | if logger: | 316 | if logger: |
70 | 334 | logger.info( | 317 | logger.info( |
73 | 335 | "Builder '%s' rescued from '%s': '%s'" % | 318 | "Builder slave '%s' rescued from %r (expected %r)." % |
74 | 336 | (vitals.name, slave_cookie, reason)) | 319 | (vitals.name, slave_cookie, expected_cookie)) |
75 | 337 | defer.returnValue(True) | 320 | defer.returnValue(True) |
76 | 338 | 321 | ||
77 | 339 | @classmethod | 322 | @classmethod |
78 | @@ -474,9 +457,22 @@ | |||
79 | 474 | candidate, vitals, builder, slave, new_behavior, logger) | 457 | candidate, vitals, builder, slave, new_behavior, logger) |
80 | 475 | defer.returnValue(candidate) | 458 | defer.returnValue(candidate) |
81 | 476 | 459 | ||
82 | 460 | @staticmethod | ||
83 | 461 | def extractBuildStatus(status_dict): | ||
84 | 462 | """Read build status name. | ||
85 | 463 | |||
86 | 464 | :param status_dict: build status dict from slaveStatus. | ||
87 | 465 | :return: the unqualified status name, e.g. "OK". | ||
88 | 466 | """ | ||
89 | 467 | status_string = status_dict['build_status'] | ||
90 | 468 | lead_string = 'BuildStatus.' | ||
91 | 469 | assert status_string.startswith(lead_string), ( | ||
92 | 470 | "Malformed status string: '%s'" % status_string) | ||
93 | 471 | return status_string[len(lead_string):] | ||
94 | 472 | |||
95 | 477 | @classmethod | 473 | @classmethod |
96 | 478 | @defer.inlineCallbacks | 474 | @defer.inlineCallbacks |
98 | 479 | def updateBuild(cls, queueItem, slave, behavior): | 475 | def updateBuild(cls, vitals, slave, builders_cache, behavior_factory): |
99 | 480 | """Verify the current build job status. | 476 | """Verify the current build job status. |
100 | 481 | 477 | ||
101 | 482 | Perform the required actions for each state. | 478 | Perform the required actions for each state. |
102 | @@ -487,76 +483,34 @@ | |||
103 | 487 | # impossible to get past rescueIfLost unless the slave matches | 483 | # impossible to get past rescueIfLost unless the slave matches |
104 | 488 | # the DB, and this method isn't called unless the DB says | 484 | # the DB, and this method isn't called unless the DB says |
105 | 489 | # there's a job. | 485 | # there's a job. |
106 | 490 | builder_status_handlers = { | ||
107 | 491 | 'BuilderStatus.BUILDING': cls.updateBuild_BUILDING, | ||
108 | 492 | 'BuilderStatus.ABORTING': cls.updateBuild_ABORTING, | ||
109 | 493 | 'BuilderStatus.WAITING': cls.updateBuild_WAITING, | ||
110 | 494 | } | ||
111 | 495 | statuses = yield cls.slaveStatus(slave) | 486 | statuses = yield cls.slaveStatus(slave) |
112 | 496 | logger = logging.getLogger('slave-scanner') | ||
113 | 497 | status_sentence, status_dict = statuses | 487 | status_sentence, status_dict = statuses |
114 | 498 | builder_status = status_dict['builder_status'] | 488 | builder_status = status_dict['builder_status'] |
116 | 499 | if builder_status not in builder_status_handlers: | 489 | if builder_status == 'BuilderStatus.BUILDING': |
117 | 490 | # Build still building, collect the logtail. | ||
118 | 491 | if vitals.build_queue.job.status != JobStatus.RUNNING: | ||
119 | 492 | # XXX: This check should be removed once we confirm it's | ||
120 | 493 | # not regularly hit. | ||
121 | 494 | raise AssertionError( | ||
122 | 495 | "Job not running when assigned and slave building.") | ||
123 | 496 | vitals.build_queue.logtail = encoding.guess( | ||
124 | 497 | str(status_dict.get('logtail'))) | ||
125 | 498 | transaction.commit() | ||
126 | 499 | elif builder_status == 'BuilderStatus.ABORTING': | ||
127 | 500 | # Build is being aborted. | ||
128 | 501 | vitals.build_queue.logtail = ( | ||
129 | 502 | "Waiting for slave process to be terminated") | ||
130 | 503 | transaction.commit() | ||
131 | 504 | elif builder_status == 'BuilderStatus.WAITING': | ||
132 | 505 | # Build has finished. Delegate handling to the build itself. | ||
133 | 506 | builder = builders_cache[vitals.name] | ||
134 | 507 | behavior = behavior_factory(vitals.build_queue, builder, slave) | ||
135 | 508 | behavior.updateSlaveStatus(status_sentence, status_dict) | ||
136 | 509 | yield behavior.handleStatus( | ||
137 | 510 | vitals.build_queue, cls.extractBuildStatus(status_dict), | ||
138 | 511 | status_dict) | ||
139 | 512 | else: | ||
140 | 500 | raise AssertionError("Unknown status %s" % builder_status) | 513 | raise AssertionError("Unknown status %s" % builder_status) |
141 | 501 | method = builder_status_handlers[builder_status] | ||
142 | 502 | yield method( | ||
143 | 503 | queueItem, behavior, status_sentence, status_dict, logger) | ||
144 | 504 | |||
145 | 505 | @staticmethod | ||
146 | 506 | def updateBuild_BUILDING(queueItem, behavior, status_sentence, status_dict, | ||
147 | 507 | logger): | ||
148 | 508 | """Build still building, collect the logtail""" | ||
149 | 509 | if queueItem.job.status != JobStatus.RUNNING: | ||
150 | 510 | queueItem.job.start() | ||
151 | 511 | queueItem.logtail = encoding.guess(str(status_dict.get('logtail'))) | ||
152 | 512 | transaction.commit() | ||
153 | 513 | |||
154 | 514 | @staticmethod | ||
155 | 515 | def updateBuild_ABORTING(queueItem, behavior, status_sentence, status_dict, | ||
156 | 516 | logger): | ||
157 | 517 | """Build was ABORTED. | ||
158 | 518 | |||
159 | 519 | Master-side should wait until the slave finish the process correctly. | ||
160 | 520 | """ | ||
161 | 521 | queueItem.logtail = "Waiting for slave process to be terminated" | ||
162 | 522 | transaction.commit() | ||
163 | 523 | |||
164 | 524 | @staticmethod | ||
165 | 525 | def extractBuildStatus(status_dict): | ||
166 | 526 | """Read build status name. | ||
167 | 527 | |||
168 | 528 | :param status_dict: build status dict as passed to the | ||
169 | 529 | updateBuild_* methods. | ||
170 | 530 | :return: the unqualified status name, e.g. "OK". | ||
171 | 531 | """ | ||
172 | 532 | status_string = status_dict['build_status'] | ||
173 | 533 | lead_string = 'BuildStatus.' | ||
174 | 534 | assert status_string.startswith(lead_string), ( | ||
175 | 535 | "Malformed status string: '%s'" % status_string) | ||
176 | 536 | |||
177 | 537 | return status_string[len(lead_string):] | ||
178 | 538 | |||
179 | 539 | @classmethod | ||
180 | 540 | def updateBuild_WAITING(cls, queueItem, behavior, status_sentence, | ||
181 | 541 | status_dict, logger): | ||
182 | 542 | """Perform the actions needed for a slave in a WAITING state | ||
183 | 543 | |||
184 | 544 | Buildslave can be WAITING in five situations: | ||
185 | 545 | |||
186 | 546 | * Build has failed, no filemap is received (PACKAGEFAIL, DEPFAIL, | ||
187 | 547 | CHROOTFAIL, BUILDERFAIL, | ||
188 | 548 | ABORTED) | ||
189 | 549 | |||
190 | 550 | * Build has been built successfully (BuildStatus.OK), in this case | ||
191 | 551 | we have a 'filemap', so we can retrieve those files and store in | ||
192 | 552 | Librarian with getFileFromSlave() and then pass the binaries to | ||
193 | 553 | the uploader for processing. | ||
194 | 554 | """ | ||
195 | 555 | behavior.updateSlaveStatus( | ||
196 | 556 | status_sentence, status_dict) | ||
197 | 557 | d = behavior.handleStatus( | ||
198 | 558 | queueItem, cls.extractBuildStatus(status_dict), status_dict) | ||
199 | 559 | return d | ||
200 | 560 | 514 | ||
201 | 561 | @staticmethod | 515 | @staticmethod |
202 | 562 | def _getSlaveScannerLogger(): | 516 | def _getSlaveScannerLogger(): |
203 | 563 | 517 | ||
204 | === modified file 'lib/lp/buildmaster/interfaces/builder.py' | |||
205 | --- lib/lp/buildmaster/interfaces/builder.py 2013-09-02 08:11:58 +0000 | |||
206 | +++ lib/lp/buildmaster/interfaces/builder.py 2013-10-02 05:56:53 +0000 | |||
207 | @@ -7,7 +7,6 @@ | |||
208 | 7 | 7 | ||
209 | 8 | __all__ = [ | 8 | __all__ = [ |
210 | 9 | 'BuildDaemonError', | 9 | 'BuildDaemonError', |
211 | 10 | 'CorruptBuildCookie', | ||
212 | 11 | 'BuildSlaveFailure', | 10 | 'BuildSlaveFailure', |
213 | 12 | 'CannotBuild', | 11 | 'CannotBuild', |
214 | 13 | 'CannotFetchFile', | 12 | 'CannotFetchFile', |
215 | @@ -71,13 +70,6 @@ | |||
216 | 71 | """The build slave had a protocol version. This is a serious error.""" | 70 | """The build slave had a protocol version. This is a serious error.""" |
217 | 72 | 71 | ||
218 | 73 | 72 | ||
219 | 74 | class CorruptBuildCookie(BuildDaemonError): | ||
220 | 75 | """The build slave is working with mismatched information. | ||
221 | 76 | |||
222 | 77 | It needs to be rescued. | ||
223 | 78 | """ | ||
224 | 79 | |||
225 | 80 | |||
226 | 81 | class CannotResumeHost(BuildDaemonError): | 73 | class CannotResumeHost(BuildDaemonError): |
227 | 82 | """The build slave virtual machine cannot be resumed.""" | 74 | """The build slave virtual machine cannot be resumed.""" |
228 | 83 | 75 | ||
229 | 84 | 76 | ||
230 | === modified file 'lib/lp/buildmaster/manager.py' | |||
231 | --- lib/lp/buildmaster/manager.py 2013-09-30 08:12:17 +0000 | |||
232 | +++ lib/lp/buildmaster/manager.py 2013-10-02 05:56:53 +0000 | |||
233 | @@ -296,8 +296,9 @@ | |||
234 | 296 | return | 296 | return |
235 | 297 | behavior = self.behavior_factory( | 297 | behavior = self.behavior_factory( |
236 | 298 | vitals.build_queue, builder, slave) | 298 | vitals.build_queue, builder, slave) |
237 | 299 | db_cookie = behavior.getBuildCookie() if behavior else None | ||
238 | 299 | lost = yield interactor.rescueIfLost( | 300 | lost = yield interactor.rescueIfLost( |
240 | 300 | vitals, slave, behavior, self.logger) | 301 | vitals, slave, db_cookie, self.logger) |
241 | 301 | if lost: | 302 | if lost: |
242 | 302 | lost_reason = '%s is lost' % vitals.name | 303 | lost_reason = '%s is lost' % vitals.name |
243 | 303 | 304 | ||
244 | @@ -320,9 +321,8 @@ | |||
245 | 320 | if vitals.build_queue is not None: | 321 | if vitals.build_queue is not None: |
246 | 321 | # Scan the slave and get the logtail, or collect the build | 322 | # Scan the slave and get the logtail, or collect the build |
247 | 322 | # if it's ready. Yes, "updateBuild" is a bad name. | 323 | # if it's ready. Yes, "updateBuild" is a bad name. |
251 | 323 | behavior = behavior or self.behavior_factory( | 324 | yield interactor.updateBuild( |
252 | 324 | vitals.build_queue, builder, slave) | 325 | vitals, slave, self.builders_cache, self.behavior_factory) |
250 | 325 | yield interactor.updateBuild(vitals.build_queue, slave, behavior) | ||
253 | 326 | elif vitals.manual: | 326 | elif vitals.manual: |
254 | 327 | # If the builder is in manual mode, don't dispatch anything. | 327 | # If the builder is in manual mode, don't dispatch anything. |
255 | 328 | self.logger.debug( | 328 | self.logger.debug( |
256 | 329 | 329 | ||
257 | === modified file 'lib/lp/buildmaster/tests/test_interactor.py' | |||
258 | --- lib/lp/buildmaster/tests/test_interactor.py 2013-10-01 01:07:35 +0000 | |||
259 | +++ lib/lp/buildmaster/tests/test_interactor.py 2013-10-02 05:56:53 +0000 | |||
260 | @@ -30,7 +30,6 @@ | |||
261 | 30 | from lp.buildmaster.interfaces.builder import ( | 30 | from lp.buildmaster.interfaces.builder import ( |
262 | 31 | CannotFetchFile, | 31 | CannotFetchFile, |
263 | 32 | CannotResumeHost, | 32 | CannotResumeHost, |
264 | 33 | CorruptBuildCookie, | ||
265 | 34 | ) | 33 | ) |
266 | 35 | from lp.buildmaster.tests.mock_slaves import ( | 34 | from lp.buildmaster.tests.mock_slaves import ( |
267 | 36 | AbortingSlave, | 35 | AbortingSlave, |
268 | @@ -40,7 +39,6 @@ | |||
269 | 40 | MockBuilder, | 39 | MockBuilder, |
270 | 41 | OkSlave, | 40 | OkSlave, |
271 | 42 | SlaveTestHelpers, | 41 | SlaveTestHelpers, |
272 | 43 | TrivialBehavior, | ||
273 | 44 | WaitingSlave, | 42 | WaitingSlave, |
274 | 45 | ) | 43 | ) |
275 | 46 | from lp.services.config import config | 44 | from lp.services.config import config |
276 | @@ -78,38 +76,6 @@ | |||
277 | 78 | self.assertRaises( | 76 | self.assertRaises( |
278 | 79 | AssertionError, BuilderInteractor.extractBuildStatus, slave_status) | 77 | AssertionError, BuilderInteractor.extractBuildStatus, slave_status) |
279 | 80 | 78 | ||
280 | 81 | def test_verifySlaveBuildCookie_building_match(self): | ||
281 | 82 | BuilderInteractor.verifySlaveBuildCookie(TrivialBehavior(), 'trivial') | ||
282 | 83 | |||
283 | 84 | def test_verifySlaveBuildCookie_building_mismatch(self): | ||
284 | 85 | self.assertRaises( | ||
285 | 86 | CorruptBuildCookie, | ||
286 | 87 | BuilderInteractor.verifySlaveBuildCookie, | ||
287 | 88 | TrivialBehavior(), 'difficult') | ||
288 | 89 | |||
289 | 90 | def test_verifySlaveBuildCookie_idle_match(self): | ||
290 | 91 | BuilderInteractor.verifySlaveBuildCookie(None, None) | ||
291 | 92 | |||
292 | 93 | def test_verifySlaveBuildCookie_idle_mismatch(self): | ||
293 | 94 | self.assertRaises( | ||
294 | 95 | CorruptBuildCookie, | ||
295 | 96 | BuilderInteractor.verifySlaveBuildCookie, None, 'foo') | ||
296 | 97 | |||
297 | 98 | def test_rescueIfLost_aborts_lost_and_broken_slave(self): | ||
298 | 99 | # A slave that's 'lost' should be aborted; when the slave is | ||
299 | 100 | # broken then abort() should also throw a fault. | ||
300 | 101 | slave = LostBuildingBrokenSlave() | ||
301 | 102 | d = BuilderInteractor.rescueIfLost( | ||
302 | 103 | extract_vitals_from_db(MockBuilder()), slave, TrivialBehavior()) | ||
303 | 104 | |||
304 | 105 | def check_slave_status(failure): | ||
305 | 106 | self.assertIn('abort', slave.call_log) | ||
306 | 107 | # 'Fault' comes from the LostBuildingBrokenSlave, this is | ||
307 | 108 | # just testing that the value is passed through. | ||
308 | 109 | self.assertIsInstance(failure.value, xmlrpclib.Fault) | ||
309 | 110 | |||
310 | 111 | return d.addBoth(check_slave_status) | ||
311 | 112 | |||
312 | 113 | def resumeSlaveHost(self, builder): | 79 | def resumeSlaveHost(self, builder): |
313 | 114 | vitals = extract_vitals_from_db(builder) | 80 | vitals = extract_vitals_from_db(builder) |
314 | 115 | return BuilderInteractor.resumeSlaveHost( | 81 | return BuilderInteractor.resumeSlaveHost( |
315 | @@ -183,6 +149,21 @@ | |||
316 | 183 | slave = BuilderInteractor.makeSlaveFromVitals(vitals) | 149 | slave = BuilderInteractor.makeSlaveFromVitals(vitals) |
317 | 184 | self.assertEqual(5, slave.timeout) | 150 | self.assertEqual(5, slave.timeout) |
318 | 185 | 151 | ||
319 | 152 | def test_rescueIfLost_aborts_lost_and_broken_slave(self): | ||
320 | 153 | # A slave that's 'lost' should be aborted; when the slave is | ||
321 | 154 | # broken then abort() should also throw a fault. | ||
322 | 155 | slave = LostBuildingBrokenSlave() | ||
323 | 156 | d = BuilderInteractor.rescueIfLost( | ||
324 | 157 | extract_vitals_from_db(MockBuilder()), slave, 'trivial') | ||
325 | 158 | |||
326 | 159 | def check_slave_status(failure): | ||
327 | 160 | self.assertIn('abort', slave.call_log) | ||
328 | 161 | # 'Fault' comes from the LostBuildingBrokenSlave, this is | ||
329 | 162 | # just testing that the value is passed through. | ||
330 | 163 | self.assertIsInstance(failure.value, xmlrpclib.Fault) | ||
331 | 164 | |||
332 | 165 | return d.addBoth(check_slave_status) | ||
333 | 166 | |||
334 | 186 | @defer.inlineCallbacks | 167 | @defer.inlineCallbacks |
335 | 187 | def test_recover_idle_slave(self): | 168 | def test_recover_idle_slave(self): |
336 | 188 | # An idle slave is not rescued, even if it's not meant to be | 169 | # An idle slave is not rescued, even if it's not meant to be |
337 | @@ -190,7 +171,7 @@ | |||
338 | 190 | # we still report that it's lost. | 171 | # we still report that it's lost. |
339 | 191 | slave = OkSlave() | 172 | slave = OkSlave() |
340 | 192 | lost = yield BuilderInteractor.rescueIfLost( | 173 | lost = yield BuilderInteractor.rescueIfLost( |
342 | 193 | extract_vitals_from_db(MockBuilder()), slave, TrivialBehavior()) | 174 | extract_vitals_from_db(MockBuilder()), slave, 'trivial') |
343 | 194 | self.assertTrue(lost) | 175 | self.assertTrue(lost) |
344 | 195 | self.assertEqual([], slave.call_log) | 176 | self.assertEqual([], slave.call_log) |
345 | 196 | 177 | ||
346 | @@ -209,8 +190,7 @@ | |||
347 | 209 | # WAITING. | 190 | # WAITING. |
348 | 210 | waiting_slave = WaitingSlave(build_id='trivial') | 191 | waiting_slave = WaitingSlave(build_id='trivial') |
349 | 211 | lost = yield BuilderInteractor.rescueIfLost( | 192 | lost = yield BuilderInteractor.rescueIfLost( |
352 | 212 | extract_vitals_from_db(MockBuilder()), waiting_slave, | 193 | extract_vitals_from_db(MockBuilder()), waiting_slave, 'trivial') |
351 | 213 | TrivialBehavior()) | ||
353 | 214 | self.assertFalse(lost) | 194 | self.assertFalse(lost) |
354 | 215 | self.assertEqual(['status'], waiting_slave.call_log) | 195 | self.assertEqual(['status'], waiting_slave.call_log) |
355 | 216 | 196 | ||
356 | @@ -223,8 +203,7 @@ | |||
357 | 223 | # discarded. | 203 | # discarded. |
358 | 224 | waiting_slave = WaitingSlave(build_id='non-trivial') | 204 | waiting_slave = WaitingSlave(build_id='non-trivial') |
359 | 225 | lost = yield BuilderInteractor.rescueIfLost( | 205 | lost = yield BuilderInteractor.rescueIfLost( |
362 | 226 | extract_vitals_from_db(MockBuilder()), waiting_slave, | 206 | extract_vitals_from_db(MockBuilder()), waiting_slave, 'trivial') |
361 | 227 | TrivialBehavior()) | ||
363 | 228 | self.assertTrue(lost) | 207 | self.assertTrue(lost) |
364 | 229 | self.assertEqual(['status', 'clean'], waiting_slave.call_log) | 208 | self.assertEqual(['status', 'clean'], waiting_slave.call_log) |
365 | 230 | 209 | ||
366 | @@ -234,8 +213,7 @@ | |||
367 | 234 | # BUILDING. | 213 | # BUILDING. |
368 | 235 | building_slave = BuildingSlave(build_id='trivial') | 214 | building_slave = BuildingSlave(build_id='trivial') |
369 | 236 | lost = yield BuilderInteractor.rescueIfLost( | 215 | lost = yield BuilderInteractor.rescueIfLost( |
372 | 237 | extract_vitals_from_db(MockBuilder()), building_slave, | 216 | extract_vitals_from_db(MockBuilder()), building_slave, 'trivial') |
371 | 238 | TrivialBehavior()) | ||
373 | 239 | self.assertFalse(lost) | 217 | self.assertFalse(lost) |
374 | 240 | self.assertEqual(['status'], building_slave.call_log) | 218 | self.assertEqual(['status'], building_slave.call_log) |
375 | 241 | 219 | ||
376 | @@ -245,8 +223,7 @@ | |||
377 | 245 | # abort the build, thus stopping it in its tracks. | 223 | # abort the build, thus stopping it in its tracks. |
378 | 246 | building_slave = BuildingSlave(build_id='non-trivial') | 224 | building_slave = BuildingSlave(build_id='non-trivial') |
379 | 247 | lost = yield BuilderInteractor.rescueIfLost( | 225 | lost = yield BuilderInteractor.rescueIfLost( |
382 | 248 | extract_vitals_from_db(MockBuilder()), building_slave, | 226 | extract_vitals_from_db(MockBuilder()), building_slave, 'trivial') |
381 | 249 | TrivialBehavior()) | ||
383 | 250 | self.assertTrue(lost) | 227 | self.assertTrue(lost) |
384 | 251 | self.assertEqual(['status', 'abort'], building_slave.call_log) | 228 | self.assertEqual(['status', 'abort'], building_slave.call_log) |
385 | 252 | 229 | ||
386 | 253 | 230 | ||
387 | === modified file 'lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py' | |||
388 | --- lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py 2013-09-30 08:12:17 +0000 | |||
389 | +++ lib/lp/soyuz/tests/test_binarypackagebuildbehavior.py 2013-10-02 05:56:53 +0000 | |||
390 | @@ -36,6 +36,7 @@ | |||
391 | 36 | TestGetUploadMethodsMixin, | 36 | TestGetUploadMethodsMixin, |
392 | 37 | TestHandleStatusMixin, | 37 | TestHandleStatusMixin, |
393 | 38 | ) | 38 | ) |
394 | 39 | from lp.buildmaster.tests.test_manager import MockBuildersCache | ||
395 | 39 | from lp.registry.interfaces.pocket import ( | 40 | from lp.registry.interfaces.pocket import ( |
396 | 40 | PackagePublishingPocket, | 41 | PackagePublishingPocket, |
397 | 41 | pocketsuffix, | 42 | pocketsuffix, |
398 | @@ -338,9 +339,9 @@ | |||
399 | 338 | self.addCleanup(self._cleanup) | 339 | self.addCleanup(self._cleanup) |
400 | 339 | 340 | ||
401 | 340 | def updateBuild(self, candidate, slave): | 341 | def updateBuild(self, candidate, slave): |
402 | 342 | bc = MockBuildersCache(self.builder, candidate) | ||
403 | 341 | return self.interactor.updateBuild( | 343 | return self.interactor.updateBuild( |
406 | 342 | candidate, slave, | 344 | bc.getVitals('foo'), slave, bc, self.interactor.getBuildBehavior) |
405 | 343 | self.interactor.getBuildBehavior(candidate, self.builder, slave)) | ||
407 | 344 | 345 | ||
408 | 345 | def assertBuildProperties(self, build): | 346 | def assertBuildProperties(self, build): |
409 | 346 | """Check that a build happened by making sure some of its properties | 347 | """Check that a build happened by making sure some of its properties |