Ejemplo n.º 1
0
 def test_doublestop(self):
     tub = GoodEnoughTub()
     tub.startService()
     d = tub.stopService()
     d.addCallback(lambda res: self.shouldFail(
         RuntimeError, "test_doublestop_startService",
         "Sorry, but Tubs cannot be restarted", tub.startService))
     d.addCallback(lambda res: self.shouldFail(
         RuntimeError, "test_doublestop_getReference",
         "Sorry, but this Tub has been shut down", tub.getReference, "furl")
                   )
     d.addCallback(lambda res: self.shouldFail(
         RuntimeError, "test_doublestop_connectTo",
         "Sorry, but this Tub has been shut down", tub.connectTo, "furl",
         None))
     return d
Ejemplo n.º 2
0
 def test_doublestop(self):
     tub = GoodEnoughTub()
     tub.startService()
     d = tub.stopService()
     d.addCallback(lambda res:
                   self.shouldFail(RuntimeError,
                                   "test_doublestop_startService",
                                   "Sorry, but Tubs cannot be restarted",
                                   tub.startService))
     d.addCallback(lambda res:
                   self.shouldFail(RuntimeError,
                                   "test_doublestop_getReference",
                                   "Sorry, but this Tub has been shut down",
                                   tub.getReference, "furl"))
     d.addCallback(lambda res:
                   self.shouldFail(RuntimeError,
                                   "test_doublestop_connectTo",
                                   "Sorry, but this Tub has been shut down",
                                   tub.connectTo, "furl", None))
     return d
Ejemplo n.º 3
0
class CancelPendingDeliveries(unittest.TestCase, StallMixin):
    def tearDown(self):
        dl = [defer.succeed(None)]
        if self.tubA.running:
            dl.append(defer.maybeDeferred(self.tubA.stopService))
        if self.tubB.running:
            dl.append(defer.maybeDeferred(self.tubB.stopService))
        d = defer.DeferredList(dl)
        d.addCallback(flushEventualQueue)
        return d

    def test_cancel_pending_deliveries(self):
        # when a Tub is stopped, any deliveries that were pending should be
        # discarded. TubA sends remote_one+remote_two (and we hope they
        # arrive in the same chunk). TubB responds to remote_one by shutting
        # down. remote_two should be discarded. The bug was that remote_two
        # would cause an unhandled error on the TubB side.
        self.tubA = GoodEnoughTub()
        self.tubB = GoodEnoughTub()
        self.tubA.startService()
        self.tubB.startService()

        self.tubB.listenOn("tcp:0")
        d = self.tubB.setLocationAutomatically()
        r = Receiver(self.tubB)
        d.addCallback(lambda res: self.tubB.registerReference(r))
        d.addCallback(lambda furl: self.tubA.getReference(furl))

        def _go(rref):
            # we want these two to get sent and received in the same hunk
            rref.callRemoteOnly("one")
            rref.callRemoteOnly("two")
            return r.done_d

        d.addCallback(_go)
        # let remote_two do its log.err before we move on to the next test
        d.addCallback(self.stall, 1.0)
        return d
Ejemplo n.º 4
0
class CancelPendingDeliveries(unittest.TestCase, StallMixin):
    def tearDown(self):
        dl = [defer.succeed(None)]
        if self.tubA.running:
            dl.append(defer.maybeDeferred(self.tubA.stopService))
        if self.tubB.running:
            dl.append(defer.maybeDeferred(self.tubB.stopService))
        d = defer.DeferredList(dl)
        d.addCallback(flushEventualQueue)
        return d

    def test_cancel_pending_deliveries(self):
        # when a Tub is stopped, any deliveries that were pending should be
        # discarded. TubA sends remote_one+remote_two (and we hope they
        # arrive in the same chunk). TubB responds to remote_one by shutting
        # down. remote_two should be discarded. The bug was that remote_two
        # would cause an unhandled error on the TubB side.
        self.tubA = GoodEnoughTub()
        self.tubB = GoodEnoughTub()
        self.tubA.startService()
        self.tubB.startService()

        self.tubB.listenOn("tcp:0")
        d = self.tubB.setLocationAutomatically()
        r = Receiver(self.tubB)
        d.addCallback(lambda res: self.tubB.registerReference(r))
        d.addCallback(lambda furl: self.tubA.getReference(furl))
        def _go(rref):
            # we want these two to get sent and received in the same hunk
            rref.callRemoteOnly("one")
            rref.callRemoteOnly("two")
            return r.done_d
        d.addCallback(_go)
        # let remote_two do its log.err before we move on to the next test
        d.addCallback(self.stall, 1.0)
        return d