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

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 3 13:38:13 PDT 2016


Revision: 15655
          http://trac.calendarserver.org//changeset/15655
Author:   sagen at apple.com
Date:     2016-06-03 13:38:13 -0700 (Fri, 03 Jun 2016)
Log Message:
-----------
Limit shared collections to 3 invitees

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

Modified: CalendarServer/trunk/contrib/performance/loadtest/clients.plist
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/clients.plist	2016-06-03 19:49:01 UTC (rev 15654)
+++ CalendarServer/trunk/contrib/performance/loadtest/clients.plist	2016-06-03 20:38:13 UTC (rev 15655)
@@ -357,41 +357,7 @@
 						</dict>
 					</dict>
 
-					<!-- Picks a random event and attaches -->
-					<dict>
-						<key>class</key>
-						<string>contrib.performance.loadtest.profiles.Attacher</string>
 
-						<key>params</key>
-						<dict>
-							<key>enabled</key>
-							<false/>
-
-							<!-- Define the interval (in seconds) at which this profile will use
-								its client to create a new event. -->
-							<key>interval</key>
-							<integer>120</integer>
-
-							<!-- Define the attachment size distribution. -->
-							<key>fileSizeDistribution</key>
-							<dict>
-								<key>type</key>
-								<string>contrib.performance.stats.NormalDistribution</string>
-								<key>params</key>
-								<dict>
-									<!-- mu gives the mean of the normal distribution (in bytes). -->
-									<key>mu</key>
-									<integer>500000</integer>
-
-									<!-- and sigma gives its standard deviation. -->
-									<key>sigma</key>
-									<integer>100000</integer>
-								</dict>
-							</dict>
-
-						</dict>
-					</dict>
-
 					<!-- Removes events from calendars exceeding a threshold -->
 					<dict>
 						<key>class</key>
@@ -429,6 +395,10 @@
 							<key>interval</key>
 							<integer>1800</integer>
 
+							<!-- Only share a collection with up to this many sharees -->
+							<key>maxSharees</key>
+							<integer>3</integer>
+
 						</dict>
 					</dict>
 
@@ -744,12 +714,12 @@
 						<key>params</key>
 						<dict>
 							<key>enabled</key>
-							<false/>
+							<true/>
 
 							<!-- Define the interval (in seconds) at which this profile will use
 								its client to run a report. -->
 							<key>interval</key>
-							<integer>10</integer>
+							<integer>300</integer>
 
 						</dict>
 					</dict>
@@ -769,7 +739,7 @@
 							<!-- Define the interval (in seconds) at which this profile will use
 								its client to refresh. -->
 							<key>interval</key>
-							<integer>1800</integer>
+							<integer>300</integer>
 
 						</dict>
 					</dict>

Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py	2016-06-03 19:49:01 UTC (rev 15654)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py	2016-06-03 20:38:13 UTC (rev 15655)
@@ -215,7 +215,7 @@
 class Calendar(object):
     def __init__(
         self, resourceType, componentTypes, name, url, changeToken,
-        shared=False, sharedByMe=False
+        shared=False, sharedByMe=False, invitees=None
     ):
         self.resourceType = resourceType
         self.componentTypes = componentTypes
@@ -225,6 +225,7 @@
         self.events = {}
         self.shared = shared
         self.sharedByMe = sharedByMe
+        self.invitees = invitees if invitees else []
 
         if self.name is None and self.url is not None:
             self.name = self.url.rstrip("/").split("/")[-1]
@@ -240,6 +241,7 @@
             result[attr] = getattr(self, attr)
         result["componentTypes"] = list(sorted(self.componentTypes))
         result["events"] = sorted(self.events.keys())
+        result["invitees"] = sorted(self.invitees)
         return result
 
 
@@ -253,6 +255,7 @@
         for attr in ("resourceType", "name", "url", "changeToken", "shared", "sharedByMe"):
             setattr(calendar, attr, u2str(data[attr]))
         calendar.componentTypes = set(map(u2str, data["componentTypes"]))
+        calendar.invitees = map(u2str, data["invitees"])
 
         for event in data["events"]:
             url = urljoin(calendar.url, event)
@@ -708,7 +711,6 @@
             StringProducer(body),
             method_label=method_label,
         )
-
         result = self._parseMultiStatus(responseBody) if response.code == MULTI_STATUS else None
 
         returnValue((response, result,))
@@ -965,7 +967,18 @@
             )
 
 
+    @inlineCallbacks
+    def unshareAll(self):
+        for calendar in self._calendars.values():
+            for invitee in calendar.invitees:
+                body = Calendar.removeInviteeXML(invitee)
+                yield self.postXML(
+                    calendar.url,
+                    body,
+                    label="POST{unshare-calendar}"
+                )
 
+
     @inlineCallbacks
     def _extractPrincipalDetails(self):
         # Using the actual principal URL, retrieve principal information
@@ -1082,6 +1095,17 @@
                     for comp in nodes[caldavxml.supported_calendar_component_set]:
                         componentTypes.add(comp.get("name").upper())
 
+                # Keep track of sharing invitees
+                invitees = []
+                if isShared and isSharedByMe:
+                    try:
+                        invite = nodes[csxml.invite]
+                        for user in invite.findall(str(csxml.user)):
+                            invitee = user.find(str(davxml.href)).text
+                            invitees.append(invitee)
+                    except KeyError:
+                        pass
+
                 calendars.append(Calendar(
                     resourceType,
                     componentTypes,
@@ -1089,7 +1113,8 @@
                     href,
                     textProps.get(changeTag, None),
                     shared=isShared,
-                    sharedByMe=isSharedByMe
+                    sharedByMe=isSharedByMe,
+                    invitees=invitees
                 ))
 
                 # Also monitor shared-to-me calendars
@@ -1496,6 +1521,7 @@
             elif self._calendars[cal.url].changeToken != newToken:
                 # Calendar changed - reload it
                 yield self._updateCalendar(self._calendars[cal.url], newToken)
+                self._calendars[cal.url].invitees = cal.invitees
 
         # Clean out previously seen collections that are no longer on the server
         currentCalendarUris = [c.url for c in calendars]
@@ -1531,6 +1557,10 @@
         pushKeys = self.ampPushKeys.values()
         self._monitorAmpPush(calendarHomeSet, pushKeys)
 
+        # if firstTime:
+        #     # clear out shared calendars
+        #     yield self.unshareAll()
+
         returnValue(True)
 
 

Modified: CalendarServer/trunk/contrib/performance/loadtest/profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2016-06-03 19:49:01 UTC (rev 15654)
+++ CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2016-06-03 20:38:13 UTC (rev 15655)
@@ -827,10 +827,12 @@
     def setParameters(
         self,
         enabled=True,
-        interval=60
+        interval=60,
+        maxSharees=3
     ):
         self.enabled = enabled
         self._interval = interval
+        self._maxSharees = maxSharees
 
 
     def run(self):
@@ -861,6 +863,10 @@
         if not calendar:
             returnValue(None)
 
+        # don't exceed maxSharees
+        if len(calendar.invitees) >= self._maxSharees:
+            returnValue(None)
+
         # pick a random sharee
         shareeRecord = self._sim.getRandomUserRecord(besides=self._number)
         if shareeRecord is None:

Modified: CalendarServer/trunk/contrib/performance/loadtest/test_ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_ical.py	2016-06-03 19:49:01 UTC (rev 15654)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_ical.py	2016-06-03 20:38:13 UTC (rev 15655)
@@ -1549,7 +1549,7 @@
         self.client._events.update(dict([[event.url, event] for event in events]))
 
         calendars = (
-            Calendar(str(caldavxml.calendar), set(('VEVENT',)), u'calendar', u'/home/calendar/', "123"),
+            Calendar(str(caldavxml.calendar), set(('VEVENT',)), u'calendar', u'/home/calendar/', "123", invitees=["a", "b", "c"]),
             Calendar(str(caldavxml.calendar), set(('VTODO',)), u'tasks', u'/home/tasks/', "456"),
             Calendar(str(caldavxml.schedule_inbox), set(('VEVENT', "VTODO",)), u'calendar', u'/home/inbox/', "789"),
         )
@@ -1596,6 +1596,11 @@
       "componentTypes": [
         "VEVENT"
       ],
+      "invitees": [
+        "a",
+        "b",
+        "c"
+      ],
       "url": "/home/calendar/",
       "events": [
         "1.ics"
@@ -1611,6 +1616,7 @@
         "VEVENT",
         "VTODO"
       ],
+      "invitees": [],
       "url": "/home/inbox/",
       "events": [
         "i1.ics"
@@ -1625,6 +1631,7 @@
       "componentTypes": [
         "VTODO"
       ],
+      "invitees": [],
       "url": "/home/tasks/",
       "events": []
     }
@@ -1705,7 +1712,6 @@
   "calendars": [
     {
       "changeToken": "321",
-      "homeToken": "321",
       "attachmentsUrl": "https://example.com/attachments/",
       "name": "calendar",
       "shared": false,
@@ -1714,6 +1720,11 @@
       "componentTypes": [
         "VEVENT"
       ],
+      "invitees": [
+        "a",
+        "b",
+        "c"
+      ],
       "url": "/home/calendar/",
       "events": [
         "2.ics"
@@ -1729,6 +1740,11 @@
         "VEVENT",
         "VTODO"
       ],
+      "invitees": [
+        "a",
+        "b",
+        "c"
+      ],
       "url": "/home/inbox/",
       "events": [
         "i2.ics"
@@ -1743,6 +1759,11 @@
       "componentTypes": [
         "VTODO"
       ],
+      "invitees": [
+        "a",
+        "b",
+        "c"
+      ],
       "url": "/home/tasks/",
       "events": []
     }
@@ -1783,6 +1804,7 @@
         self.assertEqual(self.client._calendars["/home/calendar/"].name, "calendar")
         self.assertEqual(self.client._calendars["/home/calendar/"].resourceType, "{urn:ietf:params:xml:ns:caldav}calendar")
         self.assertEqual(self.client._calendars["/home/calendar/"].componentTypes, set(("VEVENT",)))
+        self.assertEqual(self.client._calendars["/home/calendar/"].invitees, ["a", "b", "c"])
         self.assertTrue("/home/tasks/" in self.client._calendars)
         self.assertTrue("/home/inbox/" in self.client._calendars)
         self.assertEqual(self.client._calendars["/home/inbox/"].componentTypes, set(("VEVENT", "VTODO",)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160603/4485527d/attachment-0001.html>


More information about the calendarserver-changes mailing list