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
=== modified file 'lib/lp/buildmaster/manager.py'
--- lib/lp/buildmaster/manager.py 2010-01-13 21:04:49 +0000
+++ lib/lp/buildmaster/manager.py 2010-01-20 10:59:14 +0000
@@ -87,6 +87,10 @@
87 self.ensurepresent(87 self.ensurepresent(
88 libraryfilealias.content.sha1, libraryfilealias.http_url, '', '')88 libraryfilealias.content.sha1, libraryfilealias.http_url, '', '')
8989
90 def sendFileToSlave(self, *args):
91 """Helper to send a file to this builder."""
92 return self.ensurepresent(*args)
93
90 def ensurepresent(self, *args):94 def ensurepresent(self, *args):
91 """Download files needed for the build."""95 """Download files needed for the build."""
92 self.calls.append(('ensurepresent', args))96 self.calls.append(('ensurepresent', args))
9397
=== modified file 'lib/lp/buildmaster/model/builder.py'
--- lib/lp/buildmaster/model/builder.py 2010-01-14 03:40:33 +0000
+++ lib/lp/buildmaster/model/builder.py 2010-01-20 10:59:14 +0000
@@ -129,9 +129,9 @@
129 logger.debug("Asking builder on %s to ensure it has file %s "129 logger.debug("Asking builder on %s to ensure it has file %s "
130 "(%s, %s)" % (self.urlbase, libraryfilealias.filename,130 "(%s, %s)" % (self.urlbase, libraryfilealias.filename,
131 url, libraryfilealias.content.sha1))131 url, libraryfilealias.content.sha1))
132 self._sendFileToSlave(url, libraryfilealias.content.sha1)132 self.sendFileToSlave(libraryfilealias.content.sha1, url)
133133
134 def _sendFileToSlave(self, url, sha1, username="", password=""):134 def sendFileToSlave(self, sha1, url, username="", password=""):
135 """Helper to send the file at 'url' with 'sha1' to this builder."""135 """Helper to send the file at 'url' with 'sha1' to this builder."""
136 present, info = self.ensurepresent(sha1, url, username, password)136 present, info = self.ensurepresent(sha1, url, username, password)
137 if not present:137 if not present:
138138
=== modified file 'lib/lp/buildmaster/tests/test_manager.py'
--- lib/lp/buildmaster/tests/test_manager.py 2010-01-11 23:43:59 +0000
+++ lib/lp/buildmaster/tests/test_manager.py 2010-01-20 10:59:14 +0000
@@ -56,18 +56,29 @@
56 """56 """
57 self.assertEqual('<foo:http://foo:8221/rpc>', repr(self.slave))57 self.assertEqual('<foo:http://foo:8221/rpc>', repr(self.slave))
5858
59 def assert_ensurepresent(self, func):
60 """Helper function to test results from calling ensurepresent."""
61 self.assertEqual(
62 [True, 'Download'],
63 func('boing', 'bar', 'baz'))
64 self.assertEqual(
65 [('ensurepresent', ('boing', 'bar', 'baz'))],
66 self.slave.calls)
67
59 def test_ensurepresent(self):68 def test_ensurepresent(self):
60 """`RecordingSlave.ensurepresent` always succeeds.69 """`RecordingSlave.ensurepresent` always succeeds.
6170
62 It returns the expected succeed code and records the interaction71 It returns the expected succeed code and records the interaction
63 information for later use.72 information for later use.
64 """73 """
65 self.assertEqual(74 self.assert_ensurepresent(self.slave.ensurepresent)
66 [True, 'Download'],75
67 self.slave.ensurepresent('boing', 'bar', 'baz'))76 def test_sendFileToSlave(self):
68 self.assertEqual(77 """RecordingSlave.sendFileToSlave always succeeeds.
69 [('ensurepresent', ('boing', 'bar', 'baz'))],78
70 self.slave.calls)79 It calls ensurepresent() and hence returns the same results.
80 """
81 self.assert_ensurepresent(self.slave.sendFileToSlave)
7182
72 def test_build(self):83 def test_build(self):
73 """`RecordingSlave.build` always succeeds.84 """`RecordingSlave.build` always succeeds.
7485
=== modified file 'lib/lp/soyuz/model/binarypackagebuildbehavior.py'
--- lib/lp/soyuz/model/binarypackagebuildbehavior.py 2010-01-14 03:39:27 +0000
+++ lib/lp/soyuz/model/binarypackagebuildbehavior.py 2010-01-20 10:59:14 +0000
@@ -187,8 +187,8 @@
187 logger.debug("Asking builder on %s to ensure it has file %s "187 logger.debug("Asking builder on %s to ensure it has file %s "
188 "(%s, %s)" % (188 "(%s, %s)" % (
189 self._builder.url, file_name, url, sha1))189 self._builder.url, file_name, url, sha1))
190 self._builder.slave._sendFileToSlave(190 self._builder.slave.sendFileToSlave(
191 url, sha1, "buildd", archive.buildd_secret)191 sha1, url, "buildd", archive.buildd_secret)
192192
193 def _extraBuildArgs(self, build):193 def _extraBuildArgs(self, build):
194 """194 """
195195
=== modified file 'lib/lp/soyuz/tests/soyuzbuilddhelpers.py'
--- lib/lp/soyuz/tests/soyuzbuilddhelpers.py 2010-01-13 21:04:49 +0000
+++ lib/lp/soyuz/tests/soyuzbuilddhelpers.py 2010-01-20 10:59:14 +0000
@@ -186,14 +186,14 @@
186186
187 return (stdout, stderr, resume_process.returncode)187 return (stdout, stderr, resume_process.returncode)
188188
189 def _sendFileToSlave(self, url, sha1, username="", password=""):189 def sendFileToSlave(self, sha1, url, username="", password=""):
190 present, info = self.ensurepresent(sha1, url, username, password)190 present, info = self.ensurepresent(sha1, url, username, password)
191 if not present:191 if not present:
192 raise CannotFetchFile(url, info)192 raise CannotFetchFile(url, info)
193193
194 def cacheFile(self, logger, libraryfilealias):194 def cacheFile(self, logger, libraryfilealias):
195 self._sendFileToSlave(195 self.sendFileToSlave(
196 libraryfilealias.http_url, libraryfilealias.content.sha1)196 libraryfilealias.content.sha1, libraryfilealias.http_url)
197197
198198
199class BuildingSlave(OkSlave):199class BuildingSlave(OkSlave):