[CalendarServer-changes] [8380] CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/ datastore/test/util.py
source_changes at macosforge.org
source_changes at macosforge.org
Sat Dec 3 00:37:16 PST 2011
Revision: 8380
http://trac.macosforge.org/projects/calendarserver/changeset/8380
Author: glyph at apple.com
Date: 2011-12-03 00:37:15 -0800 (Sat, 03 Dec 2011)
Log Message:
-----------
add a method for creating stores in subprocesses
Modified Paths:
--------------
CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/test/util.py
Modified: CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/test/util.py 2011-12-03 08:37:06 UTC (rev 8379)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/test/util.py 2011-12-03 08:37:15 UTC (rev 8380)
@@ -83,6 +83,37 @@
SHARED_DB_PATH = "_test_sql_db"
+ @classmethod
+ def childStore(cls):
+ """
+ Create a store suitable for use in a child process, that is hooked up
+ to the store that a parent test process is managing.
+ """
+ staticQuota = 3000
+ dbRoot = CachingFilePath(cls.SHARED_DB_PATH)
+ attachmentRoot = dbRoot.child("attachments")
+ stubsvc = PostgresService(
+ dbRoot, lambda cf: Service(), current_sql_schema, resetSchema=True,
+ databaseName="caldav",
+ options = [
+ "-c log_lock_waits=TRUE",
+ "-c log_statement=all",
+ "-c log_line_prefix='%p.%x '",
+ ],
+ testMode=True
+ )
+ cp = ConnectionPool(stubsvc.produceConnection, maxConnections=1)
+ # Attach the service to the running reactor.
+ cp.startService()
+ reactor.addSystemEventTrigger("before", "shutdown", cp.stopService)
+ cds = CommonDataStore(
+ cp.connection, StubNotifierFactory(),
+ attachmentRoot, quota=staticQuota
+ )
+ return cds
+
+
+
def buildStore(self, testCase, notifierFactory):
"""
Do the necessary work to build a store for a particular test case.
@@ -145,7 +176,8 @@
except OSError:
pass
currentTestID = testCase.id()
- cp = ConnectionPool(self.sharedService.produceConnection)
+ cp = ConnectionPool(self.sharedService.produceConnection,
+ maxConnections=5)
quota = deriveQuota(testCase)
store = CommonDataStore(
cp.connection, notifierFactory, attachmentRoot, quota=quota
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111203/e44c4233/attachment.html>
More information about the calendarserver-changes
mailing list