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

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 21 19:16:13 PDT 2014


Revision: 13781
          http://trac.calendarserver.org//changeset/13781
Author:   cdaboo at apple.com
Date:     2014-07-21 19:16:13 -0700 (Mon, 21 Jul 2014)
Log Message:
-----------
Fix sim tests.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/loadtest/sim.py
    CalendarServer/trunk/contrib/performance/loadtest/test_ical.py
    CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py
    CalendarServer/trunk/contrib/performance/loadtest/test_sim.py

Modified: CalendarServer/trunk/contrib/performance/loadtest/sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sim.py	2014-07-21 19:30:59 UTC (rev 13780)
+++ CalendarServer/trunk/contrib/performance/loadtest/sim.py	2014-07-22 02:16:13 UTC (rev 13781)
@@ -53,6 +53,7 @@
 from contrib.performance.loadtest.webadmin import LoadSimAdminResource
 
 
+
 class _DirectoryRecord(object):
     def __init__(self, uid, password, commonName, email, guid):
         self.uid = uid
@@ -68,15 +69,19 @@
 
 
 
-def generateRecords(count, uidPattern="user%d", passwordPattern="user%d",
-    namePattern="User %d", emailPattern="user%d at example.com"):
+def generateRecords(
+    count, uidPattern="user%d", passwordPattern="user%d",
+    namePattern="User %d", emailPattern="user%d at example.com",
+    guidPattern="user%d"
+):
     for i in xrange(count):
         i += 1
         uid = uidPattern % (i,)
         password = passwordPattern % (i,)
         name = namePattern % (i,)
         email = emailPattern % (i,)
-        yield _DirectoryRecord(uid, password, name, email)
+        guid = guidPattern % (i,)
+        yield _DirectoryRecord(uid, password, name, email, guid)
 
 
 
@@ -151,7 +156,7 @@
         ("clients", None, _defaultClients,
          "Configuration plist file name from which to read client parameters.",
          FilePath),
-        ]
+    ]
 
 
     def opt_logfile(self, filename):
@@ -194,7 +199,7 @@
             configFile = self['config'].open()
         except IOError, e:
             raise UsageError("--config %s: %s" % (
-                    self['config'].path, e.strerror))
+                self['config'].path, e.strerror))
         try:
             try:
                 self.config = readPlist(configFile)
@@ -207,7 +212,7 @@
             clientFile = self['clients'].open()
         except IOError, e:
             raise UsageError("--clients %s: %s" % (
-                    self['clients'].path, e.strerror))
+                self['clients'].path, e.strerror))
         try:
             try:
                 client_config = readPlist(clientFile)
@@ -327,8 +332,8 @@
                             namedAny(clientConfig["software"]),
                             cls._convertParams(clientConfig["params"]),
                             [ProfileType(
-                                    namedAny(profile["class"]),
-                                    cls._convertParams(profile["params"]))
+                                namedAny(profile["class"]),
+                                cls._convertParams(profile["params"]))
                              for profile in clientConfig["profiles"]]))
             if not parameters.clients:
                 parameters.addClient(1,

Modified: CalendarServer/trunk/contrib/performance/loadtest/test_ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_ical.py	2014-07-21 19:30:59 UTC (rev 13780)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_ical.py	2014-07-22 02:16:13 UTC (rev 13781)
@@ -403,6 +403,7 @@
 """.replace("\n", "\r\n") % {'UID': EVENT_UID}
 
 
+
 class EventTests(TestCase):
     """
     Tests for L{Event}.
@@ -1122,17 +1123,18 @@
     "xmpp": """\
         <xmpp-server xmlns='http://calendarserver.org/ns/'/>
         <xmpp-uri xmlns='http://calendarserver.org/ns/'/>""",
-    }
+}
 
 CALENDAR_HOME_PROPFIND_RESPONSE_WITH_XMPP = _CALENDAR_HOME_PROPFIND_RESPONSE_TEMPLATE % {
     "xmpp": """\
         <xmpp-server xmlns='http://calendarserver.org/ns/'>xmpp.example.invalid:1952</xmpp-server>
         <xmpp-uri xmlns='http://calendarserver.org/ns/'>xmpp:pubsub.xmpp.example.invalid?pubsub;node=/CalDAV/another.example.invalid/user01/</xmpp-uri>""",
-    }
+}
 
 CALENDAR_HOME_PROPFIND_RESPONSE_XMPP_MISSING = _CALENDAR_HOME_PROPFIND_RESPONSE_TEMPLATE % {"xmpp": ""}
 
 
+
 class MemoryResponse(object):
     def __init__(self, version, code, phrase, headers, bodyProducer):
         self.version = version
@@ -1157,7 +1159,8 @@
     def setUp(self):
         TimezoneCache.create()
         self.record = _DirectoryRecord(
-            u"user91", u"user91", u"User 91", u"user91 at example.org")
+            u"user91", u"user91", u"User 91", u"user91 at example.org", u"user91",
+        )
         serializePath = self.mktemp()
         os.mkdir(serializePath)
         self.client = OS_X_10_6(
@@ -1196,18 +1199,20 @@
         principal = principals['/principals/__uids__/user01/']
         self.assertEquals(
             principal.getHrefProperties(),
-            {davxml.principal_collection_set: URL(path='/principals/'),
-             caldavxml.calendar_home_set: URL(path='/calendars/__uids__/user01'),
-             caldavxml.calendar_user_address_set: (
+            {
+                davxml.principal_collection_set: URL(path='/principals/'),
+                caldavxml.calendar_home_set: URL(path='/calendars/__uids__/user01'),
+                caldavxml.calendar_user_address_set: (
                     URL(path='/principals/__uids__/user01/'),
                     URL(path='/principals/users/user01/'),
-                    ),
-             caldavxml.schedule_inbox_URL: URL(path='/calendars/__uids__/user01/inbox/'),
-             caldavxml.schedule_outbox_URL: URL(path='/calendars/__uids__/user01/outbox/'),
-             csxml.dropbox_home_URL: URL(path='/calendars/__uids__/user01/dropbox/'),
-             csxml.notification_URL: URL(path='/calendars/__uids__/user01/notification/'),
-             davxml.principal_URL: URL(path='/principals/__uids__/user01/'),
-             })
+                ),
+                caldavxml.schedule_inbox_URL: URL(path='/calendars/__uids__/user01/inbox/'),
+                caldavxml.schedule_outbox_URL: URL(path='/calendars/__uids__/user01/outbox/'),
+                csxml.dropbox_home_URL: URL(path='/calendars/__uids__/user01/dropbox/'),
+                csxml.notification_URL: URL(path='/calendars/__uids__/user01/notification/'),
+                davxml.principal_URL: URL(path='/principals/__uids__/user01/'),
+            }
+        )
         self.assertEquals(
             principal.getTextProperties(),
             {davxml.displayname: 'User 01'})
@@ -1258,12 +1263,13 @@
             home
         )
         self.assertEqual({
-                home: XMPPPush(
-                    "xmpp.example.invalid:1952",
-                    "xmpp:pubsub.xmpp.example.invalid?pubsub;node=/CalDAV/another.example.invalid/user01/",
-                    "/Some/Unique/Value"
-                    )},
-                         self.client.xmpp)
+            home: XMPPPush(
+                "xmpp.example.invalid:1952",
+                "xmpp:pubsub.xmpp.example.invalid?pubsub;node=/CalDAV/another.example.invalid/user01/",
+                "/Some/Unique/Value"
+            )},
+            self.client.xmpp
+        )
 
 
     def test_handleMissingXMPP(self):
@@ -1982,9 +1988,7 @@
             uid = vevent.resourceUID()
             dtstamp = vevent.mainComponent().propertyValue("DTSTAMP")
             dtstamp = dtstamp.getText()
-            self.assertEqual(
-"""\
-BEGIN:VCALENDAR
+            self.assertEqual("""BEGIN:VCALENDAR
 CALSCALE:GREGORIAN
 VERSION:2.0
 METHOD:REQUEST

Modified: CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py	2014-07-21 19:30:59 UTC (rev 13780)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_profiles.py	2014-07-22 02:16:13 UTC (rev 13781)
@@ -170,6 +170,7 @@
 """
 
 
+
 class AnyUser(object):
     def __getitem__(self, index):
         return _AnyRecord(index)
@@ -182,6 +183,7 @@
         self.password = u"user%02d" % (index,)
         self.commonName = u"User %02d" % (index,)
         self.email = u"user%02d at example.com" % (index,)
+        self.guid = u"user%02d" % (index,)
 
 
 
@@ -225,7 +227,8 @@
         self._pendingFailures = {}
         self.record = _DirectoryRecord(
             "user%02d" % (number,), "user%02d" % (number,),
-            "User %02d" % (number,), "user%02d at example.org" % (number,))
+            "User %02d" % (number,), "user%02d at example.org" % (number,),
+            "user%02d" % (number,))
         self.email = "mailto:user%02d at example.com" % (number,)
         self.uuid = "urn:uuid:user%02d" % (number,)
         self.rescheduled = set()
@@ -290,10 +293,11 @@
     def changeEventAttendee(self, href, old, new):
         if href in self.rescheduled:
             return fail(IncorrectResponseCode(
-                    NO_CONTENT,
-                    Response(
-                        ('HTTP', 1, 1), PRECONDITION_FAILED,
-                        'Precondition Failed', None, None)))
+                NO_CONTENT,
+                Response(
+                    ('HTTP', 1, 1), PRECONDITION_FAILED,
+                    'Precondition Failed', None, None))
+            )
 
         vevent = self._events[href].component
         vevent.mainComponent().removeProperty(old)
@@ -791,7 +795,10 @@
         client._events[event.url] = event
         accepter = Accepter(clock, self.sim, client, userNumber)
         accepter.random = Deterministic()
-        accepter.random.gauss = lambda mu, sigma: randomDelay
+
+        def _gauss(mu, sigma):
+            return randomDelay
+        accepter.random.gauss = _gauss
         accepter.eventChanged(event.url)
         accepter.eventChanged(event.url)
         clock.advance(randomDelay)
@@ -838,10 +845,11 @@
         inboxEvent = Event(client.serializeLocation(), inboxURL + u'4321.ics', None, vevent)
         client._setEvent(inboxEvent.url, inboxEvent)
         client._failDeleteWithObject(inboxEvent.url, IncorrectResponseCode(
-                    NO_CONTENT,
-                    Response(
-                        ('HTTP', 1, 1), PRECONDITION_FAILED,
-                        'Precondition Failed', None, None)))
+            NO_CONTENT,
+            Response(
+                ('HTTP', 1, 1), PRECONDITION_FAILED,
+                'Precondition Failed', None, None))
+        )
         accepter = Accepter(clock, self.sim, client, userNumber)
         accepter.eventChanged(inboxEvent.url)
         clock.advance(3)
@@ -1035,11 +1043,13 @@
         """
         logger = OperationLogger(outfile=StringIO())
         logger.observe(dict(
-                type='operation', phase='start', user='user01',
-                label='testing', lag=0.5))
+            type='operation', phase='start', user='user01',
+            label='testing', lag=0.5)
+        )
         logger.observe(dict(
-                type='operation', phase='end', user='user01',
-                duration=0.35, label='testing', success=True))
+            type='operation', phase='end', user='user01',
+            duration=0.35, label='testing', success=True)
+        )
         self.assertEqual([], logger.failures())
 
 
@@ -1052,8 +1062,9 @@
         logger = OperationLogger(outfile=StringIO())
         for lag in [100.0, 1100.0, 1200.0]:
             logger.observe(dict(
-                    type='operation', phase='start', user='user01',
-                    label='testing', lag=lag))
+                type='operation', phase='start', user='user01',
+                label='testing', lag=lag)
+            )
         self.assertEqual(
             ["Median TESTING scheduling lag greater than 1000.0ms"],
             logger.failures())
@@ -1068,11 +1079,13 @@
         logger = OperationLogger(outfile=StringIO())
         for _ignore in range(98):
             logger.observe(dict(
-                    type='operation', phase='end', user='user01',
-                    duration=0.25, label='testing', success=True))
+                type='operation', phase='end', user='user01',
+                duration=0.25, label='testing', success=True)
+            )
         logger.observe(dict(
-                type='operation', phase='end', user='user01',
-                duration=0.25, label='testing', success=False))
+            type='operation', phase='end', user='user01',
+            duration=0.25, label='testing', success=False)
+        )
         self.assertEqual(
             ["Greater than 1% TESTING failed"],
             logger.failures())

Modified: CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_sim.py	2014-07-21 19:30:59 UTC (rev 13780)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_sim.py	2014-07-22 02:16:13 UTC (rev 13781)
@@ -56,6 +56,7 @@
 VALID_CONFIG_PLIST = writePlistToString(VALID_CONFIG)
 
 
+
 class SimOptionsTests(TestCase):
     def test_defaultConfig(self):
         """
@@ -108,7 +109,7 @@
     def _user(self, name):
         password = 'password-' + name
         email = name + "@example.com"
-        record = _DirectoryRecord(name, password, name, email)
+        record = _DirectoryRecord(name, password, name, email, name)
         return record
 
 
@@ -283,7 +284,7 @@
         simulation.
         """
         accounts = FilePath(self.mktemp())
-        accounts.setContent("foo,bar,baz,quux\nfoo2,bar2,baz2,quux2\n")
+        accounts.setContent("foo,bar,baz,quux,goo\nfoo2,bar2,baz2,quux2,goo2\n")
         config = VALID_CONFIG.copy()
         config["accounts"] = {
             "loader": "contrib.performance.loadtest.sim.recordsFromCSVFile",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140721/8efed372/attachment-0001.html>


More information about the calendarserver-changes mailing list