[CalendarServer-changes] [9963] CalendarServer/branches/users/glyph/always-abort-txn-on-error
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 22 16:09:16 PDT 2012
Revision: 9963
http://trac.calendarserver.org//changeset/9963
Author: glyph at apple.com
Date: 2012-10-22 16:09:16 -0700 (Mon, 22 Oct 2012)
Log Message:
-----------
Test for behavior when aborting the outer transaction.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/test/test_sql.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/always-abort-txn-on-error/
Modified: CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/test/test_sql.py 2012-10-22 23:09:15 UTC (rev 9962)
+++ CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/test/test_sql.py 2012-10-22 23:09:16 UTC (rev 9963)
@@ -24,6 +24,7 @@
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.task import Clock
from twisted.trial.unittest import TestCase
+from twisted.internet.defer import Deferred
from txdav.common.datastore.sql import log, CommonStoreTransactionMonitor,\
CommonHome, CommonHomeChild, ECALENDARTYPE
@@ -227,7 +228,8 @@
@inlineCallbacks
def test_subtransactionFailSomeRetries(self):
"""
- txn.subtransaction runs loop three times when all fail and two retries requested.
+ txn.subtransaction runs loop three times when all fail and two retries
+ requested.
"""
txn = self.transactionUnderTest()
@@ -251,7 +253,35 @@
self.fail("AllRetriesFailed not raised")
self.assertEqual(ctr[0], 3)
+
@inlineCallbacks
+ def test_subtransactionAbortOuterTransaction(self):
+ """
+ If an outer transaction that is holding a subtransaction open is
+ aborted, then the L{Deferred} returned by L{subtransaction} raises
+ L{AllRetriesFailed}.
+ """
+ txn = self.transactionUnderTest()
+ cs = schema.CALENDARSERVER
+ waitAMoment = Deferred()
+ @inlineCallbacks
+ def later(subtxn):
+ yield waitAMoment
+ value = yield Select([cs.VALUE], From=cs).on(subtxn)
+ returnValue(value)
+ started = txn.subtransaction(later)
+ txn.abort()
+ waitAMoment.callback(True)
+ try:
+ result = yield started
+ except AllRetriesFailed:
+ pass
+ else:
+ self.fail("AllRetriesFailed not raised, %r returned instead" %
+ (result,))
+
+
+ @inlineCallbacks
def test_changeRevision(self):
"""
CommonHomeChild._changeRevision actions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121022/ec882770/attachment-0001.html>
More information about the calendarserver-changes
mailing list