[CalendarServer-changes] [6661] CalendarServer/trunk/contrib/performance

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 29 13:33:10 PST 2010


Revision: 6661
          http://trac.macosforge.org/projects/calendarserver/changeset/6661
Author:   exarkun at twistedmatrix.com
Date:     2010-11-29 13:33:06 -0800 (Mon, 29 Nov 2010)
Log Message:
-----------
Really basic start of a copy of SL iCal; implements some startup-time behavior only, without error checking.

Added Paths:
-----------
    CalendarServer/trunk/contrib/performance/loadtest/
    CalendarServer/trunk/contrib/performance/loadtest/ical.py
    CalendarServer/trunk/contrib/performance/loadtest/sl_startup_calendarhome_propfind.request
    CalendarServer/trunk/contrib/performance/loadtest/sl_startup_notification_propfind.request
    CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_propfind.request
    CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_report.request
    CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principals_report.request

Added: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py	2010-11-29 21:33:06 UTC (rev 6661)
@@ -0,0 +1,151 @@
+##
+# Copyright (c) 2010 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##
+
+from twisted.python.log import err
+from twisted.python.filepath import FilePath
+from twisted.internet.defer import inlineCallbacks
+from twisted.web.http_headers import Headers
+from twisted.web.client import Agent
+
+from httpclient import StringProducer, readBody
+from httpauth import AuthHandlerAgent
+
+def loadRequestBody(label):
+    return FilePath(__file__).sibling(label + '.request').getContent()
+
+class SnowLeopard(object):
+    """
+    Implementation of the SnowLeopard iCal network behavior.
+    """
+
+    _STARTUP_PRINCIPAL_PROPFIND = loadRequestBody('sl_startup_principal_propfind')
+    _STARTUP_PRINCIPALS_REPORT = loadRequestBody('sl_startup_principals_report')
+    _STARTUP_CALENDARHOME_PROPFIND = loadRequestBody('sl_startup_calendarhome_propfind')
+    _STARTUP_NOTIFICATION_PROPFIND = loadRequestBody('sl_startup_notification_propfind')
+    _STARTUP_PRINCIPAL_REPORT = loadRequestBody('sl_startup_principal_report')
+
+    def __init__(self, reactor, host, port, user, auth):
+        self.reactor = reactor
+        self.agent = AuthHandlerAgent(Agent(self.reactor), auth)
+        self.root = 'http://%s:%d/' % (host, port)
+        self.user = user
+
+
+    def _request(self, method, url, headers, body):
+        # XXX Do return code checking here.
+        return self.agent.request(method, url, headers, body)
+
+    
+    def _principalPropfind(self, user):
+        d = self._request(
+            'PROPFIND',
+            self.root + 'principals/__uids__/' + user + '/',
+            Headers({
+                    'content-type': ['text/xml'],
+                    'depth': ['0']}),
+            StringProducer(self._STARTUP_PRINCIPAL_PROPFIND))
+        d.addCallback(readBody)
+        return d
+
+
+    def _principalsReport(self):
+        d = self._request(
+            'REPORT',
+            self.root + 'principals/',
+            Headers({
+                    'content-type': ['text/xml'],
+                    'depth': ['0']}),
+            StringProducer(self._STARTUP_PRINCIPALS_REPORT))
+        d.addCallback(readBody)
+        return d
+
+
+    def _calendarHomePropfind(self, user):
+        d = self._request(
+            'PROPFIND',
+            self.root + 'calendars/__uids__/' + user + '/',
+            Headers({
+                    'content-type': ['text/xml'],
+                    'depth': ['1']}),
+            StringProducer(self._STARTUP_CALENDARHOME_PROPFIND))
+        d.addCallback(readBody)
+        return d
+
+
+    def _notificationPropfind(self, user):
+        d = self._request(
+            'PROPFIND',
+            self.root + 'calendars/__uids__/' + user + '/notification/',
+            Headers({
+                    'content-type': ['text/xml'],
+                    'depth': ['1']}),
+            StringProducer(self._STARTUP_NOTIFICATION_PROPFIND))
+        d.addCallback(readBody)
+        return d
+
+    
+    def _principalReport(self, user):
+        d = self._request(
+            'REPORT',
+            self.root + 'principals/__uids__/' + user + '/',
+            Headers({
+                    'content-type': ['text/xml'],
+                    'depth': ['0']}),
+            StringProducer(self._STARTUP_PRINCIPAL_REPORT))
+        d.addCallback(readBody)
+        return d
+
+
+    @inlineCallbacks
+    def run(self):
+        """
+        Emulate a CalDAV client.
+        """
+        # Orient ourselves, or something
+        print (yield self._principalPropfind(self.user))
+
+        # Do another kind of thing I guess
+        print (yield self._principalsReport())
+
+        # Whatever
+        print (yield self._calendarHomePropfind(self.user))
+
+        # Learn stuff I guess
+        print (yield self._notificationPropfind(self.user))
+
+        # More too
+        print (yield self._principalReport(self.user))
+
+
+def main():
+    from urllib2 import HTTPDigestAuthHandler
+    from twisted.internet import reactor
+    auth = HTTPDigestAuthHandler()
+    auth.add_password(
+        realm="Test Realm",
+        uri="http://127.0.0.1:8008/",
+        user="user01",
+        passwd="user01")
+    client = SnowLeopard(reactor, '127.0.0.1', 8008, 'user01', auth)
+    d = client.run()
+    d.addErrback(err, "Snow Leopard client run() problem")
+    d.addCallback(lambda ignored: reactor.stop())
+    reactor.run()
+
+
+if __name__ == '__main__':
+    main()

Added: CalendarServer/trunk/contrib/performance/loadtest/sl_startup_calendarhome_propfind.request
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sl_startup_calendarhome_propfind.request	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/sl_startup_calendarhome_propfind.request	2010-11-29 21:33:06 UTC (rev 6661)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<x0:propfind xmlns:x0="DAV:" xmlns:x3="http://apple.com/ns/ical/" xmlns:x1="http://calendarserver.org/ns/" xmlns:x2="urn:ietf:params:xml:ns:caldav">
+ <x0:prop>
+  <x1:xmpp-server/>
+  <x1:xmpp-uri/>
+  <x1:getctag/>
+  <x0:displayname/>
+  <x2:calendar-description/>
+  <x3:calendar-color/>
+  <x3:calendar-order/>
+  <x2:supported-calendar-component-set/>
+  <x0:resourcetype/>
+  <x0:owner/>
+  <x2:calendar-free-busy-set/>
+  <x2:schedule-calendar-transp/>
+  <x2:schedule-default-calendar-URL/>
+  <x0:quota-available-bytes/>
+  <x0:quota-used-bytes/>
+  <x2:calendar-timezone/>
+  <x0:current-user-privilege-set/>
+  <x1:source/>
+  <x1:subscribed-strip-alarms/>
+  <x1:subscribed-strip-attachments/>
+  <x1:subscribed-strip-todos/>
+  <x3:refreshrate/>
+  <x1:push-transports/>
+  <x1:pushkey/>
+  <x1:publish-url/>
+ </x0:prop>
+</x0:propfind>

Added: CalendarServer/trunk/contrib/performance/loadtest/sl_startup_notification_propfind.request
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sl_startup_notification_propfind.request	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/sl_startup_notification_propfind.request	2010-11-29 21:33:06 UTC (rev 6661)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<x0:propfind xmlns:x0="DAV:" xmlns:x1="http://calendarserver.org/ns/">
+ <x0:prop>
+  <x0:getetag/>
+  <x0:resourcetype/>
+  <x1:notificationtype/>
+ </x0:prop>
+</x0:propfind>

Added: CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_propfind.request
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_propfind.request	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_propfind.request	2010-11-29 21:33:06 UTC (rev 6661)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<x0:propfind xmlns:x1="urn:ietf:params:xml:ns:caldav" xmlns:x0="DAV:" xmlns:x2="http://calendarserver.org/ns/">
+ <x0:prop>
+  <x0:principal-collection-set/>
+  <x1:calendar-home-set/>
+  <x1:calendar-user-address-set/>
+  <x1:schedule-inbox-URL/>
+  <x1:schedule-outbox-URL/>
+  <x2:dropbox-home-URL/>
+  <x2:xmpp-uri/>
+  <x2:notification-URL/>
+  <x0:displayname/>
+  <x0:principal-URL/>
+  <x0:supported-report-set/>
+ </x0:prop>
+</x0:propfind>

Added: CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_report.request
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_report.request	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principal_report.request	2010-11-29 21:33:06 UTC (rev 6661)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<x0:expand-property xmlns:x0="DAV:"><x0:property name="calendar-proxy-write-for" namespace="http://calendarserver.org/ns/"><x0:property name="displayname"/><x0:property name="principal-URL"/><x0:property name="calendar-user-address-set" namespace="urn:ietf:params:xml:ns:caldav"/></x0:property><x0:property name="calendar-proxy-read-for" namespace="http://calendarserver.org/ns/"><x0:property name="displayname"/><x0:property name="principal-URL"/><x0:property name="calendar-user-address-set" namespace="urn:ietf:params:xml:ns:caldav"/></x0:property></x0:expand-property>

Added: CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principals_report.request
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principals_report.request	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/sl_startup_principals_report.request	2010-11-29 21:33:06 UTC (rev 6661)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<x0:principal-search-property-set xmlns:x0="DAV:"/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101129/e35070eb/attachment-0001.html>


More information about the calendarserver-changes mailing list