[CalendarServer-changes] [11522] CalendarServer/branches/users/cdaboo/CalendarServer-5.0-podfix/ twistedcaldav/directory/test/test_directory.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 17 10:34:30 PDT 2013
Revision: 11522
http://trac.calendarserver.org//changeset/11522
Author: sagen at apple.com
Date: 2013-07-17 10:34:30 -0700 (Wed, 17 Jul 2013)
Log Message:
-----------
Also backport the group cacher lock test
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/CalendarServer-5.0-podfix/twistedcaldav/directory/test/test_directory.py
Modified: CalendarServer/branches/users/cdaboo/CalendarServer-5.0-podfix/twistedcaldav/directory/test/test_directory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/CalendarServer-5.0-podfix/twistedcaldav/directory/test/test_directory.py 2013-07-17 17:27:32 UTC (rev 11521)
+++ CalendarServer/branches/users/cdaboo/CalendarServer-5.0-podfix/twistedcaldav/directory/test/test_directory.py 2013-07-17 17:34:30 UTC (rev 11522)
@@ -239,6 +239,18 @@
)
)
+ # Prevent an update by locking the cache
+ acquiredLock = (yield cache.acquireLock())
+ self.assertTrue(acquiredLock)
+ self.assertEquals((False, 0), (yield updater.updateCache()))
+
+ # You can't lock when already locked:
+ acquiredLockAgain = (yield cache.acquireLock())
+ self.assertFalse(acquiredLockAgain)
+
+ # Allow an update by unlocking the cache
+ yield cache.releaseLock()
+
self.assertEquals((False, 9, 9), (yield updater.updateCache()))
# Verify cache is populated:
@@ -635,6 +647,10 @@
# time), but since the snapshot doesn't exist we fault in from the
# directory (fast now is False), and snapshot will get created
+ # Note that because fast=True and isPopulated() is False, locking is
+ # ignored:
+ yield cache.acquireLock()
+
self.assertFalse((yield cache.isPopulated()))
fast, numMembers, numChanged = (yield updater.updateCache(fast=True))
self.assertEquals(fast, False)
@@ -643,6 +659,8 @@
self.assertTrue(snapshotFile.exists())
self.assertTrue((yield cache.isPopulated()))
+ yield cache.releaseLock()
+
# Try another fast update where the snapshot already exists (as in a
# server-restart scenario), which will only read from the snapshot
# as indicated by the return value for "fast". Note that the cache
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130717/469bcb64/attachment.html>
More information about the calendarserver-changes
mailing list