Merge lp:~julian-edwards/launchpad/missing-slave-method-bug-509383 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/missing-slave-method-bug-509383
Merge into: lp:launchpad
Diff against target: 107 lines (+28/-13)
5 files modified
lib/lp/buildmaster/manager.py (+4/-0)
lib/lp/buildmaster/model/builder.py (+2/-2)
lib/lp/buildmaster/tests/test_manager.py (+17/-6)
lib/lp/soyuz/model/binarypackagebuildbehavior.py (+2/-2)
lib/lp/soyuz/tests/soyuzbuilddhelpers.py (+3/-3)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/missing-slave-method-bug-509383
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+17679@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

= Summary =
Add a method to RecordingSlave that was missed during refactoring

== Proposed fix ==
RecordingSlave is missing _sendFileToSlave(). This was missed out during the
refactoring at the Wellington sprint and causes private builds to fail.

== Implementation details ==
The new method just calls RecordingSlave.ensurepresent so the same test for
that is re-used.

== Tests ==
bin/test -vvct TestRecordingSlaves

== Demo and Q/A ==

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/buildmaster/model/builder.py
  lib/lp/buildmaster/tests/test_manager.py
  lib/lp/soyuz/tests/soyuzbuilddhelpers.py
  lib/lp/buildmaster/manager.py
  lib/lp/soyuz/model/binarypackagebuildbehavior.py

Revision history for this message
Brad Crittenden (bac) :
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/manager.py'
2--- lib/lp/buildmaster/manager.py 2010-01-13 21:04:49 +0000
3+++ lib/lp/buildmaster/manager.py 2010-01-20 10:59:14 +0000
4@@ -87,6 +87,10 @@
5 self.ensurepresent(
6 libraryfilealias.content.sha1, libraryfilealias.http_url, '', '')
7
8+ def sendFileToSlave(self, *args):
9+ """Helper to send a file to this builder."""
10+ return self.ensurepresent(*args)
11+
12 def ensurepresent(self, *args):
13 """Download files needed for the build."""
14 self.calls.append(('ensurepresent', args))
15
16=== modified file 'lib/lp/buildmaster/model/builder.py'
17--- lib/lp/buildmaster/model/builder.py 2010-01-14 03:40:33 +0000
18+++ lib/lp/buildmaster/model/builder.py 2010-01-20 10:59:14 +0000
19@@ -129,9 +129,9 @@
20 logger.debug("Asking builder on %s to ensure it has file %s "
21 "(%s, %s)" % (self.urlbase, libraryfilealias.filename,
22 url, libraryfilealias.content.sha1))
23- self._sendFileToSlave(url, libraryfilealias.content.sha1)
24+ self.sendFileToSlave(libraryfilealias.content.sha1, url)
25
26- def _sendFileToSlave(self, url, sha1, username="", password=""):
27+ def sendFileToSlave(self, sha1, url, username="", password=""):
28 """Helper to send the file at 'url' with 'sha1' to this builder."""
29 present, info = self.ensurepresent(sha1, url, username, password)
30 if not present:
31
32=== modified file 'lib/lp/buildmaster/tests/test_manager.py'
33--- lib/lp/buildmaster/tests/test_manager.py 2010-01-11 23:43:59 +0000
34+++ lib/lp/buildmaster/tests/test_manager.py 2010-01-20 10:59:14 +0000
35@@ -56,18 +56,29 @@
36 """
37 self.assertEqual('<foo:http://foo:8221/rpc>', repr(self.slave))
38
39+ def assert_ensurepresent(self, func):
40+ """Helper function to test results from calling ensurepresent."""
41+ self.assertEqual(
42+ [True, 'Download'],
43+ func('boing', 'bar', 'baz'))
44+ self.assertEqual(
45+ [('ensurepresent', ('boing', 'bar', 'baz'))],
46+ self.slave.calls)
47+
48 def test_ensurepresent(self):
49 """`RecordingSlave.ensurepresent` always succeeds.
50
51 It returns the expected succeed code and records the interaction
52 information for later use.
53 """
54- self.assertEqual(
55- [True, 'Download'],
56- self.slave.ensurepresent('boing', 'bar', 'baz'))
57- self.assertEqual(
58- [('ensurepresent', ('boing', 'bar', 'baz'))],
59- self.slave.calls)
60+ self.assert_ensurepresent(self.slave.ensurepresent)
61+
62+ def test_sendFileToSlave(self):
63+ """RecordingSlave.sendFileToSlave always succeeeds.
64+
65+ It calls ensurepresent() and hence returns the same results.
66+ """
67+ self.assert_ensurepresent(self.slave.sendFileToSlave)
68
69 def test_build(self):
70 """`RecordingSlave.build` always succeeds.
71
72=== modified file 'lib/lp/soyuz/model/binarypackagebuildbehavior.py'
73--- lib/lp/soyuz/model/binarypackagebuildbehavior.py 2010-01-14 03:39:27 +0000
74+++ lib/lp/soyuz/model/binarypackagebuildbehavior.py 2010-01-20 10:59:14 +0000
75@@ -187,8 +187,8 @@
76 logger.debug("Asking builder on %s to ensure it has file %s "
77 "(%s, %s)" % (
78 self._builder.url, file_name, url, sha1))
79- self._builder.slave._sendFileToSlave(
80- url, sha1, "buildd", archive.buildd_secret)
81+ self._builder.slave.sendFileToSlave(
82+ sha1, url, "buildd", archive.buildd_secret)
83
84 def _extraBuildArgs(self, build):
85 """
86
87=== modified file 'lib/lp/soyuz/tests/soyuzbuilddhelpers.py'
88--- lib/lp/soyuz/tests/soyuzbuilddhelpers.py 2010-01-13 21:04:49 +0000
89+++ lib/lp/soyuz/tests/soyuzbuilddhelpers.py 2010-01-20 10:59:14 +0000
90@@ -186,14 +186,14 @@
91
92 return (stdout, stderr, resume_process.returncode)
93
94- def _sendFileToSlave(self, url, sha1, username="", password=""):
95+ def sendFileToSlave(self, sha1, url, username="", password=""):
96 present, info = self.ensurepresent(sha1, url, username, password)
97 if not present:
98 raise CannotFetchFile(url, info)
99
100 def cacheFile(self, logger, libraryfilealias):
101- self._sendFileToSlave(
102- libraryfilealias.http_url, libraryfilealias.content.sha1)
103+ self.sendFileToSlave(
104+ libraryfilealias.content.sha1, libraryfilealias.http_url)
105
106
107 class BuildingSlave(OkSlave):