Merge lp:~jml/launchpad/better-slave-mock into lp:launchpad
| Status: | Merged |
|---|---|
| Merged at revision: | 11622 |
| Proposed branch: | lp:~jml/launchpad/better-slave-mock |
| Merge into: | lp:launchpad |
| Diff against target: |
510 lines (+159/-64) 11 files modified
lib/lp/buildmaster/doc/builder.txt (+0/-10) lib/lp/buildmaster/model/builder.py (+41/-23) lib/lp/buildmaster/tests/mock_slaves.py (+1/-1) lib/lp/buildmaster/tests/test_builder.py (+8/-1) lib/lp/codehosting/inmemory.py (+5/-1) lib/lp/codehosting/vfs/__init__.py (+0/-2) lib/lp/codehosting/vfs/branchfs.py (+7/-5) lib/lp/codehosting/vfs/branchfsclient.py (+6/-18) lib/lp/codehosting/vfs/tests/test_transport.py (+3/-2) lib/lp/services/twistedsupport/tests/test_xmlrpc.py (+48/-1) lib/lp/services/twistedsupport/xmlrpc.py (+40/-0) |
| To merge this branch: | bzr merge lp:~jml/launchpad/better-slave-mock |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code | 2010-09-23 | Approve on 2010-09-23 |
|
Review via email:
|
|||
Commit Message
Move BlockingProxy to lp.services.
Description of the Change
This branch moves BlockingProxy from lp.codehosting.vfs and into lp.services.
The branch also adds DeferredBlockin
I was going to actually improve the mocks, but I figured that would be easier to do when driven by actual tests.
| Jonathan Lange (jml) wrote : | # |
On Thu, Sep 23, 2010 at 10:06 AM, Michael Nelson
<email address hidden> wrote:
> Review: Approve code
> Thanks Jonathan - a few notes below, but nothing that needs attention.
>
> It was a good chance for me to learn a little more about twisted :)
>
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -137,43 +138,55 @@
>> # should make a test double that doesn't do any XML-RPC and can be used to
>> # make testing easier & tests faster.
>>
>> - def __init__(self, urlbase, vm_host):
>> - """Initialise a Server with specific parameter to our buildfarm."""
>> - self.vm_host = vm_host
>> - self.urlbase = urlbase
>> - rpc_url = urlappend(urlbase, "rpc")
>> - self._server = xmlrpclib.Server(
>> + def __init__(self, proxy, file_cache_url, vm_host):
>> + """Initialise a Server with specific parameter to our buildfarm.
>
> Nothing of yours, but s/parameter/
>
Fixed.
>> +
>> + :param proxy: An XML-RPC proxy, implementing 'callRemote'. It must
>> + support passing and returning None objects.
>> + :param file_cache_url: The URL of the file cache.
>> + :param vm_host: The VM host to use when resuming.
>> + """
>> + self._vm_host = vm_host
>> + self._
>> + self._server = proxy
>> +
>> + @classmethod
>> + def makeBlockingSla
>> + rpc_url = urlappend(url_base, 'rpc')
>> + server_proxy = xmlrpclib.
>> rpc_url, transport=
>> + file_cache_url = urlappend(url_base, 'filecache')
>> + return cls(BlockingPro
>
> I don't have a preference, but have noticed the code guys using static
> methods unless you need to use the class for something other than
> constructing (eg. lp.code.
>
I'm not sure why that is. My preference is for the classmethod
approach, which is often more suitable for subclassing.
>> @@ -203,9 +216,10 @@
>> :param libraryfilealias: An `ILibraryFileAl
>> """
>> url = libraryfilealia
>> - logger.
>> - "(%s, %s)" % (self.urlbase, libraryfilealia
>> - url, libraryfilealia
>> + logger.debug(
>> + "Asking builder on %s to ensure it has file %s (%s, %s)" % (
>
> Ignore for now, but I wonder if we should start removing interpolation
> operators from logger calls (to avoid interpolation errors). Ie.
> logger.debug("...", arg1, arg2, arg3) (Although if our tests exercise all of
> our logging calls, then we don't need to worry ;))
>
Interesting thought.
>> === modified file 'lib/lp/
>> --- lib/lp/
>> ++...

Thanks Jonathan - a few notes below, but nothing that needs attention.
It was a good chance for me to learn a little more about twisted :)
> === modified file 'lib/lp/ buildmaster/ model/builder. py' buildmaster/ model/builder. py 2010-09-21 18:43:27 +0000 buildmaster/ model/builder. py 2010-09-23 08:14:12 +0000
> --- lib/lp/
> +++ lib/lp/
> @@ -137,43 +138,55 @@
> # should make a test double that doesn't do any XML-RPC and can be used to
> # make testing easier & tests faster.
>
> - def __init__(self, urlbase, vm_host):
> - """Initialise a Server with specific parameter to our buildfarm."""
> - self.vm_host = vm_host
> - self.urlbase = urlbase
> - rpc_url = urlappend(urlbase, "rpc")
> - self._server = xmlrpclib.Server(
> + def __init__(self, proxy, file_cache_url, vm_host):
> + """Initialise a Server with specific parameter to our buildfarm.
Nothing of yours, but s/parameter/ parameters/
> + cache_url = file_cache_url ve(cls, url_base, vm_host): ServerProxy( TimeoutTranspor t(), allow_none=True) xy(server_ proxy), file_cache_url, vm_host)
> + :param proxy: An XML-RPC proxy, implementing 'callRemote'. It must
> + support passing and returning None objects.
> + :param file_cache_url: The URL of the file cache.
> + :param vm_host: The VM host to use when resuming.
> + """
> + self._vm_host = vm_host
> + self._file_
> + self._server = proxy
> +
> + @classmethod
> + def makeBlockingSla
> + rpc_url = urlappend(url_base, 'rpc')
> + server_proxy = xmlrpclib.
> rpc_url, transport=
> + file_cache_url = urlappend(url_base, 'filecache')
> + return cls(BlockingPro
I don't have a preference, but have noticed the code guys using static model.sourcepac kagerecipe. SourcePackageRe cipe.new( ))
methods unless you need to use the class for something other than
constructing (eg. lp.code.
> @@ -203,9 +216,10 @@ ias`. s.http_ url debug(" Asking builder on %s to ensure it has file %s " s.filename, s.content. sha1))
> :param libraryfilealias: An `ILibraryFileAl
> """
> url = libraryfilealia
> - logger.
> - "(%s, %s)" % (self.urlbase, libraryfilealia
> - url, libraryfilealia
> + logger.debug(
> + "Asking builder on %s to ensure it has file %s (%s, %s)" % (
Ignore for now, but I wonder if we should start removing interpolation
operators from logger calls (to avoid interpolation errors). Ie.
logger.debug("...", arg1, arg2, arg3) (Although if our tests exercise all of
our logging calls, then we don't need to worry ;))
> === modified file 'lib/lp/ services/ twistedsupport/ tests/test_ xmlrpc. py' services/ twistedsupport/ tests/test_ xmlrpc. py 2010-08-20 20:31:18 +0000 services/ twistedsupport/ tests/test_ xmlrpc. py 2010-09-23 08:14:12 +0000 l(TestFaultOne. msg_template, fault.faultString) xy(TestCase) : _calls_ attribute( self):
> --- lib/lp/
> +++ lib/lp/
> @@ -86,5 +91,47 @@
> self.assertEqua
>
>
> +class TestBlockingPro
> +
> + def test_callRemote
> + class ExampleProxy:
> + def ok(self, a, b, c=None):
> + ...