[CalendarServer-changes] [6666] CalendarServer/trunk/contrib/performance

source_changes at macosforge.org source_changes at macosforge.org
Thu Dec 2 13:09:20 PST 2010


Revision: 6666
          http://trac.macosforge.org/projects/calendarserver/changeset/6666
Author:   exarkun at twistedmatrix.com
Date:     2010-12-02 13:09:16 -0800 (Thu, 02 Dec 2010)
Log Message:
-----------
Check for the expected response code and bail out if it is anything else.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/_event_change.py
    CalendarServer/trunk/contrib/performance/benchlib.py
    CalendarServer/trunk/contrib/performance/event.py
    CalendarServer/trunk/contrib/performance/event_delete.py
    CalendarServer/trunk/contrib/performance/event_move.py
    CalendarServer/trunk/contrib/performance/find_calendars.py
    CalendarServer/trunk/contrib/performance/find_events.py
    CalendarServer/trunk/contrib/performance/vfreebusy.py

Modified: CalendarServer/trunk/contrib/performance/_event_change.py
===================================================================
--- CalendarServer/trunk/contrib/performance/_event_change.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/_event_change.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -26,6 +26,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import NO_CONTENT
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -89,7 +90,8 @@
         dtrace, samples,
         agent, (('PUT', url, headers, StringProducer(replacer(event, i)))
                 for i, (event, url)
-                in enumerate(events)).next)
+                in enumerate(events)).next,
+        NO_CONTENT)
     returnValue(samples)
 
 
@@ -110,5 +112,6 @@
     samples = yield sample(
         dtrace, samples,
         agent, (('PUT', url, headers, StringProducer(replacer(event, i)))
-                for i in count(1)).next)
+                for i in count(1)).next,
+        NO_CONTENT)
     returnValue(samples)

Modified: CalendarServer/trunk/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/benchlib.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -82,7 +82,7 @@
 
 
 @inlineCallbacks
-def sample(dtrace, samples, agent, paramgen, concurrency=1):
+def sample(dtrace, samples, agent, paramgen, responseCode, concurrency=1):
     sem = DeferredSemaphore(concurrency)
 
     urlopen = Duration('HTTP')
@@ -93,6 +93,10 @@
         before = time()
         d = agent.request(*paramgen())
         def cbResponse(response):
+            if response.code != responseCode:
+                raise Exception(
+                    "Unexpected response code received: %d" % (response.code,))
+
             d = readBody(response)
             def cbBody(ignored):
                 after = time()

Modified: CalendarServer/trunk/contrib/performance/event.py
===================================================================
--- CalendarServer/trunk/contrib/performance/event.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/event.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -27,6 +27,7 @@
 from twisted.internet import reactor
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import CREATED
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -146,6 +147,7 @@
         dtrace, samples, 
         agent, ((method, uri % (i,), headers, StringProducer(body))
                 for (i, body)
-                in events).next)
+                in events).next,
+        CREATED)
     returnValue(samples)
 

Modified: CalendarServer/trunk/contrib/performance/event_delete.py
===================================================================
--- CalendarServer/trunk/contrib/performance/event_delete.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/event_delete.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -25,6 +25,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import NO_CONTENT
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -70,6 +71,7 @@
     # Now delete them all
     samples = yield sample(
         dtrace, samples,
-        agent, (('DELETE', url) for url in urls).next)
+        agent, (('DELETE', url) for url in urls).next,
+        NO_CONTENT)
     returnValue(samples)
 

Modified: CalendarServer/trunk/contrib/performance/event_move.py
===================================================================
--- CalendarServer/trunk/contrib/performance/event_move.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/event_move.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -21,6 +21,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import CREATED
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -72,5 +73,5 @@
          Headers({"destination": [dest.next()], "overwrite": ["F"]}))
         for i in count(1))
 
-    samples = yield sample(dtrace, samples, agent, params.next)
+    samples = yield sample(dtrace, samples, agent, params.next, CREATED)
     returnValue(samples)

Modified: CalendarServer/trunk/contrib/performance/find_calendars.py
===================================================================
--- CalendarServer/trunk/contrib/performance/find_calendars.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/find_calendars.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -21,6 +21,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import MULTI_STATUS
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -93,7 +94,7 @@
          Headers({"depth": ["1"], "content-type": ["text/xml"]}), body)
         for i in count(1))
 
-    samples = yield sample(dtrace, samples, agent, params.next)
+    samples = yield sample(dtrace, samples, agent, params.next, MULTI_STATUS)
 
     # Delete the calendars we created to leave the server in roughly
     # the same state as we found it.

Modified: CalendarServer/trunk/contrib/performance/find_events.py
===================================================================
--- CalendarServer/trunk/contrib/performance/find_events.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/find_events.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -21,6 +21,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import MULTI_STATUS
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -75,11 +76,11 @@
     body = StringProducer(PROPFIND)
     params = (
         ('PROPFIND',
-         '%s/calendars/__uids__/%s/find-events/' % (uri, user),
+         '%scalendars/__uids__/%s/find-events/' % (uri, user),
          Headers({"depth": ["1"], "content-type": ["text/xml"]}), body)
         for i in count(1))
 
-    samples = yield sample(dtrace, samples, agent, params.next)
+    samples = yield sample(dtrace, samples, agent, params.next, MULTI_STATUS)
 
     # Delete the calendar we created to leave the server in roughly
     # the same state as we found it.

Modified: CalendarServer/trunk/contrib/performance/vfreebusy.py
===================================================================
--- CalendarServer/trunk/contrib/performance/vfreebusy.py	2010-12-02 20:38:42 UTC (rev 6665)
+++ CalendarServer/trunk/contrib/performance/vfreebusy.py	2010-12-02 21:09:16 UTC (rev 6666)
@@ -26,6 +26,7 @@
 from twisted.internet import reactor
 from twisted.web.client import Agent
 from twisted.web.http_headers import Headers
+from twisted.web.http import OK
 
 from httpauth import AuthHandlerAgent
 from httpclient import StringProducer
@@ -140,6 +141,7 @@
 
     samples = yield sample(
         dtrace, samples,
-        agent, lambda: (method, uri, headers, body))
+        agent, lambda: (method, uri, headers, body),
+        OK)
     returnValue(samples)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101202/204f8a50/attachment-0001.html>


More information about the calendarserver-changes mailing list