[CalendarServer-changes] [3732] CalendarServer/branches/users/sagen/migration-3709/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 24 16:28:10 PST 2009
Revision: 3732
http://trac.macosforge.org/projects/calendarserver/changeset/3732
Author: sagen at apple.com
Date: 2009-02-24 16:28:10 -0800 (Tue, 24 Feb 2009)
Log Message:
-----------
More migration tests, including verification that directories and xattrs have been removed
Modified Paths:
--------------
CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/test_upgrade.py
CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/util.py
CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/upgrade.py
Modified: CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/test_upgrade.py 2009-02-24 23:43:44 UTC (rev 3731)
+++ CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/test_upgrade.py 2009-02-25 00:28:10 UTC (rev 3732)
@@ -26,6 +26,11 @@
import os, zlib, cPickle
+freeBusyAttr = "WebDAV:{urn:ietf:params:xml:ns:caldav}calendar-free-busy-set"
+cTagAttr = "WebDAV:{http:%2F%2Fcalendarserver.org%2Fns%2F}getctag"
+md5Attr = "WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2F}getcontentmd5"
+
+
class ProxyDBUpgradeTests(TestCase):
def setUpXMLDirectory(self):
@@ -259,13 +264,16 @@
value = "<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/users/nonexistent/calendar</href>\r\n</calendar-free-busy-set>\r\n"
self.assertRaises(UpgradeError, updateFreeBusySet, value, directory)
- def test_calendarsUpgrade(self):
+ def test_calendarsUpgradeWithUsers(self):
+ """
+ Verify that calendar homes in the /calendars/users/<shortname>/ form
+ are upgraded to /calendars/__uids__/XX/YY/<guid> form
+ """
+
self.setUpXMLDirectory()
directory = getDirectory()
- fbAttr = "WebDAV:{urn:ietf:params:xml:ns:caldav}calendar-free-busy-set"
-
before = {
"calendars" :
{
@@ -278,18 +286,33 @@
"1E238CA1-3C95-4468-B8CD-C8A399F78C72.ics" :
{
"@contents" : event01_before,
+ "@xattrs" :
+ {
+ md5Attr : "12345",
+ },
},
+ "@xattrs" :
+ {
+ cTagAttr : "12345",
+ },
},
"inbox" :
{
"@xattrs" :
{
- fbAttr : cPickle.dumps(davxml.WebDAVDocument.fromString("<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/users/wsanchez/calendar</href>\r\n</calendar-free-busy-set>\r\n").root_element),
+ freeBusyAttr : cPickle.dumps(davxml.WebDAVDocument.fromString("<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/users/wsanchez/calendar</href>\r\n</calendar-free-busy-set>\r\n").root_element),
},
},
},
},
},
+ "principals" :
+ {
+ CalendarUserProxyDatabase.dbOldFilename :
+ {
+ "@contents" : "",
+ }
+ }
}
after = {
@@ -312,13 +335,21 @@
"1E238CA1-3C95-4468-B8CD-C8A399F78C72.ics" :
{
"@contents" : event01_after,
+ "@xattrs" :
+ {
+ # no md5 attr
+ },
},
+ "@xattrs" :
+ {
+ # no CTAG
+ },
},
"inbox" :
{
"@xattrs" :
{
- fbAttr : zlib.compress("<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar/</href>\r\n</calendar-free-busy-set>\r\n"),
+ freeBusyAttr : zlib.compress("<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar/</href>\r\n</calendar-free-busy-set>\r\n"),
},
},
},
@@ -326,6 +357,10 @@
},
},
},
+ CalendarUserProxyDatabase.dbFilename :
+ {
+ "@contents" : "",
+ }
}
root = self.createHierarchy(before)
@@ -334,9 +369,108 @@
config.DataRoot = root
upgradeData(config)
- self.assertTrue(self.compareHierarchy(root, after))
+ self.assertTrue(self.verifyHierarchy(root, after))
+ # Ensure that repeating the process doesn't change anything
+ upgradeData(config)
+ self.assertTrue(self.verifyHierarchy(root, after))
+ def test_calendarsUpgradeWithUIDs(self):
+ """
+ Verify that calendar homes in the /calendars/__uids__/<guid>/ form
+ are upgraded to /calendars/__uids__/XX/YY/<guid>/ form
+ """
+
+ self.setUpXMLDirectory()
+ directory = getDirectory()
+
+
+ before = {
+ "calendars" :
+ {
+ "__uids__" :
+ {
+ "6423F94A-6B76-4A3A-815B-D52CFD77935D" :
+ {
+ "calendar" :
+ {
+ "1E238CA1-3C95-4468-B8CD-C8A399F78C72.ics" :
+ {
+ "@contents" : event01_before,
+ },
+ },
+ "inbox" :
+ {
+ "@xattrs" :
+ {
+ freeBusyAttr : cPickle.dumps(davxml.WebDAVDocument.fromString("<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/users/wsanchez/calendar</href>\r\n</calendar-free-busy-set>\r\n").root_element),
+ },
+ },
+ },
+ },
+ },
+ "principals" :
+ {
+ CalendarUserProxyDatabase.dbOldFilename :
+ {
+ "@contents" : "",
+ }
+ }
+ }
+
+ after = {
+ ".calendarserver_version" :
+ {
+ "@contents" : "1",
+ },
+ "calendars" :
+ {
+ "__uids__" :
+ {
+ "64" :
+ {
+ "23" :
+ {
+ "6423F94A-6B76-4A3A-815B-D52CFD77935D" :
+ {
+ "calendar" :
+ {
+ "1E238CA1-3C95-4468-B8CD-C8A399F78C72.ics" :
+ {
+ "@contents" : event01_after,
+ },
+ },
+ "inbox" :
+ {
+ "@xattrs" :
+ {
+ freeBusyAttr : zlib.compress("<?xml version='1.0' encoding='UTF-8'?>\r\n<calendar-free-busy-set xmlns='urn:ietf:params:xml:ns:caldav'>\r\n <href xmlns='DAV:'>/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar/</href>\r\n</calendar-free-busy-set>\r\n"),
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ CalendarUserProxyDatabase.dbFilename :
+ {
+ "@contents" : "",
+ }
+ }
+
+ root = self.createHierarchy(before)
+
+ config.DocumentRoot = root
+ config.DataRoot = root
+
+ upgradeData(config)
+ self.assertTrue(self.verifyHierarchy(root, after))
+
+ # Ensure that repeating the process doesn't change anything
+ upgradeData(config)
+ self.assertTrue(self.verifyHierarchy(root, after))
+
+
event01_before = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 3.0//EN
Modified: CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/util.py 2009-02-24 23:43:44 UTC (rev 3731)
+++ CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/test/util.py 2009-02-25 00:28:10 UTC (rev 3732)
@@ -70,15 +70,20 @@
createChildren(root, structure)
return root
- def compareHierarchy(self, root, structure):
+ def verifyHierarchy(self, root, structure):
- def compareChildren(parent, subStructure):
+ def verifyChildren(parent, subStructure):
+ actual = set([child for child in os.listdir(parent)])
+
for childName, childStructure in subStructure.iteritems():
if childName.startswith("@"):
continue
+ if childName in actual:
+ actual.remove(childName)
+
childPath = os.path.join(parent, childName)
if not os.path.exists(childPath):
@@ -93,7 +98,7 @@
else:
# This is a directory
- if not compareChildren(childPath, childStructure):
+ if not verifyChildren(childPath, childStructure):
return False
if childStructure.has_key("@xattrs"):
@@ -104,10 +109,17 @@
return False
except:
return False
+ for attr, value in xattr.xattr(childPath).iteritems():
+ if attr not in xattrs:
+ return False
+ if actual:
+ # There are unexpected children
+ return False
+
return True
- return compareChildren(root, structure)
+ return verifyChildren(root, structure)
class InMemoryPropertyStore(object):
Modified: CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/upgrade.py 2009-02-24 23:43:44 UTC (rev 3731)
+++ CalendarServer/branches/users/sagen/migration-3709/twistedcaldav/upgrade.py 2009-02-25 00:28:10 UTC (rev 3732)
@@ -259,6 +259,7 @@
newHome = os.path.join(uidHomes, uid[0:2], uid[2:4],
uid)
moveCalendarHome(oldHome, newHome)
+ os.rmdir(dirPath)
# Upgrade calendar homes in the new location:
for first in os.listdir(uidHomes):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090224/6459c038/attachment-0001.html>
More information about the calendarserver-changes
mailing list