[CalendarServer-changes] [7791] CalendarServer/trunk/contrib/performance/loadtest
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 14 09:08:57 PDT 2011
Revision: 7791
http://trac.macosforge.org/projects/calendarserver/changeset/7791
Author: cdaboo at apple.com
Date: 2011-07-14 09:08:56 -0700 (Thu, 14 Jul 2011)
Log Message:
-----------
Add a __main__ for easier launching. Use default location for accounts.csv if path is empty.
Modified Paths:
--------------
CalendarServer/trunk/contrib/performance/loadtest/sim.py
CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
Modified: CalendarServer/trunk/contrib/performance/loadtest/sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sim.py 2011-07-14 15:13:11 UTC (rev 7790)
+++ CalendarServer/trunk/contrib/performance/loadtest/sim.py 2011-07-14 16:08:56 UTC (rev 7791)
@@ -43,10 +43,10 @@
def recordsFromCSVFile(path):
- if path.startswith('/'):
+ if path:
pathObj = FilePath(path)
else:
- pathObj = FilePath(__file__).parent().preauthChild(path)
+ pathObj = FilePath(__file__).sibling("accounts.csv")
return [
_DirectoryRecord(*line.decode('utf-8').split(u','))
for line
@@ -291,3 +291,6 @@
print 'PASS'
main = LoadSimulator.main
+
+if __name__ == '__main__':
+ main()
Modified: CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-14 15:13:11 UTC (rev 7790)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-14 16:08:56 UTC (rev 7791)
@@ -234,6 +234,32 @@
self.assertEqual(sim.records[1].email, 'quux2')
+ def test_loadDefaultAccountsFromFile(self):
+ """
+ L{LoadSimulator.fromCommandLine} takes an account loader (with
+ empty path)from the config file and uses it to create user
+ records for use in the simulation.
+ """
+ config = VALID_CONFIG.copy()
+ config["accounts"] = {
+ "loader": "loadtest.sim.recordsFromCSVFile",
+ "params": {
+ "path": ""},
+ }
+ configpath = FilePath(self.mktemp())
+ configpath.setContent(writePlistToString(config))
+ sim = LoadSimulator.fromCommandLine(['--config', configpath.path])
+ self.assertEqual(99, len(sim.records))
+ self.assertEqual(sim.records[0].uid, 'user01')
+ self.assertEqual(sim.records[0].password, 'user01')
+ self.assertEqual(sim.records[0].commonName, 'User 01')
+ self.assertEqual(sim.records[0].email, 'user01 at example.com')
+ self.assertEqual(sim.records[98].uid, 'user99')
+ self.assertEqual(sim.records[98].password, 'user99')
+ self.assertEqual(sim.records[98].commonName, 'User 99')
+ self.assertEqual(sim.records[98].email, 'user99 at example.com')
+
+
def test_specifyRuntime(self):
"""
L{LoadSimulator.fromCommandLine} recognizes the I{--runtime} option to
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110714/240a6823/attachment-0001.html>
More information about the calendarserver-changes
mailing list