From: Brian Warner Date: Mon, 7 Jul 2008 06:49:08 +0000 (-0700) Subject: re-enable incident-reporting, but disable it in unit tests, because they take 150... X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/index.php?a=commitdiff_plain;h=7dc8ff02633e1a7a7f7331c332baae99e61d47bc;p=tahoe-lafs%2Ftahoe-lafs.git re-enable incident-reporting, but disable it in unit tests, because they take 150% longer, and the leftover trailing timers cause errors --- diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 2dbf14c9..0757d587 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -6,7 +6,7 @@ from twisted.python import log as tahoe_log from twisted.application import service from twisted.internet import defer, reactor from foolscap import Tub, eventual -#import foolscap.logging.log +import foolscap.logging.log from allmydata import get_package_versions_string from allmydata.util import log from allmydata.util import fileutil, iputil, observer, humanreadable @@ -218,7 +218,7 @@ class Node(service.MultiService): self.tub.setOption("bridge-twisted-logs", True) incident_dir = os.path.join(self.basedir, "logs", "incidents") # this doesn't quite work yet: unit tests fail - #foolscap.logging.log.setLogDir(incident_dir) + foolscap.logging.log.setLogDir(incident_dir) def log(self, *args, **kwargs): return log.msg(*args, **kwargs) diff --git a/src/allmydata/test/__init__.py b/src/allmydata/test/__init__.py index e69de29b..3d106a69 100644 --- a/src/allmydata/test/__init__.py +++ b/src/allmydata/test/__init__.py @@ -0,0 +1,26 @@ + +from foolscap.logging.incident import IncidentQualifier +class NonQualifier(IncidentQualifier): + def check_event(self, ev): + return False + +def disable_foolscap_incidents(): + # Foolscap-0.2.9 (at least) uses "trailing delay" in its default incident + # reporter: after a severe log event is recorded (thus triggering an + # "incident" in which recent events are dumped to a file), a few seconds + # of subsequent events are also recorded in the incident file. The timer + # that this leaves running will cause "Unclean Reactor" unit test + # failures. The simplest workaround is to disable this timer. Note that + # this disables the timer for the entire process: do not call this from + # regular runtime code; only use it for unit tests that are running under + # Trial. + #IncidentReporter.TRAILING_DELAY = None + # + # Also, using Incidents more than doubles the test time. So we just + # disable them entirely. + from foolscap.logging.log import theLogger + iq = NonQualifier() + theLogger.setIncidentQualifier(iq) + +# we disable incident reporting for all unit tests. +disable_foolscap_incidents()