From 9ac5c1403757ef45977cd03954a4ac25ddd1d073 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 9 Aug 2007 12:53:44 -0700 Subject: [PATCH] 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. --- src/allmydata/introducer.py | 5 +++-- src/allmydata/test/test_client.py | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/allmydata/introducer.py b/src/allmydata/introducer.py index c7618867d..4d2f088f1 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 f55980ec1..016be9bde 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)