[CalendarServer-changes] [13804] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 30 11:50:40 PDT 2014
Revision: 13804
http://trac.calendarserver.org//changeset/13804
Author: sagen at apple.com
Date: 2014-07-30 11:50:40 -0700 (Wed, 30 Jul 2014)
Log Message:
-----------
Skip filesystem home migrations if record is missing from directory; remove quit-after-upgrade-step
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/calendarserver/tap/test/test_caldav.py
CalendarServer/trunk/contrib/od/test/test_live.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py
CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2014-07-30 18:50:40 UTC (rev 13804)
@@ -720,42 +720,6 @@
"""
-
-class QuitAfterUpgradeStep(object):
-
- def __init__(self, triggerFile, reactor=None):
- self.triggerFile = triggerFile
- if reactor is None:
- from twisted.internet import reactor
- self.reactor = reactor
-
-
- def removeTriggerFile(self):
- try:
- remove(self.triggerFile)
- except OSError:
- pass
-
-
- def stepWithResult(self, result):
- if exists(self.triggerFile):
- self.removeTriggerFile()
- self.reactor.stop()
- raise PostUpgradeStopRequested()
- else:
- return succeed(result)
-
-
- def stepWithFailure(self, failure):
- if exists(self.triggerFile):
- self.removeTriggerFile()
- self.reactor.stop()
- raise PostUpgradeStopRequested()
- else:
- return failure
-
-
-
class CalDAVServiceMaker (object):
log = Logger()
@@ -1583,15 +1547,7 @@
)
)
- # Conditionally stop after upgrade at this point
pps.addStep(
- QuitAfterUpgradeStep(
- config.StopAfterUpgradeTriggerFile or
- config.UpgradeHomePrefix
- )
- )
-
- pps.addStep(
PostDBImportStep(
store, config, getattr(self, "doPostImport", True)
)
Modified: CalendarServer/trunk/calendarserver/tap/test/test_caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/test/test_caldav.py 2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/calendarserver/tap/test/test_caldav.py 2014-07-30 18:50:40 UTC (rev 13804)
@@ -60,7 +60,7 @@
CalDAVOptions, CalDAVServiceMaker, CalDAVService, GroupOwnedUNIXServer,
DelayedStartupProcessMonitor, DelayedStartupLineLogger, TwistdSlaveProcess,
_CONTROL_SERVICE_NAME, getSystemIDs, PreProcessingService,
- QuitAfterUpgradeStep, DataStoreMonitor
+ DataStoreMonitor
)
from calendarserver.provision.root import RootResource
from twext.enterprise.jobqueue import PeerConnectionPool, LocalQueuer
@@ -1505,31 +1505,6 @@
)
- def test_quitAfterUpgradeStep(self):
- triggerFileName = "stop_after_upgrade"
- triggerFile = FilePath(triggerFileName)
- self.pps.addStep(
- StepOne(self._record, False)
- ).addStep(
- StepTwo(self._record, False)
- ).addStep(
- QuitAfterUpgradeStep(triggerFile.path, reactor=self.clock)
- ).addStep(
- StepFour(self._record, True)
- )
- triggerFile.setContent("")
- self.pps.startService()
- self.assertEquals(
- self.history,
- [
- 'one success', 'two success', 'four failure',
- ('serviceCreator', None, 'storageService')
- ]
- )
- self.assertFalse(triggerFile.exists())
-
-
-
class StubStorageService(object):
def __init__(self):
Modified: CalendarServer/trunk/contrib/od/test/test_live.py
===================================================================
--- CalendarServer/trunk/contrib/od/test/test_live.py 2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/contrib/od/test/test_live.py 2014-07-30 18:50:40 UTC (rev 13804)
@@ -40,7 +40,6 @@
from twext.who.expression import (
CompoundExpression, Operand, MatchExpression, MatchType, MatchFlags
)
- from twext.who.idirectory import QueryNotSupportedError
from txdav.who.directory import CalendarDirectoryServiceMixin
from txdav.who.opendirectory import DirectoryService as OpenDirectoryService
@@ -274,115 +273,6 @@
@onlyIfPopulated
@inlineCallbacks
- def test_compoundWithEmbeddedSingleRecordType(self):
- expression = CompoundExpression(
- [
- CompoundExpression(
- [
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"be",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"be",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"test",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"test",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- ],
- Operand.AND
- ),
- MatchExpression(
- self.service.fieldName.recordType, self.service.recordType.user,
- ),
- ],
- Operand.AND
- )
- try:
- yield self.service.recordsFromExpression(expression)
- except QueryNotSupportedError:
- pass
- else:
- self.fail("This should have raised")
-
-
- @onlyIfPopulated
- @inlineCallbacks
- def test_compoundWithEmbeddedMultipleRecordTypes(self):
- expression = CompoundExpression(
- [
- CompoundExpression(
- [
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"be",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"be",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"test",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"test",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- ],
- Operand.AND
- ),
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.recordType, self.service.recordType.user,
- ),
- MatchExpression(
- self.service.fieldName.recordType, self.service.recordType.group,
- ),
- ],
- Operand.OR
- ),
- ],
- Operand.AND
- )
-
- try:
- yield self.service.recordsFromExpression(expression)
- except QueryNotSupportedError:
- pass
- else:
- self.fail("This should have raised")
-
-
- @onlyIfPopulated
- @inlineCallbacks
def test_recordsMatchingTokens(self):
self.calService = CalOpenDirectoryService()
records = yield self.calService.recordsMatchingTokens([u"be", u"test"])
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-07-30 18:50:40 UTC (rev 13804)
@@ -310,8 +310,6 @@
"FailIfUpgradeNeeded": True, # Set to True to prevent the server or utility
# tools from running if the database needs a schema
# upgrade.
- "StopAfterUpgradeTriggerFile": "stop_after_upgrade", # if this file exists in ConfigRoot, stop
- # the service after finishing upgrade phase
"UpgradeHomePrefix": "", # When upgrading, only upgrade homes where the owner UID starts with
# with the specified prefix. The upgrade will only be partial and only
@@ -1249,7 +1247,6 @@
("DataRoot", "DatabaseRoot"),
("DataRoot", "AttachmentsRoot"),
("DataRoot", ("TimezoneService", "BasePath",)),
- ("ConfigRoot", "StopAfterUpgradeTriggerFile"),
("ConfigRoot", ("Scheduling", "iSchedule", "DNSDebug",)),
("ConfigRoot", ("Scheduling", "iSchedule", "DKIM", "PrivateKeyFile",)),
("ConfigRoot", ("Scheduling", "iSchedule", "DKIM", "PublicKeyFile",)),
Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py 2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py 2014-07-30 18:50:40 UTC (rev 13804)
@@ -50,6 +50,7 @@
from txdav.common.datastore.upgrade.sql.upgrades.calendar_upgrade_from_4_to_5 import doUpgrade as doCalendarUpgrade_4_to_5
from txdav.common.datastore.upgrade.sql.upgrades.addressbook_upgrade_from_1_to_2 import doUpgrade as doAddressbookUpgrade_1_to_2
+from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
@inlineCallbacks
@@ -326,7 +327,12 @@
returnValue(None)
try:
if sqlHome is None:
- sqlHome = yield homeGetter(uid, create=True)
+ try:
+ sqlHome = yield homeGetter(uid, create=True)
+ except DirectoryRecordNotFoundError:
+ # The directory record does not exist; skip this home
+ self.log.warn("Skipping migration of {uid} because it's missing from the directory service", uid=uid)
+ returnValue(None)
yield migrateFunc(fileHome, sqlHome, merge=self.merge)
except:
f = Failure()
@@ -362,11 +368,6 @@
)
)
- for homeType in TOPPATHS:
- homesPath = self.fileStore._path.child(homeType)
- if homesPath.isdir():
- homesPath.remove()
-
# Set attachment directory ownership. FIXME: is this still necessary
# since attachments started living outside the database directory
# created by initdb? default permissions might be correct now.
Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py 2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py 2014-07-30 18:50:40 UTC (rev 13804)
@@ -320,7 +320,36 @@
self.assertEquals(object.md5(), md5)
+ @withSpecialValue(
+ "extraRequirements",
+ {
+ "nonexistent": {
+ "calendar_1": {
+ }
+ }
+ }
+ )
@inlineCallbacks
+ def test_upgradeCalendarHomesMissingDirectoryRecord(self):
+ """
+ Test an upgrade where a directory record is missing for a home;
+ the original home directory will remain on disk.
+ """
+ yield self.upgrader.stepWithResult(None)
+ txn = self.sqlStore.newTransaction()
+ self.addCleanup(txn.commit)
+ for uid in CommonTests.requirements:
+ if CommonTests.requirements[uid] is not None:
+ self.assertNotIdentical(
+ None, (yield txn.calendarHomeWithUID(uid))
+ )
+ self.assertIdentical(None, (yield txn.calendarHomeWithUID(u"nonexistent")))
+ # Skipped calendar homes are not deleted
+ self.assertTrue(self.filesPath.child("calendars").child(
+ "__uids__").child("no").child("ne").child("nonexistent").exists())
+
+
+ @inlineCallbacks
def test_upgradeExistingHome(self):
"""
L{UpgradeToDatabaseService.startService} will skip migrating existing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140730/d4f0ddb9/attachment-0001.html>
More information about the calendarserver-changes
mailing list