[CalendarServer-changes] [4758] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Nov 17 17:25:13 PST 2009
Revision: 4758
http://trac.macosforge.org/projects/calendarserver/changeset/4758
Author: glyph at apple.com
Date: 2009-11-17 17:25:11 -0800 (Tue, 17 Nov 2009)
Log Message:
-----------
Add deletion of the old, now unused, 'notifications' directory to the upgrade process.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
CalendarServer/trunk/twistedcaldav/upgrade.py
Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py 2009-11-18 01:18:30 UTC (rev 4757)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py 2009-11-18 01:25:11 UTC (rev 4758)
@@ -226,6 +226,82 @@
self.assertEquals(newValue, expected)
+ def verifyDirectoryComparison(self, before, after, reverify=False):
+ """
+ Verify that the hierarchy described by "before", when upgraded, matches
+ the hierarchy described by "after".
+
+ @param before: a dictionary of the format accepted by L{TestCase.createHierarchy}
+
+ @param after: a dictionary of the format accepted by L{TestCase.createHierarchy}
+
+ @param reverify: if C{True}, re-verify the hierarchy by upgrading a
+ second time and re-verifying the root again.
+
+ @raise twisted.trial.unittest.FailTest: if the test fails.
+
+ @return: C{None}
+ """
+ root = self.createHierarchy(before)
+
+ config.DocumentRoot = root
+ config.DataRoot = root
+
+ upgradeData(config)
+ self.assertTrue(self.verifyHierarchy(root, after))
+
+ if reverify:
+ # Ensure that repeating the process doesn't change anything
+ upgradeData(config)
+ self.assertTrue(self.verifyHierarchy(root, after))
+
+
+ def test_removeNotificationDirectories(self):
+ """
+ The upgrade process should remove unused notification directories in
+ users' calendar homes, as well as the XML files found therein.
+ """
+ self.setUpXMLDirectory()
+
+ before = {
+ "calendars": {
+ "users": {
+ "wsanchez": {
+ "calendar" : {},
+ "notifications": {
+ "sample-notification.xml": {
+ "@contents": "<?xml version='1.0'>\n<should-be-ignored />"
+ }
+ }
+ }
+ }
+ }
+ }
+
+ after = {
+ "calendars" : {
+ "__uids__" : {
+ "64" : {
+ "23" : {
+ "6423F94A-6B76-4A3A-815B-D52CFD77935D" : {
+ "calendar": {},
+ }
+ }
+ }
+ }
+ },
+ ".calendarserver_version" : {
+ "@contents" : "1",
+ },
+ CalendarUserProxyDatabase.dbFilename : { "@contents" : None },
+ MailGatewayTokensDatabase.dbFilename : { "@contents" : None },
+ ResourceInfoDatabase.dbFilename : { "@contents" : None },
+ "tasks" : {"incoming" : {}}
+ }
+
+ self.verifyDirectoryComparison(before, after)
+
+
def test_calendarsUpgradeWithTypes(self):
"""
Verify that calendar homes in the /calendars/<type>/<shortname>/ form
@@ -359,20 +435,9 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after, reverify=True)
- 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))
-
-
-
def test_calendarsUpgradeWithOrphans(self):
"""
Verify that calendar homes in the /calendars/<type>/<shortname>/ form
@@ -446,19 +511,9 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after, reverify=True)
- 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))
-
-
def test_calendarsUpgradeWithDuplicateOrphans(self):
"""
Verify that calendar homes in the /calendars/<type>/<shortname>/ form
@@ -547,20 +602,9 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after, reverify=True)
- 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))
-
-
-
def test_calendarsUpgradeWithUnknownFiles(self):
"""
Unknown files, including .DS_Store files at any point in the hierarchy,
@@ -653,19 +697,9 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after, reverify=True)
- 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))
-
-
def test_calendarsUpgradeWithUIDs(self):
"""
Verify that calendar homes in the /calendars/__uids__/<guid>/ form
@@ -766,18 +800,9 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after, reverify=True)
- 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))
-
def test_calendarsUpgradeWithUIDsMultilevel(self):
"""
Verify that calendar homes in the /calendars/__uids__/XX/YY/<guid>/
@@ -895,19 +920,8 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after, reverify=True)
- 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))
-
-
def test_calendarsUpgradeWithNoChange(self):
"""
Verify that calendar homes in the /calendars/__uids__/XX/YY/<guid>/
@@ -1025,17 +1039,9 @@
}
}
- root = self.createHierarchy(before)
+ self.verifyDirectoryComparison(before, after)
- config.DocumentRoot = root
- config.DataRoot = root
- upgradeData(config)
- self.assertTrue(self.verifyHierarchy(root, after))
-
-
-
-
def test_calendarsUpgradeWithError(self):
"""
Verify that a problem with one resource doesn't stop the process, but
Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py 2009-11-18 01:18:30 UTC (rev 4757)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py 2009-11-18 01:25:11 UTC (rev 4758)
@@ -182,6 +182,10 @@
# Skip non-directories; these might have been uploaded by a
# random DAV client, they can't be calendar collections.
continue
+ if cal == 'notifications':
+ # Delete the old, now obsolete, notifications directory.
+ rmdir(calPath)
+ continue
log.debug("Upgrading calendar: %s" % (calPath,))
if not upgradeCalendarCollection(calPath, directory):
errorOccurred = True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091117/895b457b/attachment-0001.html>
More information about the calendarserver-changes
mailing list