Merge lp:~mwhudson/launchpad/remove-old-puller-xmlrpc-methods into lp:launchpad
- remove-old-puller-xmlrpc-methods
- Merge into devel
Proposed by
Michael Hudson-Doyle
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Tim Penhey | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~mwhudson/launchpad/remove-old-puller-xmlrpc-methods | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
448 lines (+2/-306) 8 files modified
lib/lp/code/doc/xmlrpc-branch-puller.txt (+1/-16) lib/lp/code/interfaces/branchpuller.py (+0/-6) lib/lp/code/interfaces/codehosting.py (+0/-14) lib/lp/code/model/branchpuller.py (+0/-22) lib/lp/code/model/tests/test_branchpuller.py (+0/-82) lib/lp/code/xmlrpc/codehosting.py (+1/-43) lib/lp/code/xmlrpc/tests/test_codehosting.py (+0/-100) lib/lp/codehosting/inmemory.py (+0/-23) |
||||
To merge this branch: | bzr merge lp:~mwhudson/launchpad/remove-old-puller-xmlrpc-methods | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Review via email: mp+20024@code.launchpad.net |
Commit message
Remove some code to do with the 'old' way of scheduling branch pulling.
Description of the change
To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : | # |
Revision history for this message
Tim Penhey (thumper) wrote : | # |
merge approved
Yay for obsolete code removal.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/code/doc/xmlrpc-branch-puller.txt' |
2 | --- lib/lp/code/doc/xmlrpc-branch-puller.txt 2009-10-22 11:55:51 +0000 |
3 | +++ lib/lp/code/doc/xmlrpc-branch-puller.txt 2010-02-24 02:03:16 +0000 |
4 | @@ -28,19 +28,4 @@ |
5 | True |
6 | |
7 | The IBranchPuller interface defines some methods, for which see the unit |
8 | -tests. To allow a minimal test here, we call getBranchPullQueue, |
9 | -which will return an empty list. |
10 | - |
11 | - >>> from lp.code.enums import BranchType |
12 | - >>> branch_puller.getBranchPullQueue(BranchType.HOSTED.name) |
13 | - [] |
14 | - |
15 | -This remains true when it is accessed over XMLRPC. |
16 | - |
17 | - >>> import xmlrpclib |
18 | - >>> from canonical.functional import XMLRPCTestTransport |
19 | - >>> puller = xmlrpclib.ServerProxy( |
20 | - ... 'http://xmlrpc-private.launchpad.dev:8087/branch_puller', |
21 | - ... transport=XMLRPCTestTransport()) |
22 | - >>> puller.getBranchPullQueue(BranchType.HOSTED.name) |
23 | - [] |
24 | +tests. |
25 | |
26 | === modified file 'lib/lp/code/interfaces/branchpuller.py' |
27 | --- lib/lp/code/interfaces/branchpuller.py 2009-06-30 16:56:07 +0000 |
28 | +++ lib/lp/code/interfaces/branchpuller.py 2010-02-24 02:03:16 +0000 |
29 | @@ -23,12 +23,6 @@ |
30 | MIRROR_TIME_INCREMENT = Attribute( |
31 | "How frequently we mirror branches.") |
32 | |
33 | - def getPullQueue(branch_type): |
34 | - """Return a queue of branches to mirror using the puller. |
35 | - |
36 | - :param branch_type: A value from the `BranchType` enum. |
37 | - """ |
38 | - |
39 | def acquireBranchToPull(): |
40 | """Return a Branch to pull and mark it as mirror-started. |
41 | |
42 | |
43 | === modified file 'lib/lp/code/interfaces/codehosting.py' |
44 | --- lib/lp/code/interfaces/codehosting.py 2009-06-25 04:06:00 +0000 |
45 | +++ lib/lp/code/interfaces/codehosting.py 2010-02-24 02:03:16 +0000 |
46 | @@ -58,20 +58,6 @@ |
47 | Published at 'branch_puller' on the private XML-RPC server. |
48 | """ |
49 | |
50 | - def getBranchPullQueue(branch_type): |
51 | - """Get the list of branches to be mirrored. |
52 | - |
53 | - :param branch_type: One of 'HOSTED', 'MIRRORED', or 'IMPORTED'. |
54 | - |
55 | - :raise UnknownBranchTypeError: if the branch type is unrecognized. |
56 | - |
57 | - :returns: a list of (branch_id, pull_url, unique_name, default_branch) |
58 | - 4-tuples. branch_id is the database id of the branch, pull_url is |
59 | - where to pull from, unique_name is the unique_name of the branch |
60 | - and default_branch is the default stacked on branch for the |
61 | - branch's target. |
62 | - """ |
63 | - |
64 | def acquireBranchToPull(): |
65 | """Return a Branch to pull and mark it as mirror-started. |
66 | |
67 | |
68 | === modified file 'lib/lp/code/model/branchpuller.py' |
69 | --- lib/lp/code/model/branchpuller.py 2009-08-04 05:14:32 +0000 |
70 | +++ lib/lp/code/model/branchpuller.py 2010-02-24 02:03:16 +0000 |
71 | @@ -9,17 +9,13 @@ |
72 | |
73 | from datetime import timedelta |
74 | |
75 | -from storm.expr import LeftJoin, Join |
76 | from zope.component import getUtility |
77 | from zope.interface import implements |
78 | |
79 | from canonical.database.constants import UTC_NOW |
80 | from lp.code.enums import BranchType |
81 | from lp.code.model.branch import Branch |
82 | -from lp.code.interfaces.branch import BranchTypeError |
83 | from lp.code.interfaces.branchpuller import IBranchPuller |
84 | -from lp.registry.model.person import Owner |
85 | -from lp.registry.model.product import Product |
86 | from canonical.launchpad.webapp.interfaces import ( |
87 | IStoreSelector, MAIN_STORE, DEFAULT_FLAVOR) |
88 | |
89 | @@ -32,24 +28,6 @@ |
90 | MAXIMUM_MIRROR_FAILURES = 5 |
91 | MIRROR_TIME_INCREMENT = timedelta(hours=6) |
92 | |
93 | - def getPullQueue(self, branch_type): |
94 | - """See `IBranchPuller`.""" |
95 | - if branch_type == BranchType.REMOTE: |
96 | - raise BranchTypeError("No pull queue for REMOTE branches.") |
97 | - store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR) |
98 | - # Prejoin on owner and product to preserve existing behaviour. |
99 | - # XXX: JonathanLange 2009-03-22 spec=package-branches: This prejoin is |
100 | - # inappropriate in the face of package branches. |
101 | - prejoin = store.using( |
102 | - Branch, |
103 | - LeftJoin(Product, Branch.product == Product.id), |
104 | - Join(Owner, Branch.owner == Owner.id)) |
105 | - return prejoin.find( |
106 | - Branch, |
107 | - Branch.branch_type == branch_type, |
108 | - Branch.next_mirror_time <= UTC_NOW).order_by( |
109 | - Branch.next_mirror_time) |
110 | - |
111 | def acquireBranchToPull(self): |
112 | """See `IBranchPuller`.""" |
113 | store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR) |
114 | |
115 | === modified file 'lib/lp/code/model/tests/test_branchpuller.py' |
116 | --- lib/lp/code/model/tests/test_branchpuller.py 2009-09-28 23:51:54 +0000 |
117 | +++ lib/lp/code/model/tests/test_branchpuller.py 2010-02-24 02:03:16 +0000 |
118 | @@ -17,7 +17,6 @@ |
119 | from canonical.database.constants import UTC_NOW |
120 | from canonical.testing.layers import DatabaseFunctionalLayer |
121 | from lp.code.enums import BranchType |
122 | -from lp.code.interfaces.branch import BranchTypeError |
123 | from lp.code.interfaces.branchpuller import IBranchPuller |
124 | from lp.testing import TestCaseWithFactory, login_person |
125 | |
126 | @@ -78,37 +77,6 @@ |
127 | branch.requestMirror() |
128 | self.assertEqual(UTC_NOW, branch.next_mirror_time) |
129 | |
130 | - def test_requestMirrorDuringPull(self): |
131 | - """Branches can have mirrors requested while they are being mirrored. |
132 | - If so, they should not be removed from the pull queue when the mirror |
133 | - is complete. |
134 | - """ |
135 | - # We run these in separate transactions so as to have the times set to |
136 | - # different values. This is closer to what happens in production. |
137 | - branch = self.makeAnyBranch() |
138 | - branch.startMirroring() |
139 | - self.assertEqual( |
140 | - [], list(self.branch_puller.getPullQueue(branch.branch_type))) |
141 | - branch.requestMirror() |
142 | - self.assertEqual( |
143 | - [branch], |
144 | - list(self.branch_puller.getPullQueue(branch.branch_type))) |
145 | - branch.mirrorComplete('rev1') |
146 | - self.assertEqual( |
147 | - [branch], |
148 | - list(self.branch_puller.getPullQueue(branch.branch_type))) |
149 | - |
150 | - def test_startMirroringRemovesFromPullQueue(self): |
151 | - # Starting a mirror removes the branch from the pull queue. |
152 | - branch = self.makeAnyBranch() |
153 | - branch.requestMirror() |
154 | - self.assertEqual( |
155 | - set([branch]), |
156 | - set(self.branch_puller.getPullQueue(branch.branch_type))) |
157 | - branch.startMirroring() |
158 | - self.assertEqual( |
159 | - set(), set(self.branch_puller.getPullQueue(branch.branch_type))) |
160 | - |
161 | def test_mirroringResetsMirrorRequest(self): |
162 | """Mirroring branches resets their mirror request times.""" |
163 | branch = self.makeAnyBranch() |
164 | @@ -129,44 +97,6 @@ |
165 | self.assertEqual(1, branch.mirror_failures) |
166 | self.assertEqual(None, branch.next_mirror_time) |
167 | |
168 | - def test_pullQueueEmpty(self): |
169 | - """Branches with no next_mirror_time are not in the pull queue.""" |
170 | - branch = self.makeAnyBranch() |
171 | - self.assertIs(None, branch.next_mirror_time) |
172 | - self.assertEqual( |
173 | - [], list(self.branch_puller.getPullQueue(self.branch_type))) |
174 | - |
175 | - def test_pastNextMirrorTimeInQueue(self): |
176 | - """Branches with next_mirror_time in the past are mirrored.""" |
177 | - transaction.begin() |
178 | - branch = self.makeAnyBranch() |
179 | - branch.requestMirror() |
180 | - queue = self.branch_puller.getPullQueue(branch.branch_type) |
181 | - self.assertEqual([branch], list(queue)) |
182 | - |
183 | - def test_futureNextMirrorTimeInQueue(self): |
184 | - """Branches with next_mirror_time in the future are not mirrored.""" |
185 | - transaction.begin() |
186 | - branch = removeSecurityProxy(self.makeAnyBranch()) |
187 | - tomorrow = self.getNow() + timedelta(1) |
188 | - branch.next_mirror_time = tomorrow |
189 | - branch.syncUpdate() |
190 | - transaction.commit() |
191 | - self.assertEqual( |
192 | - [], list(self.branch_puller.getPullQueue(branch.branch_type))) |
193 | - |
194 | - def test_pullQueueOrder(self): |
195 | - """Pull queue has the oldest mirror request times first.""" |
196 | - branches = [] |
197 | - for i in range(3): |
198 | - branch = removeSecurityProxy(self.makeAnyBranch()) |
199 | - branch.next_mirror_time = self.getNow() - timedelta(hours=i+1) |
200 | - branch.sync() |
201 | - branches.append(branch) |
202 | - self.assertEqual( |
203 | - list(reversed(branches)), |
204 | - list(self.branch_puller.getPullQueue(self.branch_type))) |
205 | - |
206 | |
207 | class TestMirroringForMirroredBranches(TestMirroringForHostedBranches): |
208 | |
209 | @@ -231,18 +161,6 @@ |
210 | branch_type = BranchType.IMPORTED |
211 | |
212 | |
213 | -class TestRemoteBranches(TestCaseWithFactory): |
214 | - |
215 | - layer = DatabaseFunctionalLayer |
216 | - |
217 | - def test_raises_branch_type_error(self): |
218 | - # getPullQueue raises `BranchTypeError` if passed BranchType.REMOTE. |
219 | - # It's impossible to mirror remote branches, so we shouldn't even try. |
220 | - puller = getUtility(IBranchPuller) |
221 | - self.assertRaises( |
222 | - BranchTypeError, puller.getPullQueue, BranchType.REMOTE) |
223 | - |
224 | - |
225 | class AcquireBranchToPullTests: |
226 | """Tests for acquiring branches to pull. |
227 | |
228 | |
229 | === modified file 'lib/lp/code/xmlrpc/codehosting.py' |
230 | --- lib/lp/code/xmlrpc/codehosting.py 2009-11-23 22:39:21 +0000 |
231 | +++ lib/lp/code/xmlrpc/codehosting.py 2010-02-24 02:03:16 +0000 |
232 | @@ -12,7 +12,6 @@ |
233 | |
234 | |
235 | import datetime |
236 | -import urllib |
237 | |
238 | import pytz |
239 | |
240 | @@ -25,8 +24,7 @@ |
241 | |
242 | from canonical.launchpad.ftests import login_person, logout |
243 | from lp.code.enums import BranchType |
244 | -from lp.code.interfaces.branch import ( |
245 | - BranchCreationException, UnknownBranchTypeError) |
246 | +from lp.code.interfaces.branch import BranchCreationException |
247 | from lp.code.interfaces.branchlookup import IBranchLookup |
248 | from lp.code.interfaces.branchnamespace import ( |
249 | InvalidNamespace, lookup_branch_namespace, split_unique_name) |
250 | @@ -56,46 +54,6 @@ |
251 | |
252 | implements(IBranchPuller) |
253 | |
254 | - def _getBranchPullInfo(self, branch): |
255 | - """Return information the branch puller needs to pull this branch. |
256 | - |
257 | - This is outside of the IBranch interface so that the authserver can |
258 | - access the information without logging in as a particular user. |
259 | - |
260 | - :return: (id, url, unique_name, default_stacked_on_url), where 'id' |
261 | - is the branch database ID, 'url' is the URL to pull from, |
262 | - 'unique_name' is the `unique_name` property and |
263 | - 'default_stacked_on_url' is the URL of the branch to stack on by |
264 | - default (normally of the form '/~foo/bar/baz'). If there is no |
265 | - default stacked-on branch, then it's ''. |
266 | - """ |
267 | - branch = removeSecurityProxy(branch) |
268 | - if branch.branch_type == BranchType.REMOTE: |
269 | - raise AssertionError( |
270 | - 'Remote branches should never be in the pull queue.') |
271 | - default_branch = branch.target.default_stacked_on_branch |
272 | - if default_branch is None: |
273 | - default_branch = '' |
274 | - elif (branch.branch_type == BranchType.MIRRORED |
275 | - and default_branch.private): |
276 | - default_branch = '' |
277 | - else: |
278 | - default_branch = '/' + default_branch.unique_name |
279 | - return ( |
280 | - branch.id, branch.getPullURL(), branch.unique_name, |
281 | - default_branch) |
282 | - |
283 | - def getBranchPullQueue(self, branch_type): |
284 | - """See `IBranchPuller`.""" |
285 | - try: |
286 | - branch_type = BranchType.items[branch_type] |
287 | - except KeyError: |
288 | - raise UnknownBranchTypeError( |
289 | - 'Unknown branch type: %r' % (branch_type,)) |
290 | - branches = getUtility(branchpuller.IBranchPuller).getPullQueue( |
291 | - branch_type) |
292 | - return [self._getBranchPullInfo(branch) for branch in branches] |
293 | - |
294 | def acquireBranchToPull(self): |
295 | """See `IBranchPuller`.""" |
296 | branch = getUtility(branchpuller.IBranchPuller).acquireBranchToPull() |
297 | |
298 | === modified file 'lib/lp/code/xmlrpc/tests/test_codehosting.py' |
299 | --- lib/lp/code/xmlrpc/tests/test_codehosting.py 2010-02-18 03:11:03 +0000 |
300 | +++ lib/lp/code/xmlrpc/tests/test_codehosting.py 2010-02-24 02:03:16 +0000 |
301 | @@ -399,105 +399,6 @@ |
302 | self.assertFaultEqual(faults.NoBranchWithID(branch_id), fault) |
303 | |
304 | |
305 | -class BranchPullQueueTest(TestCaseWithFactory): |
306 | - """Tests for the pull queue methods of `IBranchPuller`.""" |
307 | - |
308 | - def setUp(self): |
309 | - super(BranchPullQueueTest, self).setUp() |
310 | - frontend = self.frontend() |
311 | - self.storage = frontend.getPullerEndpoint() |
312 | - self.factory = frontend.getLaunchpadObjectFactory() |
313 | - |
314 | - def assertBranchQueues(self, hosted, mirrored, imported): |
315 | - expected_hosted = [ |
316 | - self.storage._getBranchPullInfo(branch) for branch in hosted] |
317 | - expected_mirrored = [ |
318 | - self.storage._getBranchPullInfo(branch) for branch in mirrored] |
319 | - expected_imported = [ |
320 | - self.storage._getBranchPullInfo(branch) for branch in imported] |
321 | - self.assertEqual( |
322 | - expected_hosted, self.storage.getBranchPullQueue('HOSTED')) |
323 | - self.assertEqual( |
324 | - expected_mirrored, self.storage.getBranchPullQueue('MIRRORED')) |
325 | - self.assertEqual( |
326 | - expected_imported, self.storage.getBranchPullQueue('IMPORTED')) |
327 | - |
328 | - def test_pullQueuesEmpty(self): |
329 | - """getBranchPullQueue returns an empty list when there are no branches |
330 | - to pull. |
331 | - """ |
332 | - self.assertBranchQueues([], [], []) |
333 | - |
334 | - def makeBranchAndRequestMirror(self, branch_type): |
335 | - """Make a branch of the given type and call requestMirror on it.""" |
336 | - branch = self.factory.makeAnyBranch(branch_type=branch_type) |
337 | - branch.requestMirror() |
338 | - # The pull queues contain branches that have next_mirror_time strictly |
339 | - # in the past, but requestMirror sets this field to UTC_NOW, so we |
340 | - # push the time back slightly here to get the branch to show up in the |
341 | - # queue. |
342 | - naked_branch = removeSecurityProxy(branch) |
343 | - naked_branch.next_mirror_time -= datetime.timedelta(seconds=1) |
344 | - return branch |
345 | - |
346 | - def test_getBranchPullInfo_no_default_stacked_branch(self): |
347 | - # If there's no default stacked branch for the project that a branch |
348 | - # is on, then _getBranchPullInfo returns (id, url, unique_name, ''). |
349 | - branch = self.factory.makeAnyBranch() |
350 | - info = self.storage._getBranchPullInfo(branch) |
351 | - self.assertEqual( |
352 | - (branch.id, branch.getPullURL(), branch.unique_name, ''), info) |
353 | - |
354 | - def test_getBranchPullInfo_default_stacked_branch(self): |
355 | - # If there's a default stacked branch for the project that a branch is |
356 | - # on, then _getBranchPullInfo returns (id, url, unique_name, |
357 | - # default_branch_unique_name). |
358 | - product = self.factory.makeProduct() |
359 | - default_branch = self.factory.enableDefaultStackingForProduct(product) |
360 | - branch = self.factory.makeProductBranch(product=product) |
361 | - info = self.storage._getBranchPullInfo(branch) |
362 | - self.assertEqual( |
363 | - (branch.id, branch.getPullURL(), branch.unique_name, |
364 | - '/' + default_branch.unique_name), info) |
365 | - |
366 | - def test_getBranchPullInfo_private_branch(self): |
367 | - # We don't want to stack mirrored branches onto private branches: |
368 | - # mirrored branches are public by their nature. Thus, if the default |
369 | - # stacked-on branch for the project is private and the branch is |
370 | - # MIRRORED then we don't include the default stacked-on branch's |
371 | - # details in the tuple. |
372 | - product = self.factory.makeProduct() |
373 | - default_branch = self.factory.makeProductBranch( |
374 | - product=product, private=True) |
375 | - self.factory.enableDefaultStackingForProduct(product, default_branch) |
376 | - mirrored_branch = self.factory.makeProductBranch( |
377 | - branch_type=BranchType.MIRRORED, product=product) |
378 | - info = self.storage._getBranchPullInfo(mirrored_branch) |
379 | - self.assertEqual( |
380 | - (mirrored_branch.id, mirrored_branch.getPullURL(), |
381 | - mirrored_branch.unique_name, ''), info) |
382 | - |
383 | - def test_getBranchPullInfo_junk(self): |
384 | - # _getBranchPullInfo returns (id, url, unique_name, '') for junk |
385 | - # branches. |
386 | - branch = self.factory.makePersonalBranch() |
387 | - info = self.storage._getBranchPullInfo(branch) |
388 | - self.assertEqual( |
389 | - (branch.id, branch.getPullURL(), branch.unique_name, ''), info) |
390 | - |
391 | - def test_requestMirrorPutsBranchInQueue_hosted(self): |
392 | - branch = self.makeBranchAndRequestMirror(BranchType.HOSTED) |
393 | - self.assertBranchQueues([branch], [], []) |
394 | - |
395 | - def test_requestMirrorPutsBranchInQueue_mirrored(self): |
396 | - branch = self.makeBranchAndRequestMirror(BranchType.MIRRORED) |
397 | - self.assertBranchQueues([], [branch], []) |
398 | - |
399 | - def test_requestMirrorPutsBranchInQueue_imported(self): |
400 | - branch = self.makeBranchAndRequestMirror(BranchType.IMPORTED) |
401 | - self.assertBranchQueues([], [], [branch]) |
402 | - |
403 | - |
404 | class AcquireBranchToPullTestsViaEndpoint(TestCaseWithFactory, |
405 | AcquireBranchToPullTests): |
406 | """Tests for `acquireBranchToPull` method of `IBranchPuller`.""" |
407 | @@ -1175,7 +1076,6 @@ |
408 | suite = unittest.TestSuite() |
409 | puller_tests = unittest.TestSuite( |
410 | [loader.loadTestsFromTestCase(BranchPullerTest), |
411 | - loader.loadTestsFromTestCase(BranchPullQueueTest), |
412 | loader.loadTestsFromTestCase(AcquireBranchToPullTestsViaEndpoint), |
413 | loader.loadTestsFromTestCase(BranchFileSystemTest), |
414 | ]) |
415 | |
416 | === modified file 'lib/lp/codehosting/inmemory.py' |
417 | --- lib/lp/codehosting/inmemory.py 2010-02-19 03:06:12 +0000 |
418 | +++ lib/lp/codehosting/inmemory.py 2010-02-24 02:03:16 +0000 |
419 | @@ -442,29 +442,6 @@ |
420 | self._branch_set = branch_set |
421 | self._script_activity_set = script_activity_set |
422 | |
423 | - def _getBranchPullInfo(self, branch): |
424 | - default_branch = '' |
425 | - if branch.product is not None: |
426 | - series = branch.product.development_focus |
427 | - user_branch = series.branch |
428 | - if (user_branch is not None |
429 | - and not ( |
430 | - user_branch.private |
431 | - and branch.branch_type == BranchType.MIRRORED)): |
432 | - default_branch = '/' + user_branch.unique_name |
433 | - return ( |
434 | - branch.id, branch.getPullURL(), branch.unique_name, |
435 | - default_branch) |
436 | - |
437 | - def getBranchPullQueue(self, branch_type): |
438 | - queue = [] |
439 | - branch_type = BranchType.items[branch_type] |
440 | - for branch in self._branch_set: |
441 | - if (branch.branch_type == branch_type |
442 | - and branch.next_mirror_time < UTC_NOW): |
443 | - queue.append(self._getBranchPullInfo(branch)) |
444 | - return queue |
445 | - |
446 | def acquireBranchToPull(self): |
447 | branches = sorted( |
448 | [branch for branch in self._branch_set |
Just deleting some code we don't use any more.