Merge lp:~henninge/launchpad/bug-581746-serialization-error into lp:launchpad

Proposed by Henning Eggers
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 10900
Proposed branch: lp:~henninge/launchpad/bug-581746-serialization-error
Merge into: lp:launchpad
Prerequisite: lp:~danilo/launchpad/bug-580345-devel
Diff against target: 83 lines (+37/-3)
3 files modified
lib/canonical/buildd/debian/changelog (+6/-0)
lib/canonical/buildd/slave.py (+3/-2)
lib/canonical/buildd/tests/test_buildd_slave.py (+28/-1)
To merge this branch: bzr merge lp:~henninge/launchpad/bug-581746-serialization-error
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+25623@code.launchpad.net

Commit message

Stop the builder from tripping over None not being serializable.

Description of the change

Tiny little fix that adds some real extra info to BuilderStatus.UNKNOWNBUILDER instead of None.

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

Never mind the changelog entry. The next branch replaces that anyway ...

Revision history for this message
Данило Шеган (danilo) wrote :

How about adding allowNone to XMLRPC constructor as well, so we don't get errors when we possibly hit more bugs and try to serialize None elsewhere?

=== modified file 'lib/canonical/buildd/slave.py'
--- lib/canonical/buildd/slave.py 2010-04-07 18:57:10 +0000
+++ lib/canonical/buildd/slave.py 2010-05-19 17:17:44 +0000
@@ -546,7 +546,7 @@
     """XMLRPC build daemon slave management interface"""

     def __init__(self, config):
- xmlrpc.XMLRPC.__init__(self)
+ xmlrpc.XMLRPC.__init__(self, allowNone=True)
         # The V1.0 new-style protocol introduces string-style protocol
         # versions of the form 'MAJOR.MINOR', the protocol is '1.0' for now
         # implying the presence of /filecache/ /filecache/buildlog and

It would also be nice to test this.

Revision history for this message
Данило Шеган (danilo) wrote :

Note that buildd-manager xmlrpc implementation already passes allow_none=True (it uses a different library: xmlrpclib) so it will be able to handle it.

Revision history for this message
Данило Шеган (danilo) wrote :

Looks good, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/buildd/debian/changelog'
2--- lib/canonical/buildd/debian/changelog 2010-04-01 14:55:37 +0000
3+++ lib/canonical/buildd/debian/changelog 2010-05-20 14:32:30 +0000
4@@ -1,3 +1,9 @@
5+launchpad-buildd (60.1) lucid-cat; urgency=low
6+
7+ * Improve output of build xmplrpc call.
8+
9+ -- Henning Eggers <henning@canonical.com> Mon, 17 May 2010 15:58:48 +0200
10+
11 launchpad-buildd (60) lucid-cat; urgency=low
12
13 * Depends: lsb-release, which is ubuntu-minimal, but not essential.
14
15=== modified file 'lib/canonical/buildd/slave.py'
16--- lib/canonical/buildd/slave.py 2010-04-07 18:57:10 +0000
17+++ lib/canonical/buildd/slave.py 2010-05-20 14:32:30 +0000
18@@ -546,7 +546,7 @@
19 """XMLRPC build daemon slave management interface"""
20
21 def __init__(self, config):
22- xmlrpc.XMLRPC.__init__(self)
23+ xmlrpc.XMLRPC.__init__(self, allowNone=True)
24 # The V1.0 new-style protocol introduces string-style protocol
25 # versions of the form 'MAJOR.MINOR', the protocol is '1.0' for now
26 # implying the presence of /filecache/ /filecache/buildlog and
27@@ -651,7 +651,8 @@
28 """
29 # check requested builder
30 if not builder in self._builders:
31- return (BuilderStatus.UNKNOWNBUILDER, None)
32+ extra_info = "%s not in %r" % (builder, self._builders.keys())
33+ return (BuilderStatus.UNKNOWNBUILDER, extra_info)
34 # check requested chroot availability
35 chroot_present, info = self.slave.ensurePresent(chrootsum)
36 if not chroot_present:
37
38=== modified file 'lib/canonical/buildd/tests/test_buildd_slave.py'
39--- lib/canonical/buildd/tests/test_buildd_slave.py 2009-06-25 05:30:52 +0000
40+++ lib/canonical/buildd/tests/test_buildd_slave.py 2010-05-20 14:32:30 +0000
41@@ -20,8 +20,10 @@
42 import shutil
43 import urllib2
44 import unittest
45+import xmlrpclib
46
47-from canonical.buildd.tests.harness import BuilddTestCase
48+from canonical.buildd.tests.harness import (
49+ BuilddSlaveTestSetup, BuilddTestCase)
50
51
52 def read_file(path):
53@@ -170,5 +172,30 @@
54 self.assertEqual(len(log_tail), 0)
55
56
57+class XMLRPCBuildDSlaveTests(unittest.TestCase):
58+
59+ def setUp(self):
60+ super(XMLRPCBuildDSlaveTests, self).setUp()
61+ BuilddSlaveTestSetup().setUp()
62+ self.server = xmlrpclib.Server('http://localhost:8221/rpc/')
63+
64+ def tearDown(self):
65+ BuilddSlaveTestSetup().tearDown()
66+ super(XMLRPCBuildDSlaveTests, self).tearDown()
67+
68+ def test_build_unknown_builder(self):
69+ # If a bogus builder name is passed into build, it returns an
70+ # appropriate error message and not just 'None'.
71+ buildername = 'nonexistentbuilder'
72+ status, info = self.server.build('foo', buildername, 'sha1', {}, {})
73+
74+ self.assertEqual('BuilderStatus.UNKNOWNBUILDER', status)
75+ self.assertTrue(
76+ info is not None, "UNKNOWNBUILDER returns 'None' info.")
77+ self.assertTrue(
78+ info.startswith("%s not in [" % buildername),
79+ 'UNKNOWNBUILDER info is "%s"' % info)
80+
81+
82 def test_suite():
83 return unittest.TestLoader().loadTestsFromName(__name__)