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

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 12 14:31:23 PST 2011


Revision: 8428
          http://trac.macosforge.org/projects/calendarserver/changeset/8428
Author:   cdaboo at apple.com
Date:     2011-12-12 14:31:22 -0800 (Mon, 12 Dec 2011)
Log Message:
-----------
Sim now generates VTODOs and takes supported-component-sets into account.

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

Modified: CalendarServer/trunk/contrib/performance/loadtest/config.dist.plist
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/config.dist.plist	2011-12-12 18:59:44 UTC (rev 8427)
+++ CalendarServer/trunk/contrib/performance/loadtest/config.dist.plist	2011-12-12 22:31:22 UTC (rev 8428)
@@ -261,6 +261,65 @@
 							</dict>
 						</dict>
 					</dict>
+
+					<!-- A task-creating profile, which will periodically create 
+						new tasks at a random time on a random calendar. -->
+					<dict>
+						<key>class</key>
+						<string>contrib.performance.loadtest.profiles.Tasker</string>
+
+						<key>params</key>
+						<dict>
+							<key>enabled</key>
+							<true/>
+
+							<!-- Define the interval (in seconds) at which this profile will use 
+								its client to create a new task. -->
+							<key>interval</key>
+							<integer>300</integer>
+
+							<!-- Define how due times (DUE) for the randomly generated tasks 
+								will be selected. This is an example of a "Distribution" parameter. The value 
+								for most "Distribution" parameters are interchangeable and extensible. -->
+							<key>taskDueDistribution</key>
+							<dict>
+
+								<!-- This distribution is pretty specialized. It produces timestamps 
+									in the near future, limited to certain days of the week and certain hours 
+									of the day. -->
+								<key>type</key>
+								<string>contrib.performance.stats.WorkDistribution</string>
+
+								<key>params</key>
+								<dict>
+									<!-- These are the days of the week the distribution will use. -->
+									<key>daysOfWeek</key>
+									<array>
+										<string>mon</string>
+										<string>tue</string>
+										<string>wed</string>
+										<string>thu</string>
+										<string>fri</string>
+									</array>
+
+									<!-- The earliest hour of a day at which an event might be scheduled. -->
+									<key>beginHour</key>
+									<integer>8</integer>
+
+									<!-- And the latest hour of a day (at which an event will be scheduled 
+										to begin!). -->
+									<key>endHour</key>
+									<integer>16</integer>
+
+									<!-- The timezone in which the event is scheduled. (XXX Does this 
+										really work right?) -->
+									<key>tzname</key>
+									<string>America/Los_Angeles</string>
+								</dict>
+							</dict>
+						</dict>
+					</dict>
+
 				</array>
 
 				<!-- Determine the frequency at which this client configuration will 

Modified: CalendarServer/trunk/contrib/performance/loadtest/config.plist
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/config.plist	2011-12-12 18:59:44 UTC (rev 8427)
+++ CalendarServer/trunk/contrib/performance/loadtest/config.plist	2011-12-12 22:31:22 UTC (rev 8428)
@@ -249,6 +249,65 @@
 							</dict>
 						</dict>
 					</dict>
+
+					<!-- A task-creating profile, which will periodically create 
+						new tasks at a random time on a random calendar. -->
+					<dict>
+						<key>class</key>
+						<string>contrib.performance.loadtest.profiles.Tasker</string>
+
+						<key>params</key>
+						<dict>
+							<key>enabled</key>
+							<true/>
+
+							<!-- Define the interval (in seconds) at which this profile will use 
+								its client to create a new task. -->
+							<key>interval</key>
+							<integer>300</integer>
+
+							<!-- Define how due times (DUE) for the randomly generated tasks 
+								will be selected. This is an example of a "Distribution" parameter. The value 
+								for most "Distribution" parameters are interchangeable and extensible. -->
+							<key>taskDueDistribution</key>
+							<dict>
+
+								<!-- This distribution is pretty specialized. It produces timestamps 
+									in the near future, limited to certain days of the week and certain hours 
+									of the day. -->
+								<key>type</key>
+								<string>contrib.performance.stats.WorkDistribution</string>
+
+								<key>params</key>
+								<dict>
+									<!-- These are the days of the week the distribution will use. -->
+									<key>daysOfWeek</key>
+									<array>
+										<string>mon</string>
+										<string>tue</string>
+										<string>wed</string>
+										<string>thu</string>
+										<string>fri</string>
+									</array>
+
+									<!-- The earliest hour of a day at which an event might be scheduled. -->
+									<key>beginHour</key>
+									<integer>8</integer>
+
+									<!-- And the latest hour of a day (at which an event will be scheduled 
+										to begin!). -->
+									<key>endHour</key>
+									<integer>16</integer>
+
+									<!-- The timezone in which the event is scheduled. (XXX Does this 
+										really work right?) -->
+									<key>tzname</key>
+									<string>America/Los_Angeles</string>
+								</dict>
+							</dict>
+						</dict>
+					</dict>
+
 				</array>
 
 				<!-- Determine the frequency at which this client configuration will 

Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py	2011-12-12 18:59:44 UTC (rev 8427)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py	2011-12-12 22:31:22 UTC (rev 8428)
@@ -104,8 +104,9 @@
 
 
 class Calendar(object):
-    def __init__(self, resourceType, name, url, ctag):
+    def __init__(self, resourceType, componentTypes, name, url, ctag):
         self.resourceType = resourceType
+        self.componentTypes = componentTypes
         self.name = name
         self.url = url
         self.ctag = ctag
@@ -316,8 +317,14 @@
             for nodeType in nodes[davxml.resourcetype].getchildren():
                 if nodeType.tag in self._CALENDAR_TYPES:
                     textProps = principals[principal].getTextProperties()
+                    componentTypes = set()
+                    if nodeType.tag == caldavxml.calendar:
+                        if caldavxml.supported_calendar_component_set in nodes:
+                            for comp in nodes[caldavxml.supported_calendar_component_set].getchildren():
+                                componentTypes.add(comp.get("name").upper())
                     calendars.append(Calendar(
                             nodeType.tag,
+                            componentTypes,
                             textProps.get(davxml.displayname, None),
                             principal,
                             textProps.get(csxml.getctag, None),

Modified: CalendarServer/trunk/contrib/performance/loadtest/profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2011-12-12 18:59:44 UTC (rev 8427)
+++ CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2011-12-12 22:31:22 UTC (rev 8428)
@@ -61,12 +61,12 @@
         pass
 
 
-    def _calendarsOfType(self, calendarType):
+    def _calendarsOfType(self, calendarType, componentType):
         return [
             cal 
             for cal 
             in self._client._calendars.itervalues() 
-            if cal.resourceType == calendarType]
+            if cal.resourceType == calendarType and componentType in cal.componentTypes]
 
 
     def _isSelfAttendee(self, attendee):
@@ -198,7 +198,7 @@
             change has been made.
         """
         # Find calendars which are eligible for invites
-        calendars = self._calendarsOfType(caldavxml.calendar)
+        calendars = self._calendarsOfType(caldavxml.calendar, "VEVENT")
 
         while calendars:
             # Pick one at random from which to try to select an event
@@ -442,7 +442,7 @@
 
 
     def _addEvent(self):
-        calendars = self._calendarsOfType(caldavxml.calendar)
+        calendars = self._calendarsOfType(caldavxml.calendar, "VEVENT")
 
         while calendars:
             calendar = self.random.choice(calendars)
@@ -466,6 +466,65 @@
             return self._newOperation("create", d)
 
 
+class Tasker(ProfileBase):
+    """
+    A Calendar user who creates new tasks.
+    """
+    _taskTemplate = Component.fromString("""\
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.3//EN
+CALSCALE:GREGORIAN
+BEGIN:VTODO
+CREATED:20101018T155431Z
+UID:C98AD237-55AD-4F7D-9009-0D355D835822
+SUMMARY:Simple task
+DUE;TZID=America/New_York:20101021T120000
+DTSTAMP:20101018T155438Z
+END:VTODO
+END:VCALENDAR
+""".replace("\n", "\r\n"))
+
+    def setParameters(
+        self,
+        enabled=True,
+        interval=25,
+        taskDueDistribution=NearFutureDistribution(),
+    ):
+        self.enabled = enabled
+        self._interval = interval
+        self._taskStartDistribution = taskDueDistribution
+
+
+    def run(self):
+        self._call = LoopingCall(self._addTask)
+        self._call.clock = self._reactor
+        return self._call.start(self._interval)
+
+
+    def _addTask(self):
+        calendars = self._calendarsOfType(caldavxml.calendar, "VTODO")
+
+        while calendars:
+            calendar = self.random.choice(calendars)
+            calendars.remove(calendar)
+
+            # Copy the template task and fill in some of its fields
+            # to make a new task to create on the calendar.
+            vcalendar = self._taskTemplate.duplicate()
+            vtodo = vcalendar.mainComponent()
+            uid = str(uuid4())
+            due = self._taskStartDistribution.sample()
+            vtodo.replaceProperty(Property("CREATED", PyCalendarDateTime.getNowUTC()))
+            vtodo.replaceProperty(Property("DTSTAMP", PyCalendarDateTime.getNowUTC()))
+            vtodo.replaceProperty(Property("DUE", due))
+            vtodo.replaceProperty(Property("UID", uid))
+
+            href = '%s%s.ics' % (calendar.url, uid)
+            d = self._client.addEvent(href, vcalendar)
+            return self._newOperation("create", d)
+
+
 class OperationLogger(SummarizingMixin):
     """
     Profiles will initiate operations which may span multiple requests.  Start
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111212/3730a224/attachment-0001.html>


More information about the calendarserver-changes mailing list