]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
tests: clean up tearDown to use flushEventualQueue instead of hacking fixed-time...
authorBrian Warner <warner@allmydata.com>
Wed, 4 Apr 2007 23:09:13 +0000 (16:09 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 4 Apr 2007 23:09:13 +0000 (16:09 -0700)
src/allmydata/test/test_introducer.py
src/allmydata/test/test_queen.py
src/allmydata/test/test_system.py

index c1f78cdc23b4179b58815fc20e2f2528cd2efedf..a0da3e559422a26f7025b3b88c504c705161d723 100644 (file)
@@ -23,14 +23,12 @@ class TestIntroducer(unittest.TestCase):
         self.parent.startService()
     def tearDown(self):
         log.msg("TestIntroducer.tearDown")
-        d = defer.Deferred()
-        reactor.callLater(1.1, d.callback, None)
+        d = defer.succeed(None)
         d.addCallback(lambda res: self.parent.stopService())
         d.addCallback(flushEventualQueue)
         return d
 
 
-
     def poll(self, check_f, pollinterval=0.01):
         # Return a Deferred, then call check_f periodically until it returns
         # True, at which point the Deferred will fire.. If check_f raises an
index 0a242c4c75498b821a6291bb021eac3e85d58fc7..e60d4334d9f1fd7d3c4559215e3fad516cb01b73 100644 (file)
@@ -1,5 +1,6 @@
 
 from twisted.trial import unittest
+from foolscap.eventual import flushEventualQueue
 
 from allmydata import queen
 
@@ -8,5 +9,6 @@ class Basic(unittest.TestCase):
         q = queen.Queen()
         d = q.startService()
         d.addCallback(lambda res: q.stopService())
+        d.addCallback(flushEventualQueue)
         return d
 
index 67df54893f24efbb8ba54cbc7d0c2af5a5053ef0..c87ed5c1509b90bed0001ffe7d76cc1e12db42d0 100644 (file)
@@ -10,14 +10,6 @@ from twisted.python import log
 from twisted.web.client import getPage
 
 class SystemTest(unittest.TestCase):
-    # it takes a little while for a disconnected loopback TCP connection to
-    # be noticed by the other side. This is not directly visible to us, so we
-    # have to wait for time to pass rather than just waiting on a deferred.
-    # This is unfortunate, both because it arbitrarily slows down the test
-    # process, and because it is hard to predict what the minimum time
-    # necessary would be (on a slow or heavily loaded system, 100ms might not
-    # be enough).
-    DISCONNECT_DELAY = 0.1
 
     def setUp(self):
         self.sparent = service.MultiService()
@@ -25,12 +17,7 @@ class SystemTest(unittest.TestCase):
     def tearDown(self):
         log.msg("shutting down SystemTest services")
         d = self.sparent.stopService()
-        d.addCallback(lambda res: flushEventualQueue())
-        def _done(res):
-            d1 = defer.Deferred()
-            reactor.callLater(self.DISCONNECT_DELAY, d1.callback, None)
-            return d1
-        d.addCallback(_done)
+        d.addCallback(flushEventualQueue)
         return d
 
     def add_service(self, s):
@@ -109,11 +96,7 @@ class SystemTest(unittest.TestCase):
         d.addCallback(_check)
         def _shutdown_extra_node(res):
             if self.extra_node:
-                d1 = self.extra_node.stopService()
-                d2 = defer.Deferred()
-                reactor.callLater(self.DISCONNECT_DELAY, d2.callback, res)
-                d1.addCallback(lambda ignored: d2)
-                return d1
+                return self.extra_node.stopService()
             return res
         d.addBoth(_shutdown_extra_node)
         return d