re-enable incident-reporting, but disable it in unit tests, because they take 150% longer, and the leftover trailing timers cause errors

This commit is contained in:
Brian Warner 2008-07-06 23:49:08 -07:00
parent 13d0ba72a4
commit 7dc8ff0263
2 changed files with 28 additions and 2 deletions

View File

@ -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)

View File

@ -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()