[CalendarServer-changes] [11520] CalendarServer/trunk/twistedcaldav/directory/test/test_directory.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 16 13:13:19 PDT 2013


Revision: 11520
          http://trac.calendarserver.org//changeset/11520
Author:   sagen at apple.com
Date:     2013-07-16 13:13:19 -0700 (Tue, 16 Jul 2013)
Log Message:
-----------
More testing of group cacher lock

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/test/test_directory.py

Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_directory.py	2013-07-16 03:08:34 UTC (rev 11519)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_directory.py	2013-07-16 20:13:19 UTC (rev 11520)
@@ -240,6 +240,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:
@@ -636,6 +648,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)
@@ -644,6 +660,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/20130716/cb010d25/attachment.html>


More information about the calendarserver-changes mailing list