launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07679
[Merge] lp:~benji/launchpad/bug-974617 into lp:launchpad
Benji York has proposed merging lp:~benji/launchpad/bug-974617 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #974617 in Launchpad itself: "test_operationalerror_view_integration fails intermittently in parallel tests"
https://bugs.launchpad.net/launchpad/+bug/974617
For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-974617/+merge/105130
This branch tweaks the code that waits for pgboucer to start for tests to wait for a usable socket to open, not the process itself to have been started. The race between the process starting and it being usable is biting us in tests.
--
https://code.launchpad.net/~benji/launchpad/bug-974617/+merge/105130
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-974617 into lp:launchpad.
=== modified file 'lib/lp/testing/fixture.py'
--- lib/lp/testing/fixture.py 2012-04-24 18:00:00 +0000
+++ lib/lp/testing/fixture.py 2012-05-08 21:10:32 +0000
@@ -17,6 +17,7 @@
from ConfigParser import SafeConfigParser
import os.path
+import socket
import time
import amqplib.client_0_8 as amqp
@@ -128,14 +129,22 @@
reconnect_stores()
def start(self, retries=20, sleep=0.5):
- """Simply return to simulate an error starting PGBouncer."""
+ """Start PGBouncer, waiting for it to accept connections if neccesary.
+ """
super(PGBouncerFixture, self).start()
- for i in itertools.count(1):
- if self.is_running:
- return
- if i == retries:
- raise PGNotReadyError("Not ready after %d attempts." % i)
+ s = socket.socket()
+ for i in xrange(retries):
+ try:
+ socket.create_connection((self.host, self.port))
+ except socket.error:
+ # Try again.
+ pass
+ else:
+ break
time.sleep(sleep)
+ else:
+ raise PGNotReadyError("Not ready after %d attempts." % retries)
+
class ZopeAdapterFixture(Fixture):
Follow ups