Merge ~cjwatson/launchpad:rename-builder-interactor-slave into launchpad:master
- Git
- lp:~cjwatson/launchpad
- rename-builder-interactor-slave
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 49163ad5cdf93c027e62fd51dea09bdf52ef6d12 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:rename-builder-interactor-slave |
Merge into: | launchpad:master |
Prerequisite: | ~cjwatson/launchpad:rename-bfj-behaviour-slave |
Diff against target: |
392 lines (+65/-65) 4 files modified
lib/lp/buildmaster/interactor.py (+32/-32) lib/lp/buildmaster/manager.py (+3/-3) lib/lp/buildmaster/tests/test_interactor.py (+29/-29) lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py (+1/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+414045@code.launchpad.net |
Commit message
Rename "slave" in BuilderInteractor to "worker"
Description of the change
To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py | |||
2 | index 3aaae63..e8a1d7f 100644 | |||
3 | --- a/lib/lp/buildmaster/interactor.py | |||
4 | +++ b/lib/lp/buildmaster/interactor.py | |||
5 | @@ -345,7 +345,7 @@ def extract_vitals_from_db(builder, build_queue=_BQ_UNSPECIFIED): | |||
6 | 345 | class BuilderInteractor: | 345 | class BuilderInteractor: |
7 | 346 | 346 | ||
8 | 347 | @staticmethod | 347 | @staticmethod |
10 | 348 | def makeSlaveFromVitals(vitals): | 348 | def makeWorkerFromVitals(vitals): |
11 | 349 | if vitals.virtualized: | 349 | if vitals.virtualized: |
12 | 350 | timeout = config.builddmaster.virtualized_socket_timeout | 350 | timeout = config.builddmaster.virtualized_socket_timeout |
13 | 351 | else: | 351 | else: |
14 | @@ -354,19 +354,19 @@ class BuilderInteractor: | |||
15 | 354 | vitals.url, vitals.vm_host, timeout) | 354 | vitals.url, vitals.vm_host, timeout) |
16 | 355 | 355 | ||
17 | 356 | @staticmethod | 356 | @staticmethod |
19 | 357 | def getBuildBehaviour(queue_item, builder, slave): | 357 | def getBuildBehaviour(queue_item, builder, worker): |
20 | 358 | if queue_item is None: | 358 | if queue_item is None: |
21 | 359 | return None | 359 | return None |
22 | 360 | behaviour = IBuildFarmJobBehaviour(queue_item.specific_build) | 360 | behaviour = IBuildFarmJobBehaviour(queue_item.specific_build) |
24 | 361 | behaviour.setBuilder(builder, slave) | 361 | behaviour.setBuilder(builder, worker) |
25 | 362 | return behaviour | 362 | return behaviour |
26 | 363 | 363 | ||
27 | 364 | @classmethod | 364 | @classmethod |
30 | 365 | def resumeSlaveHost(cls, vitals, slave): | 365 | def resumeWorkerHost(cls, vitals, worker): |
31 | 366 | """Resume the slave host to a known good condition. | 366 | """Resume the worker host to a known good condition. |
32 | 367 | 367 | ||
33 | 368 | Issues 'builddmaster.vm_resume_command' specified in the configuration | 368 | Issues 'builddmaster.vm_resume_command' specified in the configuration |
35 | 369 | to resume the slave. | 369 | to resume the worker. |
36 | 370 | 370 | ||
37 | 371 | :raises: CannotResumeHost: if builder is not virtual or if the | 371 | :raises: CannotResumeHost: if builder is not virtual or if the |
38 | 372 | configuration command has failed. | 372 | configuration command has failed. |
39 | @@ -384,7 +384,7 @@ class BuilderInteractor: | |||
40 | 384 | logger = cls._getWorkerScannerLogger() | 384 | logger = cls._getWorkerScannerLogger() |
41 | 385 | logger.info("Resuming %s (%s)" % (vitals.name, vitals.url)) | 385 | logger.info("Resuming %s (%s)" % (vitals.name, vitals.url)) |
42 | 386 | 386 | ||
44 | 387 | d = slave.resume() | 387 | d = worker.resume() |
45 | 388 | 388 | ||
46 | 389 | def got_resume_ok(args): | 389 | def got_resume_ok(args): |
47 | 390 | stdout, stderr, returncode = args | 390 | stdout, stderr, returncode = args |
48 | @@ -400,38 +400,38 @@ class BuilderInteractor: | |||
49 | 400 | 400 | ||
50 | 401 | @classmethod | 401 | @classmethod |
51 | 402 | @defer.inlineCallbacks | 402 | @defer.inlineCallbacks |
54 | 403 | def cleanSlave(cls, vitals, slave, builder_factory): | 403 | def cleanWorker(cls, vitals, worker, builder_factory): |
55 | 404 | """Prepare a slave for a new build. | 404 | """Prepare a worker for a new build. |
56 | 405 | 405 | ||
57 | 406 | :return: A Deferred that fires when this stage of the resume | 406 | :return: A Deferred that fires when this stage of the resume |
59 | 407 | operations finishes. If the value is True, the slave is now clean. | 407 | operations finishes. If the value is True, the worker is now clean. |
60 | 408 | If it's False, the clean is still in progress and this must be | 408 | If it's False, the clean is still in progress and this must be |
61 | 409 | called again later. | 409 | called again later. |
62 | 410 | """ | 410 | """ |
63 | 411 | if vitals.virtualized: | 411 | if vitals.virtualized: |
64 | 412 | if vitals.vm_reset_protocol == BuilderResetProtocol.PROTO_1_1: | 412 | if vitals.vm_reset_protocol == BuilderResetProtocol.PROTO_1_1: |
65 | 413 | # In protocol 1.1 the reset trigger is synchronous, so | 413 | # In protocol 1.1 the reset trigger is synchronous, so |
67 | 414 | # once resumeSlaveHost returns the slave should be | 414 | # once resumeWorkerHost returns the worker should be |
68 | 415 | # running. | 415 | # running. |
69 | 416 | builder_factory[vitals.name].setCleanStatus( | 416 | builder_factory[vitals.name].setCleanStatus( |
70 | 417 | BuilderCleanStatus.CLEANING) | 417 | BuilderCleanStatus.CLEANING) |
71 | 418 | transaction.commit() | 418 | transaction.commit() |
74 | 419 | yield cls.resumeSlaveHost(vitals, slave) | 419 | yield cls.resumeWorkerHost(vitals, worker) |
75 | 420 | # We ping the resumed slave before we try to do anything | 420 | # We ping the resumed worker before we try to do anything |
76 | 421 | # useful with it. This is to ensure it's accepting | 421 | # useful with it. This is to ensure it's accepting |
77 | 422 | # packets from the outside world, because testing has | 422 | # packets from the outside world, because testing has |
78 | 423 | # shown that the first packet will randomly fail for no | 423 | # shown that the first packet will randomly fail for no |
79 | 424 | # apparent reason. This could be a quirk of the Xen | 424 | # apparent reason. This could be a quirk of the Xen |
80 | 425 | # guest, we're not sure. See bug 586359. | 425 | # guest, we're not sure. See bug 586359. |
82 | 426 | yield slave.echo("ping") | 426 | yield worker.echo("ping") |
83 | 427 | return True | 427 | return True |
84 | 428 | elif vitals.vm_reset_protocol == BuilderResetProtocol.PROTO_2_0: | 428 | elif vitals.vm_reset_protocol == BuilderResetProtocol.PROTO_2_0: |
85 | 429 | # In protocol 2.0 the reset trigger is asynchronous. | 429 | # In protocol 2.0 the reset trigger is asynchronous. |
88 | 430 | # If the trigger succeeds we'll leave the slave in | 430 | # If the trigger succeeds we'll leave the worker in |
89 | 431 | # CLEANING, and the non-LP slave management code will | 431 | # CLEANING, and the non-LP worker management code will |
90 | 432 | # set it back to CLEAN later using the webservice. | 432 | # set it back to CLEAN later using the webservice. |
91 | 433 | if vitals.clean_status == BuilderCleanStatus.DIRTY: | 433 | if vitals.clean_status == BuilderCleanStatus.DIRTY: |
93 | 434 | yield cls.resumeSlaveHost(vitals, slave) | 434 | yield cls.resumeWorkerHost(vitals, worker) |
94 | 435 | builder_factory[vitals.name].setCleanStatus( | 435 | builder_factory[vitals.name].setCleanStatus( |
95 | 436 | BuilderCleanStatus.CLEANING) | 436 | BuilderCleanStatus.CLEANING) |
96 | 437 | transaction.commit() | 437 | transaction.commit() |
97 | @@ -441,28 +441,28 @@ class BuilderInteractor: | |||
98 | 441 | raise CannotResumeHost( | 441 | raise CannotResumeHost( |
99 | 442 | "Invalid vm_reset_protocol: %r" % vitals.vm_reset_protocol) | 442 | "Invalid vm_reset_protocol: %r" % vitals.vm_reset_protocol) |
100 | 443 | else: | 443 | else: |
102 | 444 | worker_status = yield slave.status() | 444 | worker_status = yield worker.status() |
103 | 445 | status = worker_status.get('builder_status', None) | 445 | status = worker_status.get('builder_status', None) |
104 | 446 | if status == 'BuilderStatus.IDLE': | 446 | if status == 'BuilderStatus.IDLE': |
105 | 447 | # This is as clean as we can get it. | 447 | # This is as clean as we can get it. |
106 | 448 | return True | 448 | return True |
107 | 449 | elif status == 'BuilderStatus.BUILDING': | 449 | elif status == 'BuilderStatus.BUILDING': |
110 | 450 | # Asynchronously abort() the slave and wait until WAITING. | 450 | # Asynchronously abort() the worker and wait until WAITING. |
111 | 451 | yield slave.abort() | 451 | yield worker.abort() |
112 | 452 | return False | 452 | return False |
113 | 453 | elif status == 'BuilderStatus.ABORTING': | 453 | elif status == 'BuilderStatus.ABORTING': |
114 | 454 | # Wait it out until WAITING. | 454 | # Wait it out until WAITING. |
115 | 455 | return False | 455 | return False |
116 | 456 | elif status == 'BuilderStatus.WAITING': | 456 | elif status == 'BuilderStatus.WAITING': |
117 | 457 | # Just a synchronous clean() call and we'll be idle. | 457 | # Just a synchronous clean() call and we'll be idle. |
119 | 458 | yield slave.clean() | 458 | yield worker.clean() |
120 | 459 | return True | 459 | return True |
121 | 460 | raise BuildDaemonError( | 460 | raise BuildDaemonError( |
122 | 461 | "Invalid status during clean: %r" % status) | 461 | "Invalid status during clean: %r" % status) |
123 | 462 | 462 | ||
124 | 463 | @classmethod | 463 | @classmethod |
125 | 464 | @defer.inlineCallbacks | 464 | @defer.inlineCallbacks |
127 | 465 | def _startBuild(cls, build_queue_item, vitals, builder, slave, behaviour, | 465 | def _startBuild(cls, build_queue_item, vitals, builder, worker, behaviour, |
128 | 466 | logger): | 466 | logger): |
129 | 467 | """Start a build on this builder. | 467 | """Start a build on this builder. |
130 | 468 | 468 | ||
131 | @@ -482,7 +482,7 @@ class BuilderInteractor: | |||
132 | 482 | 482 | ||
133 | 483 | if builder.clean_status != BuilderCleanStatus.CLEAN: | 483 | if builder.clean_status != BuilderCleanStatus.CLEAN: |
134 | 484 | raise BuildDaemonIsolationError( | 484 | raise BuildDaemonIsolationError( |
136 | 485 | "Attempted to start build on a dirty slave.") | 485 | "Attempted to start build on a dirty worker.") |
137 | 486 | 486 | ||
138 | 487 | builder.setCleanStatus(BuilderCleanStatus.DIRTY) | 487 | builder.setCleanStatus(BuilderCleanStatus.DIRTY) |
139 | 488 | transaction.commit() | 488 | transaction.commit() |
140 | @@ -491,8 +491,8 @@ class BuilderInteractor: | |||
141 | 491 | 491 | ||
142 | 492 | @classmethod | 492 | @classmethod |
143 | 493 | @defer.inlineCallbacks | 493 | @defer.inlineCallbacks |
146 | 494 | def findAndStartJob(cls, vitals, builder, slave, builder_factory): | 494 | def findAndStartJob(cls, vitals, builder, worker, builder_factory): |
147 | 495 | """Find a job to run and send it to the buildd slave. | 495 | """Find a job to run and send it to the buildd worker. |
148 | 496 | 496 | ||
149 | 497 | :return: A Deferred whose value is the `IBuildQueue` instance | 497 | :return: A Deferred whose value is the `IBuildQueue` instance |
150 | 498 | found or None if no job was found. | 498 | found or None if no job was found. |
151 | @@ -514,7 +514,7 @@ class BuilderInteractor: | |||
152 | 514 | logger.debug("No build candidates available for builder.") | 514 | logger.debug("No build candidates available for builder.") |
153 | 515 | return None | 515 | return None |
154 | 516 | 516 | ||
156 | 517 | new_behaviour = cls.getBuildBehaviour(candidate, builder, slave) | 517 | new_behaviour = cls.getBuildBehaviour(candidate, builder, worker) |
157 | 518 | needed_bfjb = type(removeSecurityProxy( | 518 | needed_bfjb = type(removeSecurityProxy( |
158 | 519 | IBuildFarmJobBehaviour(candidate.specific_build))) | 519 | IBuildFarmJobBehaviour(candidate.specific_build))) |
159 | 520 | if not zope_isinstance(new_behaviour, needed_bfjb): | 520 | if not zope_isinstance(new_behaviour, needed_bfjb): |
160 | @@ -522,7 +522,7 @@ class BuilderInteractor: | |||
161 | 522 | "Inappropriate IBuildFarmJobBehaviour: %r is not a %r" % | 522 | "Inappropriate IBuildFarmJobBehaviour: %r is not a %r" % |
162 | 523 | (new_behaviour, needed_bfjb)) | 523 | (new_behaviour, needed_bfjb)) |
163 | 524 | yield cls._startBuild( | 524 | yield cls._startBuild( |
165 | 525 | candidate, vitals, builder, slave, new_behaviour, logger) | 525 | candidate, vitals, builder, worker, new_behaviour, logger) |
166 | 526 | return candidate | 526 | return candidate |
167 | 527 | 527 | ||
168 | 528 | @staticmethod | 528 | @staticmethod |
169 | @@ -549,7 +549,7 @@ class BuilderInteractor: | |||
170 | 549 | """ | 549 | """ |
171 | 550 | builder_status = worker_status["builder_status"] | 550 | builder_status = worker_status["builder_status"] |
172 | 551 | if builder_status == "BuilderStatus.ABORTING": | 551 | if builder_status == "BuilderStatus.ABORTING": |
174 | 552 | logtail = "Waiting for slave process to be terminated" | 552 | logtail = "Waiting for worker process to be terminated" |
175 | 553 | elif worker_status.get("logtail") is not None: | 553 | elif worker_status.get("logtail") is not None: |
176 | 554 | # worker_status["logtail"] is an xmlrpc.client.Binary instance, | 554 | # worker_status["logtail"] is an xmlrpc.client.Binary instance, |
177 | 555 | # and the contents might include invalid UTF-8 due to being a | 555 | # and the contents might include invalid UTF-8 due to being a |
178 | @@ -567,16 +567,16 @@ class BuilderInteractor: | |||
179 | 567 | 567 | ||
180 | 568 | @classmethod | 568 | @classmethod |
181 | 569 | @defer.inlineCallbacks | 569 | @defer.inlineCallbacks |
183 | 570 | def updateBuild(cls, vitals, slave, worker_status, builder_factory, | 570 | def updateBuild(cls, vitals, worker, worker_status, builder_factory, |
184 | 571 | behaviour_factory, manager): | 571 | behaviour_factory, manager): |
185 | 572 | """Verify the current build job status. | 572 | """Verify the current build job status. |
186 | 573 | 573 | ||
187 | 574 | Perform the required actions for each state. | 574 | Perform the required actions for each state. |
188 | 575 | 575 | ||
190 | 576 | :return: A Deferred that fires when the slave dialog is finished. | 576 | :return: A Deferred that fires when the worker dialog is finished. |
191 | 577 | """ | 577 | """ |
192 | 578 | # IDLE is deliberately not handled here, because it should be | 578 | # IDLE is deliberately not handled here, because it should be |
194 | 579 | # impossible to get past the cookie check unless the slave | 579 | # impossible to get past the cookie check unless the worker |
195 | 580 | # matches the DB, and this method isn't called unless the DB | 580 | # matches the DB, and this method isn't called unless the DB |
196 | 581 | # says there's a job. | 581 | # says there's a job. |
197 | 582 | builder_status = worker_status['builder_status'] | 582 | builder_status = worker_status['builder_status'] |
198 | @@ -592,7 +592,7 @@ class BuilderInteractor: | |||
199 | 592 | elif builder_status == 'BuilderStatus.WAITING': | 592 | elif builder_status == 'BuilderStatus.WAITING': |
200 | 593 | # Build has finished. Delegate handling to the build itself. | 593 | # Build has finished. Delegate handling to the build itself. |
201 | 594 | builder = builder_factory[vitals.name] | 594 | builder = builder_factory[vitals.name] |
203 | 595 | behaviour = behaviour_factory(vitals.build_queue, builder, slave) | 595 | behaviour = behaviour_factory(vitals.build_queue, builder, worker) |
204 | 596 | yield behaviour.handleStatus( | 596 | yield behaviour.handleStatus( |
205 | 597 | vitals.build_queue, cls.extractBuildStatus(worker_status), | 597 | vitals.build_queue, cls.extractBuildStatus(worker_status), |
206 | 598 | worker_status) | 598 | worker_status) |
207 | diff --git a/lib/lp/buildmaster/manager.py b/lib/lp/buildmaster/manager.py | |||
208 | index ba9c3f1..850b83b 100644 | |||
209 | --- a/lib/lp/buildmaster/manager.py | |||
210 | +++ b/lib/lp/buildmaster/manager.py | |||
211 | @@ -431,7 +431,7 @@ class WorkerScanner: | |||
212 | 431 | 431 | ||
213 | 432 | def __init__(self, builder_name, builder_factory, manager, logger, | 432 | def __init__(self, builder_name, builder_factory, manager, logger, |
214 | 433 | clock=None, interactor_factory=BuilderInteractor, | 433 | clock=None, interactor_factory=BuilderInteractor, |
216 | 434 | worker_factory=BuilderInteractor.makeSlaveFromVitals, | 434 | worker_factory=BuilderInteractor.makeWorkerFromVitals, |
217 | 435 | behaviour_factory=BuilderInteractor.getBuildBehaviour): | 435 | behaviour_factory=BuilderInteractor.getBuildBehaviour): |
218 | 436 | self.builder_name = builder_name | 436 | self.builder_name = builder_name |
219 | 437 | self.builder_factory = builder_factory | 437 | self.builder_factory = builder_factory |
220 | @@ -681,11 +681,11 @@ class WorkerScanner: | |||
221 | 681 | builder.resetFailureCount() | 681 | builder.resetFailureCount() |
222 | 682 | transaction.commit() | 682 | transaction.commit() |
223 | 683 | else: | 683 | else: |
225 | 684 | # Ask the BuilderInteractor to clean the slave. It might | 684 | # Ask the BuilderInteractor to clean the worker. It might |
226 | 685 | # be immediately cleaned on return, in which case we go | 685 | # be immediately cleaned on return, in which case we go |
227 | 686 | # straight back to CLEAN, or we might have to spin | 686 | # straight back to CLEAN, or we might have to spin |
228 | 687 | # through another few cycles. | 687 | # through another few cycles. |
230 | 688 | done = yield interactor.cleanSlave( | 688 | done = yield interactor.cleanWorker( |
231 | 689 | vitals, slave, self.builder_factory) | 689 | vitals, slave, self.builder_factory) |
232 | 690 | if done: | 690 | if done: |
233 | 691 | builder = self.builder_factory[self.builder_name] | 691 | builder = self.builder_factory[self.builder_name] |
234 | diff --git a/lib/lp/buildmaster/tests/test_interactor.py b/lib/lp/buildmaster/tests/test_interactor.py | |||
235 | index fc102be..6e4a790 100644 | |||
236 | --- a/lib/lp/buildmaster/tests/test_interactor.py | |||
237 | +++ b/lib/lp/buildmaster/tests/test_interactor.py | |||
238 | @@ -123,7 +123,7 @@ class TestBuilderInteractor(TestCase): | |||
239 | 123 | 123 | ||
240 | 124 | def test_extractBuildStatus_baseline(self): | 124 | def test_extractBuildStatus_baseline(self): |
241 | 125 | # extractBuildStatus picks the name of the build status out of a | 125 | # extractBuildStatus picks the name of the build status out of a |
243 | 126 | # dict describing the slave's status. | 126 | # dict describing the worker's status. |
244 | 127 | worker_status = {'build_status': 'BuildStatus.BUILDING'} | 127 | worker_status = {'build_status': 'BuildStatus.BUILDING'} |
245 | 128 | self.assertEqual( | 128 | self.assertEqual( |
246 | 129 | 'BUILDING', BuilderInteractor.extractBuildStatus(worker_status)) | 129 | 'BUILDING', BuilderInteractor.extractBuildStatus(worker_status)) |
247 | @@ -136,20 +136,20 @@ class TestBuilderInteractor(TestCase): | |||
248 | 136 | AssertionError, BuilderInteractor.extractBuildStatus, | 136 | AssertionError, BuilderInteractor.extractBuildStatus, |
249 | 137 | worker_status) | 137 | worker_status) |
250 | 138 | 138 | ||
252 | 139 | def resumeSlaveHost(self, builder): | 139 | def resumeWorkerHost(self, builder): |
253 | 140 | vitals = extract_vitals_from_db(builder) | 140 | vitals = extract_vitals_from_db(builder) |
256 | 141 | return BuilderInteractor.resumeSlaveHost( | 141 | return BuilderInteractor.resumeWorkerHost( |
257 | 142 | vitals, BuilderInteractor.makeSlaveFromVitals(vitals)) | 142 | vitals, BuilderInteractor.makeWorkerFromVitals(vitals)) |
258 | 143 | 143 | ||
261 | 144 | def test_resumeSlaveHost_nonvirtual(self): | 144 | def test_resumeWorkerHost_nonvirtual(self): |
262 | 145 | d = self.resumeSlaveHost(MockBuilder(virtualized=False)) | 145 | d = self.resumeWorkerHost(MockBuilder(virtualized=False)) |
263 | 146 | return assert_fails_with(d, CannotResumeHost) | 146 | return assert_fails_with(d, CannotResumeHost) |
264 | 147 | 147 | ||
267 | 148 | def test_resumeSlaveHost_no_vmhost(self): | 148 | def test_resumeWorkerHost_no_vmhost(self): |
268 | 149 | d = self.resumeSlaveHost(MockBuilder(virtualized=False, vm_host=None)) | 149 | d = self.resumeWorkerHost(MockBuilder(virtualized=False, vm_host=None)) |
269 | 150 | return assert_fails_with(d, CannotResumeHost) | 150 | return assert_fails_with(d, CannotResumeHost) |
270 | 151 | 151 | ||
272 | 152 | def test_resumeSlaveHost_success(self): | 152 | def test_resumeWorkerHost_success(self): |
273 | 153 | reset_config = """ | 153 | reset_config = """ |
274 | 154 | [builddmaster] | 154 | [builddmaster] |
275 | 155 | vm_resume_command: /bin/echo -n snap %(buildd_name)s %(vm_host)s | 155 | vm_resume_command: /bin/echo -n snap %(buildd_name)s %(vm_host)s |
276 | @@ -157,45 +157,45 @@ class TestBuilderInteractor(TestCase): | |||
277 | 157 | config.push('reset', reset_config) | 157 | config.push('reset', reset_config) |
278 | 158 | self.addCleanup(config.pop, 'reset') | 158 | self.addCleanup(config.pop, 'reset') |
279 | 159 | 159 | ||
281 | 160 | d = self.resumeSlaveHost(MockBuilder( | 160 | d = self.resumeWorkerHost(MockBuilder( |
282 | 161 | url="http://crackle.ppa/", virtualized=True, vm_host="pop")) | 161 | url="http://crackle.ppa/", virtualized=True, vm_host="pop")) |
283 | 162 | 162 | ||
284 | 163 | def got_resume(output): | 163 | def got_resume(output): |
285 | 164 | self.assertEqual((b'snap crackle pop', b''), output) | 164 | self.assertEqual((b'snap crackle pop', b''), output) |
286 | 165 | return d.addCallback(got_resume) | 165 | return d.addCallback(got_resume) |
287 | 166 | 166 | ||
289 | 167 | def test_resumeSlaveHost_command_failed(self): | 167 | def test_resumeWorkerHost_command_failed(self): |
290 | 168 | reset_fail_config = """ | 168 | reset_fail_config = """ |
291 | 169 | [builddmaster] | 169 | [builddmaster] |
292 | 170 | vm_resume_command: /bin/false""" | 170 | vm_resume_command: /bin/false""" |
293 | 171 | config.push('reset fail', reset_fail_config) | 171 | config.push('reset fail', reset_fail_config) |
294 | 172 | self.addCleanup(config.pop, 'reset fail') | 172 | self.addCleanup(config.pop, 'reset fail') |
296 | 173 | d = self.resumeSlaveHost(MockBuilder(virtualized=True, vm_host="pop")) | 173 | d = self.resumeWorkerHost(MockBuilder(virtualized=True, vm_host="pop")) |
297 | 174 | return assert_fails_with(d, CannotResumeHost) | 174 | return assert_fails_with(d, CannotResumeHost) |
298 | 175 | 175 | ||
303 | 176 | def test_makeSlaveFromVitals(self): | 176 | def test_makeWorkerFromVitals(self): |
304 | 177 | # Builder.slave is a BuilderWorker that points at the actual Builder. | 177 | # BuilderInteractor.makeWorkerFromVitals returns a BuilderWorker |
305 | 178 | # The Builder is only ever used in scripts that run outside of the | 178 | # that points at the actual Builder. The Builder is only ever used |
306 | 179 | # security context. | 179 | # in scripts that run outside of the security context. |
307 | 180 | builder = MockBuilder(virtualized=False) | 180 | builder = MockBuilder(virtualized=False) |
308 | 181 | vitals = extract_vitals_from_db(builder) | 181 | vitals = extract_vitals_from_db(builder) |
312 | 182 | slave = BuilderInteractor.makeSlaveFromVitals(vitals) | 182 | worker = BuilderInteractor.makeWorkerFromVitals(vitals) |
313 | 183 | self.assertEqual(builder.url, slave.url) | 183 | self.assertEqual(builder.url, worker.url) |
314 | 184 | self.assertEqual(10, slave.timeout) | 184 | self.assertEqual(10, worker.timeout) |
315 | 185 | 185 | ||
316 | 186 | builder = MockBuilder(virtualized=True) | 186 | builder = MockBuilder(virtualized=True) |
317 | 187 | vitals = extract_vitals_from_db(builder) | 187 | vitals = extract_vitals_from_db(builder) |
320 | 188 | slave = BuilderInteractor.makeSlaveFromVitals(vitals) | 188 | worker = BuilderInteractor.makeWorkerFromVitals(vitals) |
321 | 189 | self.assertEqual(5, slave.timeout) | 189 | self.assertEqual(5, worker.timeout) |
322 | 190 | 190 | ||
323 | 191 | 191 | ||
325 | 192 | class TestBuilderInteractorCleanSlave(TestCase): | 192 | class TestBuilderInteractorCleanWorker(TestCase): |
326 | 193 | 193 | ||
327 | 194 | run_tests_with = AsynchronousDeferredRunTest | 194 | run_tests_with = AsynchronousDeferredRunTest |
328 | 195 | 195 | ||
329 | 196 | @defer.inlineCallbacks | 196 | @defer.inlineCallbacks |
330 | 197 | def assertCleanCalls(self, builder, worker, calls, done): | 197 | def assertCleanCalls(self, builder, worker, calls, done): |
332 | 198 | actually_done = yield BuilderInteractor.cleanSlave( | 198 | actually_done = yield BuilderInteractor.cleanWorker( |
333 | 199 | extract_vitals_from_db(builder), worker, | 199 | extract_vitals_from_db(builder), worker, |
334 | 200 | MockBuilderFactory(builder, None)) | 200 | MockBuilderFactory(builder, None)) |
335 | 201 | self.assertEqual(done, actually_done) | 201 | self.assertEqual(done, actually_done) |
336 | @@ -243,7 +243,7 @@ class TestBuilderInteractorCleanSlave(TestCase): | |||
337 | 243 | builder.vm_reset_protocol = None | 243 | builder.vm_reset_protocol = None |
338 | 244 | with ExpectedException( | 244 | with ExpectedException( |
339 | 245 | CannotResumeHost, "Invalid vm_reset_protocol: None"): | 245 | CannotResumeHost, "Invalid vm_reset_protocol: None"): |
341 | 246 | yield BuilderInteractor.cleanSlave( | 246 | yield BuilderInteractor.cleanWorker( |
342 | 247 | extract_vitals_from_db(builder), OkWorker(), | 247 | extract_vitals_from_db(builder), OkWorker(), |
343 | 248 | MockBuilderFactory(builder, None)) | 248 | MockBuilderFactory(builder, None)) |
344 | 249 | 249 | ||
345 | @@ -290,7 +290,7 @@ class TestBuilderInteractorCleanSlave(TestCase): | |||
346 | 290 | vitals = extract_vitals_from_db(builder) | 290 | vitals = extract_vitals_from_db(builder) |
347 | 291 | worker = LostBuildingBrokenWorker() | 291 | worker = LostBuildingBrokenWorker() |
348 | 292 | try: | 292 | try: |
350 | 293 | yield BuilderInteractor.cleanSlave( | 293 | yield BuilderInteractor.cleanWorker( |
351 | 294 | vitals, worker, MockBuilderFactory(builder, None)) | 294 | vitals, worker, MockBuilderFactory(builder, None)) |
352 | 295 | except xmlrpc.client.Fault: | 295 | except xmlrpc.client.Fault: |
353 | 296 | self.assertEqual(['status', 'abort'], worker.call_log) | 296 | self.assertEqual(['status', 'abort'], worker.call_log) |
354 | @@ -470,8 +470,8 @@ class TestBuilderInteractorDB(TestCaseWithFactory): | |||
355 | 470 | return d.addCallback(check_build_started) | 470 | return d.addCallback(check_build_started) |
356 | 471 | 471 | ||
357 | 472 | @defer.inlineCallbacks | 472 | @defer.inlineCallbacks |
360 | 473 | def test_findAndStartJob_requires_clean_slave(self): | 473 | def test_findAndStartJob_requires_clean_worker(self): |
361 | 474 | # findAndStartJob ensures that its slave starts CLEAN. | 474 | # findAndStartJob ensures that its worker starts CLEAN. |
362 | 475 | builder, build = self._setupBinaryBuildAndBuilder() | 475 | builder, build = self._setupBinaryBuildAndBuilder() |
363 | 476 | builder.setCleanStatus(BuilderCleanStatus.DIRTY) | 476 | builder.setCleanStatus(BuilderCleanStatus.DIRTY) |
364 | 477 | candidate = build.queueBuild() | 477 | candidate = build.queueBuild() |
365 | @@ -480,12 +480,12 @@ class TestBuilderInteractorDB(TestCaseWithFactory): | |||
366 | 480 | vitals = extract_vitals_from_db(builder) | 480 | vitals = extract_vitals_from_db(builder) |
367 | 481 | with ExpectedException( | 481 | with ExpectedException( |
368 | 482 | BuildDaemonIsolationError, | 482 | BuildDaemonIsolationError, |
370 | 483 | "Attempted to start build on a dirty slave."): | 483 | "Attempted to start build on a dirty worker."): |
371 | 484 | yield BuilderInteractor.findAndStartJob( | 484 | yield BuilderInteractor.findAndStartJob( |
372 | 485 | vitals, builder, OkWorker(), builder_factory) | 485 | vitals, builder, OkWorker(), builder_factory) |
373 | 486 | 486 | ||
374 | 487 | @defer.inlineCallbacks | 487 | @defer.inlineCallbacks |
376 | 488 | def test_findAndStartJob_dirties_slave(self): | 488 | def test_findAndStartJob_dirties_worker(self): |
377 | 489 | # findAndStartJob marks its builder DIRTY before dispatching. | 489 | # findAndStartJob marks its builder DIRTY before dispatching. |
378 | 490 | builder, build = self._setupBinaryBuildAndBuilder() | 490 | builder, build = self._setupBinaryBuildAndBuilder() |
379 | 491 | candidate = build.queueBuild() | 491 | candidate = build.queueBuild() |
380 | diff --git a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py | |||
381 | index 89f8474..73bff8d 100644 | |||
382 | --- a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py | |||
383 | +++ b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py | |||
384 | @@ -615,7 +615,7 @@ class TestBinaryBuildPackageBehaviourBuildCollection(TestCaseWithFactory): | |||
385 | 615 | # The builder is in the process of aborting. | 615 | # The builder is in the process of aborting. |
386 | 616 | def got_update(ignored): | 616 | def got_update(ignored): |
387 | 617 | self.assertEqual( | 617 | self.assertEqual( |
389 | 618 | "Waiting for slave process to be terminated", | 618 | "Waiting for worker process to be terminated", |
390 | 619 | self.candidate.logtail) | 619 | self.candidate.logtail) |
391 | 620 | 620 | ||
392 | 621 | d = self.updateBuild(self.candidate, AbortingWorker()) | 621 | d = self.updateBuild(self.candidate, AbortingWorker()) |