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.

This commit is contained in:
Brian Warner 2007-08-09 12:53:44 -07:00
parent 84d41adfcc
commit 9ac5c14037
2 changed files with 11 additions and 3 deletions

View File

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

View File

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