From: Brian Warner Date: Thu, 9 Aug 2007 19:53:44 +0000 (-0700) Subject: introducer: don't log.err() an initial connection failure, since that flunks tests... X-Git-Tag: allmydata-tahoe-0.5.0~97 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri//%22%22?a=commitdiff_plain;h=9ac5c1403757ef45977cd03954a4ac25ddd1d073;p=tahoe-lafs%2Ftahoe-lafs.git introducer: don't log.err() an initial connection failure, since that flunks tests. Use self.log() instead. Also improve test_client.py to always trigger this case, before it was finishing to quickly to always hit the problem. --- diff --git a/src/allmydata/introducer.py b/src/allmydata/introducer.py index c7618867..4d2f088f 100644 --- a/src/allmydata/introducer.py +++ b/src/allmydata/introducer.py @@ -59,8 +59,9 @@ class IntroducerClient(service.Service, Referenceable): self.introducer_reconnector = self.tub.connectTo(self.introducer_furl, self._got_introducer) def connect_failed(failure): - self.log("\n\nInitial Introducer connection failed: perhaps it's down\n") - log.err(failure) + self.log("\n\nInitial Introducer connection failed: " + "perhaps it's down\n") + self.log(str(failure)) d = self.tub.getReference(self.introducer_furl) d.addErrback(connect_failed) diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index f55980ec..016be9bd 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -2,6 +2,7 @@ import os from twisted.trial import unittest from twisted.application import service +from twisted.internet import reactor, defer import allmydata from allmydata import client, introducer @@ -133,6 +134,11 @@ class Run(unittest.TestCase): open(os.path.join(basedir, "suicide_prevention_hotline"), "w") c = client.Client(basedir) + def stall(self, res=None, delay=1): + d = defer.Deferred() + reactor.callLater(delay, d.callback, res) + return d + def test_reloadable(self): basedir = "test_client.Run.test_reloadable" os.mkdir(basedir) @@ -141,7 +147,8 @@ class Run(unittest.TestCase): c1 = client.Client(basedir) c1.setServiceParent(self.sparent) - d = c1.disownServiceParent() + d = self.stall(delay=0.1) + d.addCallback(lambda res: c1.disownServiceParent()) def _restart(res): c2 = client.Client(basedir) c2.setServiceParent(self.sparent)