[CalendarServer-changes] [6833] CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/ test/test_adbapi2.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 28 17:40:46 PST 2011


Revision: 6833
          http://trac.macosforge.org/projects/calendarserver/changeset/6833
Author:   glyph at apple.com
Date:     2011-01-28 17:40:46 -0800 (Fri, 28 Jan 2011)
Log Message:
-----------
Oh, okay, this already works.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py

Modified: CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py	2011-01-29 01:40:36 UTC (rev 6832)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py	2011-01-29 01:40:46 UTC (rev 6833)
@@ -256,9 +256,18 @@
         self.pool._createHolder = self.makeAHolder
         self.clock = self.pool.reactor = Clock()
         self.pool.startService()
-        self.addCleanup(self.pool.stopService)
 
 
+    @inlineCallbacks
+    def tearDown(self):
+        """
+        Make sure the service is stopped and the fake ThreadHolders are all
+        executing their queues so failed tests can exit cleanly.
+        """
+        self.flushHolders()
+        yield self.pool.stopService()
+
+
     def flushHolders(self):
         """
         Flush all pending C{submit}s since C{pauseHolders} was called.
@@ -393,7 +402,7 @@
         """
         If L{ConnectionPool.stopService} is called while a connection attempt is
         outstanding, the resulting L{Deferred} won't be fired until the
-        connection attempt has succeeded.
+        connection attempt has finished; in this case, succeeded.
         """
         self.pauseHolders()
         self.pool.connection()
@@ -408,3 +417,25 @@
         # FIXME: next, 'failed' case.
 
 
+    def test_shutdownDuringAttemptFailed(self):
+        """
+        If L{ConnectionPool.stopService} is called while a connection attempt is
+        outstanding, the resulting L{Deferred} won't be fired until the
+        connection attempt has finished; in this case, failed.
+        """
+        self.factory.defaultFail()
+        self.pauseHolders()
+        self.pool.connection()
+        stopd = []
+        self.pool.stopService().addBoth(stopd.append)
+        self.assertEquals(stopd, [])
+        self.flushHolders()
+        errors = self.flushLoggedErrors(FakeConnectionError)
+        self.assertEquals(len(errors), 1)
+        self.assertEquals(stopd, [None])
+        [holder] = self.holders
+        self.assertEquals(holder.started, True)
+        self.assertEquals(holder.stopped, True)
+        # FIXME: next, 'failed' case.
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110128/6d27c5ad/attachment.html>


More information about the calendarserver-changes mailing list