Rev 5505: Fix http test spurious failures and get rid of some useless messages in log. in file:///home/vila/src/bzr/bugs/655557-cleanup-http-pipe/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Oct 18 11:01:47 BST 2010


At file:///home/vila/src/bzr/bugs/655557-cleanup-http-pipe/

------------------------------------------------------------
revno: 5505
revision-id: v.ladeuil+lp at free.fr-20101018100147-kk6xf7b5l0quy2ua
parent: pqm at pqm.ubuntu.com-20101015164148-k10lo687r72nzbtl
fixes bug(s): https://launchpad.net/bugs/655557
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 655557-cleanup-http-pipe
timestamp: Mon 2010-10-18 12:01:47 +0200
message:
  Fix http test spurious failures and get rid of some useless messages in log.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2010-10-12 07:24:46 +0000
+++ b/bzrlib/tests/test_http.py	2010-10-18 10:01:47 +0000
@@ -961,7 +961,7 @@
                 return
             self.send_range_content(file, start, end - start + 1)
             cur += 1
-        # No final boundary
+        # Final boundary
         self.wfile.write(boundary_line)
 
 
@@ -996,6 +996,7 @@
         # that mode
         self.assertEqual('single', t._range_hint)
 
+
 class LimitedRangeRequestHandler(http_server.TestingHTTPRequestHandler):
     """Errors out when range specifiers exceed the limit"""
 

=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py	2010-10-12 07:24:46 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py	2010-10-18 10:01:47 +0000
@@ -165,7 +165,7 @@
     """
 
     # Some responses have bodies in which we have no interest
-    _body_ignored_responses = [301,302, 303, 307, 401, 403, 404]
+    _body_ignored_responses = [301,302, 303, 307, 400, 401, 403, 404, 501]
 
     # in finish() below, we may have to discard several MB in the worst
     # case. To avoid buffering that much, we read and discard by chunks
@@ -266,17 +266,27 @@
     def cleanup_pipe(self):
         """Read the remaining bytes of the last response if any."""
         if self._response is not None:
-            pending = self._response.finish()
-            # Warn the user (once)
-            if (self._ranges_received_whole_file is None
-                and self._response.status == 200
-                and pending and pending > self._range_warning_thresold
-                ):
-                self._ranges_received_whole_file = True
-                trace.warning(
-                    'Got a 200 response when asking for multiple ranges,'
-                    ' does your server at %s:%s support range requests?',
-                    self.host, self.port)
+            try:
+                pending = self._response.finish()
+                # Warn the user (once)
+                if (self._ranges_received_whole_file is None
+                    and self._response.status == 200
+                    and pending and pending > self._range_warning_thresold
+                    ):
+                    self._ranges_received_whole_file = True
+                    trace.warning(
+                        'Got a 200 response when asking for multiple ranges,'
+                        ' does your server at %s:%s support range requests?',
+                        self.host, self.port)
+            except socket.error, e:
+                # It's conceivable that the socket is in a bad state here
+                # (including some test cases) and in this case, it doesn't need
+                # cleaning anymore, so no need to fail, we just get rid of the
+                # socket and let callers reconnect
+                if (len(e.args) == 0
+                    or e.args[0] not in (errno.ECONNRESET, errno.ECONNABORTED)):
+                    raise
+                self.close()
             self._response = None
         # Preserve our preciousss
         sock = self.sock

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2010-10-15 15:05:09 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-10-18 10:01:47 +0000
@@ -89,6 +89,10 @@
 * ``bzr test-script script`` is a new command that runs a shell-like script
   from an the ``script`` file. (Vincent Ladeuil)
 
+* Fix spurious test failures on babune related to the http pipe cleanup and
+  get rid of some 'bytes left on the HTTP socket' useless log messhes.
+  (Vincent Ladeuil, #655557)
+
 
 bzr 2.3b2
 #########



More information about the bazaar-commits mailing list