Rev 5511: (vila) Fix spurious test failures related to the http pipe cleanup. (Vincent in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Oct 21 08:51:45 BST 2010


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

------------------------------------------------------------
revno: 5511 [merge]
revision-id: pqm at pqm.ubuntu.com-20101021075144-cnmt4hltdrl5yka0
parent: pqm at pqm.ubuntu.com-20101019191035-v1rj4gag5ba3cenn
parent: v.ladeuil+lp at free.fr-20101021065040-lis7zwc07olox97r
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-10-21 08:51:44 +0100
message:
  (vila) Fix spurious test failures related to the http pipe cleanup. (Vincent
   Ladeuil)
modified:
  bzrlib/tests/test_http.py      testhttp.py-20051018020158-b2eef6e867c514d9
  bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== 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-18 21:34:05 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-10-21 07:51:44 +0000
@@ -102,6 +102,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 messages.
+  (Vincent Ladeuil, #655557)
+
 
 bzr 2.3b2
 #########




More information about the bazaar-commits mailing list