From 7dc8ff02633e1a7a7f7331c332baae99e61d47bc Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 6 Jul 2008 23:49:08 -0700 Subject: [PATCH] re-enable incident-reporting, but disable it in unit tests, because they take 150% longer, and the leftover trailing timers cause errors --- src/allmydata/node.py | 4 ++-- src/allmydata/test/__init__.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) 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() -- 2.45.2