Rev 2668: (Andrew Bennetts) Log errors from the smart server in the trace file, to make debugging test failures (and live failures!) easier. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Aug 2 08:22:07 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2668
revision-id: pqm at pqm.ubuntu.com-20070802072205-gjk1eev6rlw7ght8
parent: pqm at pqm.ubuntu.com-20070802063321-lpx3oazcxyac24oa
parent: andrew.bennetts at canonical.com-20070802064244-9ykz37n3av60d6d9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-08-02 08:22:05 +0100
message:
  (Andrew Bennetts) Log errors from the smart server in the trace file, to make debugging test failures (and live failures!) easier.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
  bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
    ------------------------------------------------------------
    revno: 2621.3.3
    merged: andrew.bennetts at canonical.com-20070802064244-9ykz37n3av60d6d9
    parent: andrew.bennetts at canonical.com-20070802064058-09eblz1qbc01fcr3
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-server-logging
    timestamp: Thu 2007-08-02 16:42:44 +1000
    message:
      Add NEWS entry.
    ------------------------------------------------------------
    revno: 2621.3.2
    merged: andrew.bennetts at canonical.com-20070802064058-09eblz1qbc01fcr3
    parent: andrew.bennetts at canonical.com-20070717065701-uq95aym0vtp7xykb
    parent: pqm at pqm.ubuntu.com-20070801171451-en3tds1hzlru2j83
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-server-logging
    timestamp: Thu 2007-08-02 16:40:58 +1000
    message:
      Merge bzr.dev.
    ------------------------------------------------------------
    revno: 2621.3.1
    merged: andrew.bennetts at canonical.com-20070717065701-uq95aym0vtp7xykb
    parent: pqm at pqm.ubuntu.com-20070716205413-42lqws7bkld2gbju
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-server-logging
    timestamp: Tue 2007-07-17 16:57:01 +1000
    message:
      Log errors from the smart server in the trace file, to make debugging test failures (and live failures!) easier.
=== modified file 'NEWS'
--- a/NEWS	2007-08-02 06:33:21 +0000
+++ b/NEWS	2007-08-02 07:22:05 +0000
@@ -106,6 +106,9 @@
     * Fix ``bzr update`` to avoid an unnecessary
       ``branch.get_master_branch`` call, which avoids 1 extra connection
       to the remote server. (Partial fix for #128076, John Arbash Meinel)
+
+    * Log errors from the smart server in the trace file, to make debugging 
+      test failures (and live failures!) easier.  (Andrew Bennetts)
       
 
   LIBRARY API BREAKS:

=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py	2007-07-27 19:41:03 +0000
+++ b/bzrlib/smart/protocol.py	2007-08-02 06:40:58 +0000
@@ -24,7 +24,7 @@
 from bzrlib import debug
 from bzrlib import errors
 from bzrlib.smart import request
-from bzrlib.trace import mutter
+from bzrlib.trace import log_exception_quietly, mutter
 
 
 # Protocol version strings.  These are sent as prefixes of bzr requests and
@@ -110,6 +110,7 @@
                 raise
             except Exception, exception:
                 # everything else: pass to client, flush, and quit
+                log_exception_quietly()
                 self._send_response(request.FailedSmartServerResponse(
                     ('error', str(exception))))
                 return

=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py	2007-04-26 07:48:05 +0000
+++ b/bzrlib/tests/test_smart.py	2007-07-17 06:57:01 +0000
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-"""Tests for the smart wire/domain protococl."""
+"""Tests for the smart wire/domain protocol."""
 
 from StringIO import StringIO
 import tempfile

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2007-07-20 18:59:29 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2007-08-02 06:40:58 +0000
@@ -1343,7 +1343,20 @@
         self.assertEqual(expected_tuple, smart_protocol.read_response_tuple())
 
 
-class TestSmartProtocolOne(TestSmartProtocol):
+class CommonSmartProtocolTestMixin(object):
+
+    def test_errors_are_logged(self):
+        """If an error occurs during testing, it is logged to the test log."""
+        out_stream = StringIO()
+        smart_protocol = self.server_protocol_class(None, out_stream.write)
+        # This triggers a "bad request" error.
+        smart_protocol.accept_bytes('abc\n')
+        test_log = self._get_log(keep_log_file=True)
+        self.assertContainsRe(test_log, 'Traceback')
+        self.assertContainsRe(test_log, 'SmartProtocolError')
+
+
+class TestSmartProtocolOne(TestSmartProtocol, CommonSmartProtocolTestMixin):
     """Tests for the smart protocol version one."""
 
     client_protocol_class = protocol.SmartClientRequestProtocolOne
@@ -1564,7 +1577,7 @@
             errors.ReadingCompleted, smart_protocol.read_body_bytes)
 
 
-class TestSmartProtocolTwo(TestSmartProtocol):
+class TestSmartProtocolTwo(TestSmartProtocol, CommonSmartProtocolTestMixin):
     """Tests for the smart protocol version two.
 
     This test case is mostly the same as TestSmartProtocolOne.




More information about the bazaar-commits mailing list