[CalendarServer-changes] [7792] CalendarServer/trunk/contrib/performance/loadtest
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 14 09:31:57 PDT 2011
Revision: 7792
http://trac.macosforge.org/projects/calendarserver/changeset/7792
Author: exarkun at twistedmatrix.com
Date: 2011-07-14 09:31:56 -0700 (Thu, 14 Jul 2011)
Log Message:
-----------
Discard failures that happen after we have decided to shutdown the sim.
Modified Paths:
--------------
CalendarServer/trunk/contrib/performance/loadtest/population.py
CalendarServer/trunk/contrib/performance/loadtest/sim.py
CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
Modified: CalendarServer/trunk/contrib/performance/loadtest/population.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/population.py 2011-07-14 16:08:56 UTC (rev 7791)
+++ CalendarServer/trunk/contrib/performance/loadtest/population.py 2011-07-14 16:31:56 UTC (rev 7792)
@@ -154,6 +154,7 @@
self.server = server
self._pop = self.populator.populate(parameters)
self._user = 0
+ self._stopped = False
def getUserRecord(self, index):
@@ -179,6 +180,16 @@
return user, auth
+ def stop(self):
+ """
+ Indicate that the simulation is over. CalendarClientSimulator doesn't
+ actively react to this, but it does cause all future failures to be
+ disregarded (as some are expected, as the simulation will always stop
+ while some requests are in flight).
+ """
+ self._stopped = True
+
+
def add(self, numClients):
for n in range(numClients):
number = self._nextUserNumber()
@@ -210,15 +221,17 @@
def _clientFailure(self, reason, reactor):
- where = self._dumpLogs(reactor, reason)
- err(reason, "Client stopped with error; recent traffic in %r" % (
- where.path,))
+ if not self._stopped:
+ where = self._dumpLogs(reactor, reason)
+ err(reason, "Client stopped with error; recent traffic in %r" % (
+ where.path,))
def _profileFailure(self, reason, profileType, reactor):
- where = self._dumpLogs(reactor, reason)
- err(reason, "Profile stopped with error; recent traffic in %r" % (
- where.path,))
+ if not self._stopped:
+ where = self._dumpLogs(reactor, reason)
+ err(reason, "Profile stopped with error; recent traffic in %r" % (
+ where.path,))
Modified: CalendarServer/trunk/contrib/performance/loadtest/sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/sim.py 2011-07-14 16:08:56 UTC (rev 7791)
+++ CalendarServer/trunk/contrib/performance/loadtest/sim.py 2011-07-14 16:31:56 UTC (rev 7792)
@@ -272,9 +272,14 @@
def run(self):
for obs in self.observers:
addObserver(obs.observe)
- self.reactor.addSystemEventTrigger(
- 'before', 'shutdown', removeObserver, obs.observe)
sim = self.createSimulator()
+
+ def stop():
+ for obs in self.observers:
+ removeObserver(obs.observe)
+ sim.stop()
+ self.reactor.addSystemEventTrigger('before', 'shutdown', stop)
+
arrivalPolicy = self.createArrivalPolicy()
arrivalPolicy.run(sim)
if self.runtime is not None:
Modified: CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-14 16:08:56 UTC (rev 7791)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-14 16:31:56 UTC (rev 7792)
@@ -20,6 +20,7 @@
from twisted.python.log import msg
from twisted.python.usage import UsageError
from twisted.python.filepath import FilePath
+from twisted.internet.defer import Deferred
from twisted.trial.unittest import TestCase
from twistedcaldav.directory.directory import DirectoryRecord
@@ -134,6 +135,43 @@
'password-' + user)
+ def test_stop(self):
+ """
+ After L{CalendarClientSimulator.stop} is called, failed clients and
+ profiles are not logged.
+ """
+ class BrokenClient(object):
+ def __init__(self, reactor, serverAddress, userInfo, auth, runResult):
+ self._runResult = runResult
+
+ def run(self):
+ return self._runResult
+
+ class BrokenProfile(object):
+ def __init__(self, reactor, simulator, client, userNumber, runResult):
+ self._runResult = runResult
+
+ def run(self):
+ return self._runResult
+
+ clientRunResult = Deferred()
+ profileRunResult = Deferred()
+
+ params = PopulationParameters()
+ params.addClient(1, ClientType(
+ BrokenClient, {'runResult': clientRunResult},
+ [ProfileType(BrokenProfile, {'runResult': profileRunResult})]))
+ sim = CalendarClientSimulator(
+ [self._user('alice')], Populator(None), params, None, 'http://example.com:1234/')
+ sim.add(1)
+ sim.stop()
+ clientRunResult.errback(RuntimeError("Some fictional client problem"))
+ profileRunResult.errback(RuntimeError("Some fictional profile problem"))
+
+ self.assertEqual([], self.flushLoggedErrors())
+
+
+
class Reactor(object):
message = "some event to be observed"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110714/5b272905/attachment.html>
More information about the calendarserver-changes
mailing list