[CalendarServer-changes] [7715] CalendarServer/trunk/contrib/performance/loadtest
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 6 11:25:42 PDT 2011
Revision: 7715
http://trac.macosforge.org/projects/calendarserver/changeset/7715
Author: exarkun at twistedmatrix.com
Date: 2011-07-06 11:25:40 -0700 (Wed, 06 Jul 2011)
Log Message:
-----------
Let the total simulation runtime be specified as a command line argument
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-06 18:01:19 UTC (rev 7714)
+++ CalendarServer/trunk/contrib/performance/loadtest/sim.py 2011-07-06 18:25:40 UTC (rev 7715)
@@ -79,6 +79,11 @@
"""
config = None
+ optParameters = [
+ ("runtime", "t", None,
+ "Specify the limit limit (seconds) on the time to run the simulation.",
+ int)]
+
def opt_config(self, path):
"""
ini-syntax configuration file from which to read simulation
@@ -150,7 +155,8 @@
user information about the accounts on the server being put
under load.
"""
- def __init__(self, server, arrival, parameters, observers=None, records=None, reactor=None):
+ def __init__(self, server, arrival, parameters, observers=None,
+ records=None, reactor=None, runtime=None):
if reactor is None:
from twisted.internet import reactor
self.server = server
@@ -159,6 +165,7 @@
self.observers = observers
self.records = records
self.reactor = LagTrackingReactor(reactor)
+ self.runtime = runtime
@classmethod
@@ -212,7 +219,8 @@
records.extend(namedAny(loader)(**params))
return cls(server, arrival, parameters,
- observers=observers, records=records)
+ observers=observers, records=records,
+ runtime=options['runtime'])
@classmethod
def _convertParams(cls, params):
@@ -263,6 +271,8 @@
sim = self.createSimulator()
arrivalPolicy = self.createArrivalPolicy()
arrivalPolicy.run(sim)
+ if self.runtime is not None:
+ self.reactor.callLater(self.runtime, self.reactor.stop)
self.reactor.run()
for obs in self.observers:
obs.report()
Modified: CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-06 18:01:19 UTC (rev 7714)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-06 18:25:40 UTC (rev 7715)
@@ -208,7 +208,9 @@
def test_loadAccountsFromFile(self):
"""
- L{LoadSimulator.
+ L{LoadSimulator.fromCommandLine} takes an account loader from the
+ config file and uses it to create user records for use in the
+ simulation.
"""
accounts = FilePath(self.mktemp())
accounts.setContent("foo,bar,baz,quux\nfoo2,bar2,baz2,quux2\n")
@@ -232,6 +234,17 @@
self.assertEqual(sim.records[1].email, 'quux2')
+ def test_specifyRuntime(self):
+ """
+ L{LoadSimulator.fromCommandLine} recognizes the I{--runtime} option to
+ specify a limit on how long the simulation will run.
+ """
+ config = FilePath(self.mktemp())
+ config.setContent(VALID_CONFIG_PLIST)
+ sim = LoadSimulator.fromCommandLine(['--config', config.path, '--runtime', '123'])
+ self.assertEqual(123, sim.runtime)
+
+
def test_loadServerConfig(self):
"""
The Calendar Server host and port are loaded from the [server]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110706/f9f81469/attachment.html>
More information about the calendarserver-changes
mailing list