<!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>[15362] 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/15362">15362</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 13:00:49 -0800 (Thu, 03 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>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.</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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcontribperformanceloadtestclientsplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/clients.plist (15361 => 15362)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -615,6 +615,19 @@
</span><span class="cx">                                                 </dict>
</span><span class="cx">                                         </dict>
</span><span class="cx">
</span><ins>+
+                                        <!-- 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>
+
</ins><span class="cx">                                         <!-- A task-creating profile, which will periodically create
</span><span class="cx">                                                 new tasks at a random time on a random calendar. -->
</span><span class="cx">                                         <dict>
</span></span></pre></div>
<a id="CalendarServertrunkcontribperformanceloadtesticalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py (15361 => 15362)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -700,6 +700,22 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><ins>+ 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
</ins><span class="cx"> def _report(self, url, body, depth='0', allowedStatus=(MULTI_STATUS,), otherTokens=False, method_label=None):
</span><span class="cx"> """
</span><span class="cx"> Issue a REPORT on the chosen URL
</span><span class="lines">@@ -886,9 +902,11 @@
</span><span class="cx"> isNotifications = False
</span><span class="cx"> isShared = False
</span><span class="cx"> isSharedByMe = False
</span><ins>+ resourceType = None
</ins><span class="cx"> for nodeType in nodes[davxml.resourcetype]:
</span><span class="cx"> if nodeType.tag in self._CALENDAR_TYPES:
</span><span class="cx"> isCalendar = True
</span><ins>+ resourceType = nodeType.tag
</ins><span class="cx"> elif nodeType.tag == csxml.notification:
</span><span class="cx"> isNotifications = True
</span><span class="cx"> elif nodeType.tag.startswith("{http://calendarserver.org/ns/}shared"):
</span><span class="lines">@@ -905,7 +923,7 @@
</span><span class="cx"> componentTypes.add(comp.get("name").upper())
</span><span class="cx">
</span><span class="cx"> calendars.append(Calendar(
</span><del>- nodeType.tag,
</del><ins>+ resourceType,
</ins><span class="cx"> componentTypes,
</span><span class="cx"> textProps.get(davxml.displayname, None),
</span><span class="cx"> href,
</span><span class="lines">@@ -1985,6 +2003,7 @@
</span><span class="cx"> method_label="POST{attach}"
</span><span class="cx"> )
</span><span class="cx"> body = yield readBody(response)
</span><ins>+ yield self.updateEvent(href)
</ins><span class="cx"> returnValue(body)
</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 (15361 => 15362)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -525,7 +525,48 @@
</span><span class="cx"> return accepted
</span><span class="cx">
</span><span class="cx">
</span><ins>+class AttachmentDownloader(ProfileBase):
+ """
+ A Calendar user who downloads attachments.
+ """
+ def setParameters(
+ self,
+ enabled=True,
+ ):
+ self.enabled = enabled
</ins><span class="cx">
</span><ins>+ 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)
+
+
+
</ins><span class="cx"> class Eventer(ProfileBase):
</span><span class="cx"> """
</span><span class="cx"> A Calendar user who creates new events.
</span><span class="lines">@@ -622,13 +663,14 @@
</span><span class="cx"> vevent = component.mainComponent()
</span><span class="cx">
</span><span class="cx"> label = yield self.modifyEvent(event.url, vevent)
</span><del>- vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
</del><ins>+ if label:
+ vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
</ins><span class="cx">
</span><del>- event.component = component
- yield self._newOperation(
- label,
- self._client.changeEvent(event.url)
- )
</del><ins>+ event.component = component
+ yield self._newOperation(
+ label,
+ self._client.changeEvent(event.url)
+ )
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def run(self):
</span><span class="lines">@@ -700,7 +742,7 @@
</span><span class="cx"> def modifyEvent(self, href, vevent):
</span><span class="cx"> fileSize = int(self._fileSize.sample())
</span><span class="cx"> yield self._client.postAttachment(href, 'x' * fileSize)
</span><del>- returnValue("attach{files}")
</del><ins>+ returnValue(None)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>