[CalendarServer-changes] [15362] CalendarServer/trunk/contrib/performance/loadtest

source_changes at macosforge.org source_changes at macosforge.org
Thu Dec 3 13:00:49 PST 2015


Revision: 15362
          http://trac.calendarserver.org//changeset/15362
Author:   sagen at apple.com
Date:     2015-12-03 13:00:49 -0800 (Thu, 03 Dec 2015)
Log Message:
-----------
Client sim now downloads all attachments whenever an event change is noticed.  Also, fixed a bug where sim calendar resource type wasn't being properly set.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/loadtest/clients.plist
    CalendarServer/trunk/contrib/performance/loadtest/ical.py
    CalendarServer/trunk/contrib/performance/loadtest/profiles.py

Modified: CalendarServer/trunk/contrib/performance/loadtest/clients.plist
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/clients.plist	2015-12-03 18:54:20 UTC (rev 15361)
+++ CalendarServer/trunk/contrib/performance/loadtest/clients.plist	2015-12-03 21:00:49 UTC (rev 15362)
@@ -615,6 +615,19 @@
 						</dict>
 					</dict>
 
+
+					<!-- This profile downloads attachments when an event changes. -->
+					<dict>
+						<key>class</key>
+						<string>contrib.performance.loadtest.profiles.AttachmentDownloader</string>
+
+						<key>params</key>
+						<dict>
+							<key>enabled</key>
+							<true/>
+						</dict>
+					</dict>
+
 					<!-- A task-creating profile, which will periodically create
 						new tasks at a random time on a random calendar. -->
 					<dict>

Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py	2015-12-03 18:54:20 UTC (rev 15361)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py	2015-12-03 21:00:49 UTC (rev 15362)
@@ -700,6 +700,22 @@
 
 
     @inlineCallbacks
+    def _get(self, url, allowedStatus=(MULTI_STATUS,), method_label=None):
+        """
+        Issue a GET on the chosen URL
+        """
+        response = yield self._request(
+            allowedStatus,
+            'GET',
+            url,
+            method_label=method_label,
+        )
+
+        body = yield readBody(response)
+        returnValue(body)
+
+
+    @inlineCallbacks
     def _report(self, url, body, depth='0', allowedStatus=(MULTI_STATUS,), otherTokens=False, method_label=None):
         """
         Issue a REPORT on the chosen URL
@@ -886,9 +902,11 @@
             isNotifications = False
             isShared = False
             isSharedByMe = False
+            resourceType = None
             for nodeType in nodes[davxml.resourcetype]:
                 if nodeType.tag in self._CALENDAR_TYPES:
                     isCalendar = True
+                    resourceType = nodeType.tag
                 elif nodeType.tag == csxml.notification:
                     isNotifications = True
                 elif nodeType.tag.startswith("{http://calendarserver.org/ns/}shared"):
@@ -905,7 +923,7 @@
                             componentTypes.add(comp.get("name").upper())
 
                 calendars.append(Calendar(
-                    nodeType.tag,
+                    resourceType,
                     componentTypes,
                     textProps.get(davxml.displayname, None),
                     href,
@@ -1985,6 +2003,7 @@
             method_label="POST{attach}"
         )
         body = yield readBody(response)
+        yield self.updateEvent(href)
         returnValue(body)
 
 

Modified: CalendarServer/trunk/contrib/performance/loadtest/profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2015-12-03 18:54:20 UTC (rev 15361)
+++ CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2015-12-03 21:00:49 UTC (rev 15362)
@@ -525,7 +525,48 @@
         return accepted
 
 
+class AttachmentDownloader(ProfileBase):
+    """
+    A Calendar user who downloads attachments.
+    """
+    def setParameters(
+        self,
+        enabled=True,
+    ):
+        self.enabled = enabled
 
+    def run(self):
+        self._subscription = self._client.catalog["eventChanged"].subscribe(self.eventChanged)
+        return Deferred()
+
+
+    def eventChanged(self, href):
+        # Just respond to normal calendar events
+        calendar = href.rsplit('/', 1)[0] + '/'
+        try:
+            calendar = self._client._calendars[calendar]
+        except KeyError:
+            return
+
+        if calendar.resourceType == caldavxml.calendar:
+            self.calendarEventChanged(calendar, href)
+
+
+    def calendarEventChanged(self, calendar, href):
+        component = self._client._events[href].component
+        attachments = tuple(component.mainComponent().properties('ATTACH'))
+        if attachments:
+            for attachment in attachments:
+                attachmentHref = attachment.value()
+                self._reactor.callLater(
+                    0, self._downloadAttachment, attachmentHref
+                )
+
+    def _downloadAttachment(self, href):
+        return self._client._get(href, 200)
+
+
+
 class Eventer(ProfileBase):
     """
     A Calendar user who creates new events.
@@ -622,13 +663,14 @@
         vevent = component.mainComponent()
 
         label = yield self.modifyEvent(event.url, vevent)
-        vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
+        if label:
+            vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
 
-        event.component = component
-        yield self._newOperation(
-            label,
-            self._client.changeEvent(event.url)
-        )
+            event.component = component
+            yield self._newOperation(
+                label,
+                self._client.changeEvent(event.url)
+            )
 
 
     def run(self):
@@ -700,7 +742,7 @@
     def modifyEvent(self, href, vevent):
         fileSize = int(self._fileSize.sample())
         yield self._client.postAttachment(href, 'x' * fileSize)
-        returnValue("attach{files}")
+        returnValue(None)
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151203/a1353836/attachment.html>


More information about the calendarserver-changes mailing list