From 4e2070ca3d8bca288cbc2d96771a78c22a7ec031 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 12 Mar 2008 18:35:16 -0400 Subject: Add a working (though not yet complete) test for the LMTP runner. Refactor the TestableMaster class so that doctests don't need to do all the threading and event fiddling themselves. Hide all that in the test class. In bin/master, add the -r/--runner option to allow overriding the set of queue runners to start from the command line. This is much more convenient than fiddling the config file (which is still supported), and it allows us to start a subset of the runners from the TestableMaster class. Refactor the calculation of queue runner shortcut names into Configuration.add_qrunner(). This way, it's easy to share between bin/qrunner and bin/master. Use pkg_resource in bin/testall to create the test configuration file. We're still using mailman.__file__ as the target to os.walk() though, so this conversion isn't complete. In bin/testall, update to the new convention of putting .options and .arguments on the parser instance, so we only need to pass back one thing. In test_documentation.py, use config.verbosity instead of config.options.verbosity. Wind that through to bin/testall while we're at it. Update loginit.py so that defaults for all the logging options can be found in a [*] section. This is better than [DEFAULT] because the latter requires %-interpolation and still requires each sublogger to be specified explicitly. Now we just set values in the [*] section and have them apply to all loggers. Allow for passing bin/testall's -v and -e options to any subprocesses that get created, e.g. via the TestableMaster. Now testall will write a logging.cfg file with a [*] entry as appropriate. It's DEFAULT_DATABASE_URL now, not SQLALCHEMY_ENGINE_URL. StockDatabase._reset() requires that the store be rolled back before it's reset. Otherwise if there are outstanding transactions, the reset will fail with an OperationalError. Update the LMTPRunner. Have it return a 501 error if the message has defects. Most defective messages are spam. Make the LMTPRunner startable and stoppable. Just because it's asyncore based doesn't mean that's not possible . Enable the LMTP runner in tests. --- mailman/configuration.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'mailman/configuration.py') diff --git a/mailman/configuration.py b/mailman/configuration.py index 1f82c8304..83fadac5d 100644 --- a/mailman/configuration.py +++ b/mailman/configuration.py @@ -48,6 +48,7 @@ class Configuration(object): self.domains = {} # email host -> web host self._reverse = None self.qrunners = {} + self.qrunner_shortcuts = {} self.QFILE_SCHEMA_VERSION = Version.QFILE_SCHEMA_VERSION def load(self, filename=None): @@ -212,22 +213,34 @@ class Configuration(object): def add_qrunner(self, name, count=1): """Convenient interface for adding additional qrunners. - name is the qrunner name and it must not include the 'Runner' suffix. - E.g. 'HTTP' or 'LMTP'. count is the number of qrunner slices to - create, by default, 1. + :param name: the qrunner name, which must not include the 'Runner' + suffix. E.g. 'HTTP' or 'LMTP'. + :param count: is the number of qrunner slices to create, default: 1. """ if name.startswith('.'): name = 'mailman.queue' + name self.qrunners[name] = count + # Calculate the queue runner shortcut name. + classname = name.rsplit('.', 1)[1] + if classname.endswith('Runner'): + shortname = classname[:-6].lower() + else: + shortname = classname + self.qrunner_shortcuts[shortname] = name def del_qrunner(self, name): """Remove the named qrunner so that it does not start. - name is the qrunner name and it must not include the 'Runner' suffix. + :param name: the qrunner name, which must not include the 'Runner' + suffix. """ if name.startswith('.'): name = 'mailman.queue' + name self.qrunners.pop(name) + for shortname, classname in self.qrunner_shortcuts: + if name == classname: + del self.qrunner_shortcuts[shortname] + break @property def paths(self): -- cgit v1.2.3-70-g09d2