launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10444
[Merge] lp:~benji/launchpad/bug-974617-tweak-and-diagnostics into lp:launchpad
Benji York has proposed merging lp:~benji/launchpad/bug-974617-tweak-and-diagnostics into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-974617-tweak-and-diagnostics/+merge/117427
This branch adds some additional debug information about the state of postgres and pgbouncer sockets when some particular tests fail.
--
https://code.launchpad.net/~benji/launchpad/bug-974617-tweak-and-diagnostics/+merge/117427
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-974617-tweak-and-diagnostics into lp:launchpad.
=== modified file 'lib/lp/services/webapp/tests/test_error.py'
--- lib/lp/services/webapp/tests/test_error.py 2012-07-03 19:14:24 +0000
+++ lib/lp/services/webapp/tests/test_error.py 2012-07-31 12:56:05 +0000
@@ -5,6 +5,7 @@
import httplib
+import socket
import time
import urllib2
@@ -12,6 +13,8 @@
DisconnectionError,
OperationalError,
)
+from testtools.content import Content
+from testtools.content_type import UTF8_TEXT
import transaction
from lp.services.webapp.error import (
@@ -67,7 +70,22 @@
else:
self.fail("We should have gotten an HTTP error")
- def retryConnection(self, url, retries=60):
+ def add_retry_failure_details(self, bouncer):
+ # This method (and its invocations) are to be removed when we have
+ # figured out what is causing bug 974617.
+
+ # First we figure out if pgbouncer is listening on the port it is
+ # supposed to be listening on. connect_ex returns 0 on success or an
+ # errno otherwise.
+ pg_port_status = str(socket.socket().connect_ex(('localhost', 5432)))
+ self.addDetail('postgres socket.connect_ex result',
+ Content(UTF8_TEXT, lambda: pg_port_status))
+ bouncer_port_status = str(
+ socket.socket().connect_ex(('localhost', bouncer.port)))
+ self.addDetail('pgbouncer socket.connect_ex result',
+ Content(UTF8_TEXT, lambda: bouncer_port_status))
+
+ def retryConnection(self, url, bouncer, retries=60):
"""Retry to connect to *url* for *retries* times.
Return the file-like object returned by *urllib2.urlopen(url)*.
@@ -81,6 +99,7 @@
raise
time.sleep(1)
else:
+ self.add_retry_failure_details(bouncer)
raise TimeoutException(
"Launchpad did not come up after {0} attempts."
.format(retries))
@@ -102,7 +121,7 @@
transaction.abort()
# Verify things are working initially.
url = 'http://launchpad.dev/'
- self.retryConnection(url)
+ self.retryConnection(url, bouncer)
# Now break the database, and we get an exception, along with
# our view.
bouncer.stop()
@@ -123,7 +142,7 @@
self.assertEqual(503, self.getHTTPError(url).code)
# When the database is available again, requests succeed.
bouncer.start()
- self.retryConnection(url)
+ self.retryConnection(url, bouncer)
def test_disconnectionerror_view(self):
request = LaunchpadTestRequest()
@@ -157,7 +176,7 @@
self.getHTTPError(url).code)
# When the database is available again, requests succeed.
bouncer.start()
- self.retryConnection(url)
+ self.retryConnection(url, bouncer)
def test_operationalerror_view(self):
request = LaunchpadTestRequest()
Follow ups