Merge lp:~mwhudson/launchpad/puller-doesnt-call-startMirroring into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/puller-doesnt-call-startMirroring
Merge into: lp:launchpad
Diff against target: 86 lines
2 files modified
lib/lp/codehosting/puller/scheduler.py (+2/-4)
lib/lp/codehosting/puller/tests/test_scheduler.py (+8/-21)
To merge this branch: bzr merge lp:~mwhudson/launchpad/puller-doesnt-call-startMirroring
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+12563@code.launchpad.net

Commit message

Remove a now-redundant call to startMirroring in the puller worker.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hi,

This branch removes a superfluous call to startMirroring from the puller system -- it's called by acquireBranchToPull already.

More changes to tests than code...

Cheers,
mwh

Revision history for this message
Tim Penhey (thumper) wrote :

Looks good.

I also noticed your comment on IRC about how you thought it may be possible to have two workers pulling the same branch. In normal circumstances it won't be, however I just thought of an edge case where it is currently pulling a branch, and a new requestMirror comes in, will another worker try to pull it again?

review: Approve
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

> Looks good.
>
> I also noticed your comment on IRC about how you thought it may be possible to
> have two workers pulling the same branch. In normal circumstances it won't
> be, however I just thought of an edge case where it is currently pulling a
> branch, and a new requestMirror comes in, will another worker try to pull it
> again?

Yeah, that's exactly what I mean.

Cheers,
mwh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/codehosting/puller/scheduler.py'
2--- lib/lp/codehosting/puller/scheduler.py 2009-09-28 17:54:00 +0000
3+++ lib/lp/codehosting/puller/scheduler.py 2009-10-01 22:50:24 +0000
4@@ -366,10 +366,8 @@
5
6 def startMirroring(self):
7 self.logger.info(
8- 'Mirroring branch %d: %s to %s', self.branch_id, self.source_url,
9- self.destination_url)
10- return self.branch_puller_endpoint.callRemote(
11- 'startMirroring', self.branch_id)
12+ 'Worker started on branch %d: %s to %s', self.branch_id,
13+ self.source_url, self.destination_url)
14
15 def mirrorFailed(self, reason, oops):
16 self.logger.info('Recorded %s', oops)
17
18=== modified file 'lib/lp/codehosting/puller/tests/test_scheduler.py'
19--- lib/lp/codehosting/puller/tests/test_scheduler.py 2009-07-29 06:02:12 +0000
20+++ lib/lp/codehosting/puller/tests/test_scheduler.py 2009-10-01 22:50:24 +0000
21@@ -445,12 +445,11 @@
22 self.eventHandler.unique_name), oops.url)
23
24 def test_startMirroring(self):
25- deferred = self.eventHandler.startMirroring()
26+ # startMirroring does not send a message to the endpoint.
27+ deferred = defer.maybeDeferred(self.eventHandler.startMirroring)
28
29 def checkMirrorStarted(ignored):
30- self.assertEqual(
31- [('startMirroring', self.arbitrary_branch_id)],
32- self.status_client.calls)
33+ self.assertEqual([], self.status_client.calls)
34
35 return deferred.addCallback(checkMirrorStarted)
36
37@@ -477,7 +476,7 @@
38
39 def test_mirrorComplete(self):
40 arbitrary_revision_id = 'rev1'
41- deferred = self.eventHandler.startMirroring()
42+ deferred = defer.maybeDeferred(self.eventHandler.startMirroring)
43
44 def mirrorSucceeded(ignored):
45 self.status_client.calls = []
46@@ -494,7 +493,7 @@
47 def test_mirrorFailed(self):
48 arbitrary_error_message = 'failed'
49
50- deferred = self.eventHandler.startMirroring()
51+ deferred = defer.maybeDeferred(self.eventHandler.startMirroring)
52
53 def mirrorFailed(ignored):
54 self.status_client.calls = []
55@@ -704,8 +703,7 @@
56
57 def check_authserver_called(ignored):
58 self.assertEqual(
59- [('startMirroring', self.db_branch.id),
60- ('setStackedOn', 77, ''),
61+ [('setStackedOn', 77, ''),
62 ('mirrorComplete', self.db_branch.id, revision_id)],
63 self.client.calls)
64 return ignored
65@@ -963,19 +961,8 @@
66 script_text=lower_timeout_script)
67 deferred = puller_master.mirror()
68 def check_mirror_failed(ignored):
69- # In Bazaar 1.15, set_stacked_on_url locks the branch. With
70- # 1.14, there's an extra 'setStackedOn' call to the XML-RPC
71- # server, which is wrong. With 1.15, that call no longer takes
72- # place.
73- #
74- # Assert that the call length is 2 (not 3) when we upgrade to
75- # Bazaar 1.15.
76- self.assertIn(len(self.client.calls), [2, 3])
77- start_mirroring_call = self.client.calls[0]
78- mirror_failed_call = self.client.calls[-1]
79- self.assertEqual(
80- start_mirroring_call,
81- ('startMirroring', self.db_branch.id))
82+ self.assertEqual(len(self.client.calls), 1)
83+ mirror_failed_call = self.client.calls[0]
84 self.assertEqual(
85 mirror_failed_call[:2],
86 ('mirrorFailed', self.db_branch.id))