<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15655] CalendarServer/trunk/contrib/performance/loadtest</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15655">15655</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2016-06-03 13:38:13 -0700 (Fri, 03 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Limit shared collections to 3 invitees</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcontribperformanceloadtestclientsplist">CalendarServer/trunk/contrib/performance/loadtest/clients.plist</a></li>
<li><a href="#CalendarServertrunkcontribperformanceloadtesticalpy">CalendarServer/trunk/contrib/performance/loadtest/ical.py</a></li>
<li><a href="#CalendarServertrunkcontribperformanceloadtestprofilespy">CalendarServer/trunk/contrib/performance/loadtest/profiles.py</a></li>
<li><a href="#CalendarServertrunkcontribperformanceloadtesttest_icalpy">CalendarServer/trunk/contrib/performance/loadtest/test_ical.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcontribperformanceloadtestclientsplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/clients.plist (15654 => 15655)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -357,41 +357,7 @@
</span><span class="cx">                                                 &lt;/dict&gt;
</span><span class="cx">                                         &lt;/dict&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;!-- Picks a random event and attaches --&gt;
-                                        &lt;dict&gt;
-                                                &lt;key&gt;class&lt;/key&gt;
-                                                &lt;string&gt;contrib.performance.loadtest.profiles.Attacher&lt;/string&gt;
</del><span class="cx"> 
</span><del>-                                                &lt;key&gt;params&lt;/key&gt;
-                                                &lt;dict&gt;
-                                                        &lt;key&gt;enabled&lt;/key&gt;
-                                                        &lt;false/&gt;
-
-                                                        &lt;!-- Define the interval (in seconds) at which this profile will use
-                                                                its client to create a new event. --&gt;
-                                                        &lt;key&gt;interval&lt;/key&gt;
-                                                        &lt;integer&gt;120&lt;/integer&gt;
-
-                                                        &lt;!-- Define the attachment size distribution. --&gt;
-                                                        &lt;key&gt;fileSizeDistribution&lt;/key&gt;
-                                                        &lt;dict&gt;
-                                                                &lt;key&gt;type&lt;/key&gt;
-                                                                &lt;string&gt;contrib.performance.stats.NormalDistribution&lt;/string&gt;
-                                                                &lt;key&gt;params&lt;/key&gt;
-                                                                &lt;dict&gt;
-                                                                        &lt;!-- mu gives the mean of the normal distribution (in bytes). --&gt;
-                                                                        &lt;key&gt;mu&lt;/key&gt;
-                                                                        &lt;integer&gt;500000&lt;/integer&gt;
-
-                                                                        &lt;!-- and sigma gives its standard deviation. --&gt;
-                                                                        &lt;key&gt;sigma&lt;/key&gt;
-                                                                        &lt;integer&gt;100000&lt;/integer&gt;
-                                                                &lt;/dict&gt;
-                                                        &lt;/dict&gt;
-
-                                                &lt;/dict&gt;
-                                        &lt;/dict&gt;
-
</del><span class="cx">                                         &lt;!-- Removes events from calendars exceeding a threshold --&gt;
</span><span class="cx">                                         &lt;dict&gt;
</span><span class="cx">                                                 &lt;key&gt;class&lt;/key&gt;
</span><span class="lines">@@ -429,6 +395,10 @@
</span><span class="cx">                                                         &lt;key&gt;interval&lt;/key&gt;
</span><span class="cx">                                                         &lt;integer&gt;1800&lt;/integer&gt;
</span><span class="cx"> 
</span><ins>+                                                        &lt;!-- Only share a collection with up to this many sharees --&gt;
+                                                        &lt;key&gt;maxSharees&lt;/key&gt;
+                                                        &lt;integer&gt;3&lt;/integer&gt;
+
</ins><span class="cx">                                                 &lt;/dict&gt;
</span><span class="cx">                                         &lt;/dict&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -744,12 +714,12 @@
</span><span class="cx">                                                 &lt;key&gt;params&lt;/key&gt;
</span><span class="cx">                                                 &lt;dict&gt;
</span><span class="cx">                                                         &lt;key&gt;enabled&lt;/key&gt;
</span><del>-                                                        &lt;false/&gt;
</del><ins>+                                                        &lt;true/&gt;
</ins><span class="cx"> 
</span><span class="cx">                                                         &lt;!-- Define the interval (in seconds) at which this profile will use
</span><span class="cx">                                                                 its client to run a report. --&gt;
</span><span class="cx">                                                         &lt;key&gt;interval&lt;/key&gt;
</span><del>-                                                        &lt;integer&gt;10&lt;/integer&gt;
</del><ins>+                                                        &lt;integer&gt;300&lt;/integer&gt;
</ins><span class="cx"> 
</span><span class="cx">                                                 &lt;/dict&gt;
</span><span class="cx">                                         &lt;/dict&gt;
</span><span class="lines">@@ -769,7 +739,7 @@
</span><span class="cx">                                                         &lt;!-- Define the interval (in seconds) at which this profile will use
</span><span class="cx">                                                                 its client to refresh. --&gt;
</span><span class="cx">                                                         &lt;key&gt;interval&lt;/key&gt;
</span><del>-                                                        &lt;integer&gt;1800&lt;/integer&gt;
</del><ins>+                                                        &lt;integer&gt;300&lt;/integer&gt;
</ins><span class="cx"> 
</span><span class="cx">                                                 &lt;/dict&gt;
</span><span class="cx">                                         &lt;/dict&gt;
</span></span></pre></div>
<a id="CalendarServertrunkcontribperformanceloadtesticalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py (15654 => 15655)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx"> class Calendar(object):
</span><span class="cx">     def __init__(
</span><span class="cx">         self, resourceType, componentTypes, name, url, changeToken,
</span><del>-        shared=False, sharedByMe=False
</del><ins>+        shared=False, sharedByMe=False, invitees=None
</ins><span class="cx">     ):
</span><span class="cx">         self.resourceType = resourceType
</span><span class="cx">         self.componentTypes = componentTypes
</span><span class="lines">@@ -225,6 +225,7 @@
</span><span class="cx">         self.events = {}
</span><span class="cx">         self.shared = shared
</span><span class="cx">         self.sharedByMe = sharedByMe
</span><ins>+        self.invitees = invitees if invitees else []
</ins><span class="cx"> 
</span><span class="cx">         if self.name is None and self.url is not None:
</span><span class="cx">             self.name = self.url.rstrip(&quot;/&quot;).split(&quot;/&quot;)[-1]
</span><span class="lines">@@ -240,6 +241,7 @@
</span><span class="cx">             result[attr] = getattr(self, attr)
</span><span class="cx">         result[&quot;componentTypes&quot;] = list(sorted(self.componentTypes))
</span><span class="cx">         result[&quot;events&quot;] = sorted(self.events.keys())
</span><ins>+        result[&quot;invitees&quot;] = sorted(self.invitees)
</ins><span class="cx">         return result
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -253,6 +255,7 @@
</span><span class="cx">         for attr in (&quot;resourceType&quot;, &quot;name&quot;, &quot;url&quot;, &quot;changeToken&quot;, &quot;shared&quot;, &quot;sharedByMe&quot;):
</span><span class="cx">             setattr(calendar, attr, u2str(data[attr]))
</span><span class="cx">         calendar.componentTypes = set(map(u2str, data[&quot;componentTypes&quot;]))
</span><ins>+        calendar.invitees = map(u2str, data[&quot;invitees&quot;])
</ins><span class="cx"> 
</span><span class="cx">         for event in data[&quot;events&quot;]:
</span><span class="cx">             url = urljoin(calendar.url, event)
</span><span class="lines">@@ -708,7 +711,6 @@
</span><span class="cx">             StringProducer(body),
</span><span class="cx">             method_label=method_label,
</span><span class="cx">         )
</span><del>-
</del><span class="cx">         result = self._parseMultiStatus(responseBody) if response.code == MULTI_STATUS else None
</span><span class="cx"> 
</span><span class="cx">         returnValue((response, result,))
</span><span class="lines">@@ -965,7 +967,18 @@
</span><span class="cx">             )
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @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=&quot;POST{unshare-calendar}&quot;
+                )
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _extractPrincipalDetails(self):
</span><span class="cx">         # Using the actual principal URL, retrieve principal information
</span><span class="lines">@@ -1082,6 +1095,17 @@
</span><span class="cx">                     for comp in nodes[caldavxml.supported_calendar_component_set]:
</span><span class="cx">                         componentTypes.add(comp.get(&quot;name&quot;).upper())
</span><span class="cx"> 
</span><ins>+                # 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
+
</ins><span class="cx">                 calendars.append(Calendar(
</span><span class="cx">                     resourceType,
</span><span class="cx">                     componentTypes,
</span><span class="lines">@@ -1089,7 +1113,8 @@
</span><span class="cx">                     href,
</span><span class="cx">                     textProps.get(changeTag, None),
</span><span class="cx">                     shared=isShared,
</span><del>-                    sharedByMe=isSharedByMe
</del><ins>+                    sharedByMe=isSharedByMe,
+                    invitees=invitees
</ins><span class="cx">                 ))
</span><span class="cx"> 
</span><span class="cx">                 # Also monitor shared-to-me calendars
</span><span class="lines">@@ -1496,6 +1521,7 @@
</span><span class="cx">             elif self._calendars[cal.url].changeToken != newToken:
</span><span class="cx">                 # Calendar changed - reload it
</span><span class="cx">                 yield self._updateCalendar(self._calendars[cal.url], newToken)
</span><ins>+                self._calendars[cal.url].invitees = cal.invitees
</ins><span class="cx"> 
</span><span class="cx">         # Clean out previously seen collections that are no longer on the server
</span><span class="cx">         currentCalendarUris = [c.url for c in calendars]
</span><span class="lines">@@ -1531,6 +1557,10 @@
</span><span class="cx">         pushKeys = self.ampPushKeys.values()
</span><span class="cx">         self._monitorAmpPush(calendarHomeSet, pushKeys)
</span><span class="cx"> 
</span><ins>+        # if firstTime:
+        #     # clear out shared calendars
+        #     yield self.unshareAll()
+
</ins><span class="cx">         returnValue(True)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunkcontribperformanceloadtestprofilespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/profiles.py (15654 => 15655)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -827,10 +827,12 @@
</span><span class="cx">     def setParameters(
</span><span class="cx">         self,
</span><span class="cx">         enabled=True,
</span><del>-        interval=60
</del><ins>+        interval=60,
+        maxSharees=3
</ins><span class="cx">     ):
</span><span class="cx">         self.enabled = enabled
</span><span class="cx">         self._interval = interval
</span><ins>+        self._maxSharees = maxSharees
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def run(self):
</span><span class="lines">@@ -861,6 +863,10 @@
</span><span class="cx">         if not calendar:
</span><span class="cx">             returnValue(None)
</span><span class="cx"> 
</span><ins>+        # don't exceed maxSharees
+        if len(calendar.invitees) &gt;= self._maxSharees:
+            returnValue(None)
+
</ins><span class="cx">         # pick a random sharee
</span><span class="cx">         shareeRecord = self._sim.getRandomUserRecord(besides=self._number)
</span><span class="cx">         if shareeRecord is None:
</span></span></pre></div>
<a id="CalendarServertrunkcontribperformanceloadtesttest_icalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/test_ical.py (15654 => 15655)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1549,7 +1549,7 @@
</span><span class="cx">         self.client._events.update(dict([[event.url, event] for event in events]))
</span><span class="cx"> 
</span><span class="cx">         calendars = (
</span><del>-            Calendar(str(caldavxml.calendar), set(('VEVENT',)), u'calendar', u'/home/calendar/', &quot;123&quot;),
</del><ins>+            Calendar(str(caldavxml.calendar), set(('VEVENT',)), u'calendar', u'/home/calendar/', &quot;123&quot;, invitees=[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]),
</ins><span class="cx">             Calendar(str(caldavxml.calendar), set(('VTODO',)), u'tasks', u'/home/tasks/', &quot;456&quot;),
</span><span class="cx">             Calendar(str(caldavxml.schedule_inbox), set(('VEVENT', &quot;VTODO&quot;,)), u'calendar', u'/home/inbox/', &quot;789&quot;),
</span><span class="cx">         )
</span><span class="lines">@@ -1596,6 +1596,11 @@
</span><span class="cx">       &quot;componentTypes&quot;: [
</span><span class="cx">         &quot;VEVENT&quot;
</span><span class="cx">       ],
</span><ins>+      &quot;invitees&quot;: [
+        &quot;a&quot;,
+        &quot;b&quot;,
+        &quot;c&quot;
+      ],
</ins><span class="cx">       &quot;url&quot;: &quot;/home/calendar/&quot;,
</span><span class="cx">       &quot;events&quot;: [
</span><span class="cx">         &quot;1.ics&quot;
</span><span class="lines">@@ -1611,6 +1616,7 @@
</span><span class="cx">         &quot;VEVENT&quot;,
</span><span class="cx">         &quot;VTODO&quot;
</span><span class="cx">       ],
</span><ins>+      &quot;invitees&quot;: [],
</ins><span class="cx">       &quot;url&quot;: &quot;/home/inbox/&quot;,
</span><span class="cx">       &quot;events&quot;: [
</span><span class="cx">         &quot;i1.ics&quot;
</span><span class="lines">@@ -1625,6 +1631,7 @@
</span><span class="cx">       &quot;componentTypes&quot;: [
</span><span class="cx">         &quot;VTODO&quot;
</span><span class="cx">       ],
</span><ins>+      &quot;invitees&quot;: [],
</ins><span class="cx">       &quot;url&quot;: &quot;/home/tasks/&quot;,
</span><span class="cx">       &quot;events&quot;: []
</span><span class="cx">     }
</span><span class="lines">@@ -1705,7 +1712,6 @@
</span><span class="cx">   &quot;calendars&quot;: [
</span><span class="cx">     {
</span><span class="cx">       &quot;changeToken&quot;: &quot;321&quot;,
</span><del>-      &quot;homeToken&quot;: &quot;321&quot;,
</del><span class="cx">       &quot;attachmentsUrl&quot;: &quot;https://example.com/attachments/&quot;,
</span><span class="cx">       &quot;name&quot;: &quot;calendar&quot;,
</span><span class="cx">       &quot;shared&quot;: false,
</span><span class="lines">@@ -1714,6 +1720,11 @@
</span><span class="cx">       &quot;componentTypes&quot;: [
</span><span class="cx">         &quot;VEVENT&quot;
</span><span class="cx">       ],
</span><ins>+      &quot;invitees&quot;: [
+        &quot;a&quot;,
+        &quot;b&quot;,
+        &quot;c&quot;
+      ],
</ins><span class="cx">       &quot;url&quot;: &quot;/home/calendar/&quot;,
</span><span class="cx">       &quot;events&quot;: [
</span><span class="cx">         &quot;2.ics&quot;
</span><span class="lines">@@ -1729,6 +1740,11 @@
</span><span class="cx">         &quot;VEVENT&quot;,
</span><span class="cx">         &quot;VTODO&quot;
</span><span class="cx">       ],
</span><ins>+      &quot;invitees&quot;: [
+        &quot;a&quot;,
+        &quot;b&quot;,
+        &quot;c&quot;
+      ],
</ins><span class="cx">       &quot;url&quot;: &quot;/home/inbox/&quot;,
</span><span class="cx">       &quot;events&quot;: [
</span><span class="cx">         &quot;i2.ics&quot;
</span><span class="lines">@@ -1743,6 +1759,11 @@
</span><span class="cx">       &quot;componentTypes&quot;: [
</span><span class="cx">         &quot;VTODO&quot;
</span><span class="cx">       ],
</span><ins>+      &quot;invitees&quot;: [
+        &quot;a&quot;,
+        &quot;b&quot;,
+        &quot;c&quot;
+      ],
</ins><span class="cx">       &quot;url&quot;: &quot;/home/tasks/&quot;,
</span><span class="cx">       &quot;events&quot;: []
</span><span class="cx">     }
</span><span class="lines">@@ -1783,6 +1804,7 @@
</span><span class="cx">         self.assertEqual(self.client._calendars[&quot;/home/calendar/&quot;].name, &quot;calendar&quot;)
</span><span class="cx">         self.assertEqual(self.client._calendars[&quot;/home/calendar/&quot;].resourceType, &quot;{urn:ietf:params:xml:ns:caldav}calendar&quot;)
</span><span class="cx">         self.assertEqual(self.client._calendars[&quot;/home/calendar/&quot;].componentTypes, set((&quot;VEVENT&quot;,)))
</span><ins>+        self.assertEqual(self.client._calendars[&quot;/home/calendar/&quot;].invitees, [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;])
</ins><span class="cx">         self.assertTrue(&quot;/home/tasks/&quot; in self.client._calendars)
</span><span class="cx">         self.assertTrue(&quot;/home/inbox/&quot; in self.client._calendars)
</span><span class="cx">         self.assertEqual(self.client._calendars[&quot;/home/inbox/&quot;].componentTypes, set((&quot;VEVENT&quot;, &quot;VTODO&quot;,)))
</span></span></pre>
</div>
</div>

</body>
</html>