[CalendarServer-changes] [7420] CalendarServer/trunk/contrib/performance/loadtest/ical.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 6 13:30:25 PDT 2011
Revision: 7420
http://trac.macosforge.org/projects/calendarserver/changeset/7420
Author: exarkun at twistedmatrix.com
Date: 2011-05-06 13:30:25 -0700 (Fri, 06 May 2011)
Log Message:
-----------
Add startup and poll aggregate log events; also serialize iCal calendar polling to produce accurate timing for the poll event (but this may need to be revisted)
Modified Paths:
--------------
CalendarServer/trunk/contrib/performance/loadtest/ical.py
Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py 2011-05-06 20:25:30 UTC (rev 7419)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py 2011-05-06 20:30:25 UTC (rev 7420)
@@ -30,6 +30,7 @@
from twisted.python.log import addObserver, err, msg
from twisted.python.filepath import FilePath
+from twisted.python.failure import Failure
from twisted.internet.defer import Deferred, inlineCallbacks, returnValue
from twisted.internet.task import LoopingCall
from twisted.web.http_headers import Headers
@@ -381,14 +382,16 @@
def _checkCalendarsForEvents(self, calendarHomeSet):
d = self._calendarHomePropfind(calendarHomeSet)
+ @inlineCallbacks
def cbCalendars(calendars):
for cal in calendars:
if self._calendars.setdefault(cal.url, cal).ctag != cal.ctag or True:
- self._updateCalendar(cal)
+ yield self._updateCalendar(cal)
+ d.addCallback(cbCalendars)
+ d = self._newOperation("poll", d)
def ebCalendars(reason):
reason.trap(IncorrectResponseCode)
- msg(type="aggregate", operation="poll", success=False)
- d.addCallbacks(cbCalendars, ebCalendars)
+ d.addErrback(ebCalendars)
d.addErrback(err, "Unexpected failure during calendar home poll")
return d
@@ -463,17 +466,34 @@
"""
pollCalendarHome = LoopingCall(
self._checkCalendarsForEvents, calendarHome)
- pollCalendarHome.start(self.calendarHomePollInterval)
+ pollCalendarHome.start(self.calendarHomePollInterval, now=False)
+ def _newOperation(self, label, deferred):
+ before = self.reactor.seconds()
+ msg(type="operation", phase="start", user=self.user, label=label)
+ def finished(passthrough):
+ success = not isinstance(passthrough, Failure)
+ after = self.reactor.seconds()
+ msg(type="operation", phase="end", duration=after - before,
+ user=self.user, label=label, success=success)
+ return passthrough
+ deferred.addBoth(finished)
+ return deferred
+
@inlineCallbacks
def run(self):
"""
Emulate a CalDAV client.
"""
- principal = yield self.startup()
- hrefs = principal.getHrefProperties()
- self._calendarCheckLoop(hrefs[caldavxml.calendar_home_set].toString())
+ @inlineCallbacks
+ def startup():
+ principal = yield self.startup()
+ hrefs = principal.getHrefProperties()
+ calendarHome = hrefs[caldavxml.calendar_home_set].toString()
+ yield self._checkCalendarsForEvents(calendarHome)
+ self._calendarCheckLoop(calendarHome)
+ yield self._newOperation("startup", startup())
# XXX Oops, should probably stop sometime.
yield Deferred()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110506/c61b7949/attachment.html>
More information about the calendarserver-changes
mailing list