summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/config/schema.cfg5
-rw-r--r--src/mailman/testing/helpers.py25
-rw-r--r--src/mailman/testing/layers.py3
3 files changed, 21 insertions, 12 deletions
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index 53d7d42e0..f9f2df03d 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -134,6 +134,11 @@ recipient:
# predictable dates and times.
testing: no
+# Time-outs for starting up various test subprocesses, such as the LMTP and
+# REST servers. This is only used for the test suite, so if you're seeing
+# test failures, try increasing the wait time.
+wait: 10s
+
[passwords]
# The default scheme to use to encrypt new passwords. Existing passwords
diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py
index 74e00b501..71cddd0f4 100644
--- a/src/mailman/testing/helpers.py
+++ b/src/mailman/testing/helpers.py
@@ -47,6 +47,7 @@ from base64 import b64encode
from contextlib import contextmanager
from email import message_from_string
from httplib2 import Http
+from lazr.config import as_timedelta
from urllib import urlencode
from urllib2 import HTTPError
from zope import event
@@ -61,9 +62,6 @@ from mailman.interfaces.usermanager import IUserManager
from mailman.utilities.mailbox import Mailbox
-STARTUP_WAIT = datetime.timedelta(seconds=5)
-
-
def make_testable_runner(runner_class, name=None):
"""Create a queue runner that runs until its queue is empty.
@@ -221,16 +219,16 @@ def get_lmtp_client():
# It's possible the process has started but is not yet accepting
# connections. Wait a little while.
lmtp = LMTP()
- until = datetime.datetime.now() + STARTUP_WAIT
+ until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
while datetime.datetime.now() < until:
try:
response = lmtp.connect(
config.mta.lmtp_host, int(config.mta.lmtp_port))
print response
return lmtp
- except socket.error, error:
+ except socket.error as error:
if error[0] == errno.ECONNREFUSED:
- time.sleep(0.5)
+ time.sleep(0.1)
else:
raise
else:
@@ -240,15 +238,20 @@ def get_lmtp_client():
def wait_for_webservice():
"""Wait for the REST server to start serving requests."""
- # Time out after approximately 3 seconds.
- for count in range(30):
+ until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
+ while datetime.datetime.now() < until:
try:
socket.socket().connect((config.webservice.hostname,
- int(config.webservice.port)))
- except socket.error:
- time.sleep(0.1)
+ int(config.webservice.port)))
+ except socket.error as error:
+ if error[0] == errno.ECONNREFUSED:
+ time.sleep(0.1)
+ else:
+ raise
else:
break
+ else:
+ raise RuntimeError('Connection refused')
def call_api(url, data=None, method=None, username=None, password=None):
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py
index 29ab7169a..38d4c7f02 100644
--- a/src/mailman/testing/layers.py
+++ b/src/mailman/testing/layers.py
@@ -37,6 +37,7 @@ import datetime
import tempfile
from base64 import b64encode
+from lazr.config import as_timedelta
from pkg_resources import resource_string
from textwrap import dedent
from urllib2 import Request, URLError, urlopen
@@ -265,7 +266,7 @@ class RESTLayer(SMTPLayer):
@staticmethod
def _wait_for_rest_server():
- until = datetime.datetime.now() + TEST_TIMEOUT
+ until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
while datetime.datetime.now() < until:
try:
request = Request('http://localhost:9001/3.0/system')