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

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 3 11:00:21 PST 2011


Revision: 6855
          http://trac.macosforge.org/projects/calendarserver/changeset/6855
Author:   glyph at apple.com
Date:     2011-02-03 11:00:19 -0800 (Thu, 03 Feb 2011)
Log Message:
-----------
test for stopping with a committed, spooled transaction

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-02-03 01:15:04 UTC (rev 6854)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py	2011-02-03 19:00:19 UTC (rev 6855)
@@ -26,6 +26,7 @@
 from twisted.internet.task import Clock
 
 from twisted.internet.defer import Deferred
+from twext.enterprise.ienterprise import ConnectionError
 from twext.enterprise.adbapi2 import ConnectionPool
 
 
@@ -481,4 +482,24 @@
         self.assertEquals(stopResult, [None])
 
 
+    def test_stopServiceWithSpooled(self):
+        """
+        When L{ConnectionPool.stopService} is called when spooled transactions
+        are outstanding, any pending L{Deferreds} returned by those transactions
+        will be failed with L{ConnectionError}.
+        """
+        # Use up the free slots so we have to spool.
+        hold = []
+        hold.append(self.pool.connection())
+        hold.append(self.pool.connection())
 
+        c = self.pool.connection()
+        se = resultOf(c.execSQL("alpha"))
+        ce = resultOf(c.commit())
+        self.assertEquals(se, [])
+        self.assertEquals(ce, [])
+        self.pool.stopService()
+        self.assertEquals(se[0].type, ConnectionError)
+        self.assertEquals(ce[0].type, ConnectionError)
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110203/94dc2d3d/attachment.html>


More information about the calendarserver-changes mailing list