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

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 8 11:08:58 PDT 2011


Revision: 7744
          http://trac.macosforge.org/projects/calendarserver/changeset/7744
Author:   exarkun at twistedmatrix.com
Date:     2011-07-08 11:08:58 -0700 (Fri, 08 Jul 2011)
Log Message:
-----------
Include user count in the end-of-sim report; some notes about other things to do at the end.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/loadtest/population.py

Added Paths:
-----------
    CalendarServer/trunk/contrib/performance/loadtest/test_population.py

Modified: CalendarServer/trunk/contrib/performance/loadtest/population.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/population.py	2011-07-08 13:20:53 UTC (rev 7743)
+++ CalendarServer/trunk/contrib/performance/loadtest/population.py	2011-07-08 18:08:58 UTC (rev 7744)
@@ -263,6 +263,13 @@
 
 
 class ReportStatistics(StatisticsBase, SummarizingMixin):
+    """
+
+    @ivar _users: A C{set} containing all user UIDs which have been observed in
+        events.  When generating the final report, the size of this set is
+        reported as the number of users in the simulation.
+
+    """
     _fields = [
         ('operation', 10, '%10s'),
         ('count', 8, '%8s'),
@@ -274,15 +281,27 @@
 
     def __init__(self):
         self._perMethodTimes = {}
+        self._users = set()
 
 
+    def countUsers(self):
+        return len(self._users)
+
+
     def eventReceived(self, event):
         dataset = self._perMethodTimes.setdefault(event['method'], [])
         dataset.append((event['success'], event['duration']))
+        self._users.add(event['user'])
 
 
+    def printMiscellaneous(self, items):
+        for k, v in sorted(items.iteritems()):
+            print k.title(), ':', v
+
+
     def report(self):
         print
+        self.printMiscellaneous({'users': self.countUsers()})
         self.printHeader([
                 (label, width)
                 for (label, width, fmt)
@@ -291,7 +310,15 @@
             [fmt for (label, width, fmt) in self._fields],
             sorted(self._perMethodTimes.items()))
 
+        # TODO
+        # Check for >1% request failure rate
+        #           >1% >5sec response rate
+        #           >5% >3sec response rate
+        # 
+        
 
+
+
 def main():
     import random
 

Added: CalendarServer/trunk/contrib/performance/loadtest/test_population.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_population.py	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_population.py	2011-07-08 18:08:58 UTC (rev 7744)
@@ -0,0 +1,41 @@
+##
+# Copyright (c) 2011 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##
+
+"""
+Tests for some things in L{loadtest.population}.
+"""
+
+from twisted.trial.unittest import TestCase
+
+from loadtest.population import ReportStatistics
+
+class ReportStatisticsTests(TestCase):
+    """
+    Tests for L{loadtest.population.ReportStatistics}.
+    """
+    def test_countUsers(self):
+        """
+        L{ReportStatistics.countUsers} returns the number of users observed to
+        have acted in the simulation.
+        """
+        logger = ReportStatistics()
+        users = ['user01', 'user02', 'user03']
+        for user in users:
+            logger.observe(dict(
+                    type='response', method='GET', success=True,
+                    duration=1.23, user=user))
+        self.assertEqual(len(users), logger.countUsers())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110708/7b99db22/attachment.html>


More information about the calendarserver-changes mailing list