[CalendarServer-changes] [8383] 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:48 PST 2011


Revision: 8383
          http://trac.macosforge.org/projects/calendarserver/changeset/8383
Author:   glyph at apple.com
Date:     2011-12-03 00:37:48 -0800 (Sat, 03 Dec 2011)
Log Message:
-----------
factor out store service creation

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:39 UTC (rev 8382)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/test/util.py	2011-12-03 08:37:48 UTC (rev 8383)
@@ -83,17 +83,15 @@
 
     SHARED_DB_PATH = "_test_sql_db"
 
+
     @classmethod
-    def childStore(cls):
+    def createService(cls, serviceFactory):
         """
-        Create a store suitable for use in a child process, that is hooked up
-        to the store that a parent test process is managing.
+        Create a L{PostgresService} to use for building a store.
         """
-        staticQuota = 3000
         dbRoot = CachingFilePath(cls.SHARED_DB_PATH)
-        attachmentRoot = dbRoot.child("attachments")
-        stubsvc = PostgresService(
-            dbRoot, lambda cf: Service(), current_sql_schema, resetSchema=True,
+        return PostgresService(
+            dbRoot, serviceFactory, current_sql_schema, resetSchema=True,
             databaseName="caldav",
             options = [
                 "-c log_lock_waits=TRUE",
@@ -102,6 +100,19 @@
             ],
             testMode=True
         )
+
+
+    @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
+        attachmentRoot = (CachingFilePath(cls.SHARED_DB_PATH)
+                          .child("attachments"))
+        stubsvc = cls.createService(lambda cf: Service())
+
         cp = ConnectionPool(stubsvc.produceConnection, maxConnections=1)
         # Attach the service to the running reactor.
         cp.startService()
@@ -113,7 +124,6 @@
         return cds
 
 
-
     def buildStore(self, testCase, notifierFactory):
         """
         Do the necessary work to build a store for a particular test case.
@@ -130,16 +140,7 @@
                     testCase, notifierFactory, attachmentRoot
                 ).chainDeferred(ready)
                 return Service()
-            self.sharedService = PostgresService(
-                dbRoot, getReady, 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
-            )
+            self.sharedService = self.createService(getReady)
             self.sharedService.startService()
             def startStopping():
                 log.msg("Starting stopping.")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111203/ddfab2ac/attachment-0001.html>


More information about the calendarserver-changes mailing list