summaryrefslogtreecommitdiff
path: root/src/mailman/testing
diff options
context:
space:
mode:
authorBarry Warsaw2013-06-17 09:36:43 -0400
committerBarry Warsaw2013-06-17 09:36:43 -0400
commit41059ed20ec668baf41cceaf539f8017171e9651 (patch)
tree391b33289ecb1d02905a897ed581ac9538531f10 /src/mailman/testing
parentbffd71903475efad53ce6aa59c96a704a905a984 (diff)
downloadmailman-41059ed20ec668baf41cceaf539f8017171e9651.tar.gz
mailman-41059ed20ec668baf41cceaf539f8017171e9651.tar.zst
mailman-41059ed20ec668baf41cceaf539f8017171e9651.zip
* `bin/runner` command has been simplified and its command line options
reduced. Now, only one `-r/--runner` option may be provided and the round-robin feature has been removed. * Fixed REST server crash on `reopen` command. Identification and test provided by Aurélien Bompard. (LP: #1184376) Also: * bin/runner now uses standard argparse instead of ScriptOptions. * The entire bin/runner machinery has bee reorganized and simplified. There * is no more Loop class. Signal setting is moved directly into the base Runner class and overrided in specific subclasses (e.g. RESTRunner which must cleanly shutdown its TCPServer). The runner exit status is now set directly on the Runner instance. * Fixed a few minor style issues. * In order to cleanly shutdown the RESTRunner's WSGI server, we must start a subthread which only watches for an Event and then calls the server's shutdown() method. It has to be this way because the WSGI server itself (due to interactions with SQLite), and the signal handlers (due to Python's signal handling semantics) must both run in the main thread. However, the shutdown() must be invoked from a subthread in order to prevent deadlock. * Refactor the RESTLayer to eliminate duplication of code.
Diffstat (limited to 'src/mailman/testing')
-rw-r--r--src/mailman/testing/layers.py27
1 files changed, 3 insertions, 24 deletions
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py
index bee116b6c..e47d5c9e0 100644
--- a/src/mailman/testing/layers.py
+++ b/src/mailman/testing/layers.py
@@ -45,11 +45,9 @@ import logging
import datetime
import tempfile
-from base64 import b64encode
-from lazr.config import as_boolean, as_timedelta
+from lazr.config import as_boolean
from pkg_resources import resource_string
from textwrap import dedent
-from urllib2 import Request, URLError, urlopen
from zope.component import getUtility
from mailman.config import config
@@ -59,7 +57,7 @@ from mailman.core.logging import get_handler
from mailman.database.transaction import transaction
from mailman.interfaces.domain import IDomainManager
from mailman.testing.helpers import (
- TestableMaster, get_lmtp_client, reset_the_world)
+ TestableMaster, get_lmtp_client, reset_the_world, wait_for_webservice)
from mailman.testing.mta import ConnectionCountingController
from mailman.utilities.string import expand
@@ -315,29 +313,10 @@ class RESTLayer(SMTPLayer):
server = None
- @staticmethod
- def _wait_for_rest_server():
- until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
- while datetime.datetime.now() < until:
- try:
- request = Request('http://localhost:9001/3.0/system')
- basic_auth = '{0}:{1}'.format(config.webservice.admin_user,
- config.webservice.admin_pass)
- request.add_header('Authorization',
- 'Basic ' + b64encode(basic_auth))
- fp = urlopen(request)
- except URLError:
- pass
- else:
- fp.close()
- break
- else:
- raise RuntimeError('REST server did not start up')
-
@classmethod
def setUp(cls):
assert cls.server is None, 'Layer already set up'
- cls.server = TestableMaster(cls._wait_for_rest_server)
+ cls.server = TestableMaster(wait_for_webservice)
cls.server.start('rest')
@classmethod