[CalendarServer-changes] [8241] CalendarServer/branches/users/glyph/parallel-sim/contrib/performance /loadtest
source_changes at macosforge.org
source_changes at macosforge.org
Tue Nov 1 17:50:17 PDT 2011
Revision: 8241
http://trac.macosforge.org/projects/calendarserver/changeset/8241
Author: glyph at apple.com
Date: 2011-11-01 17:50:16 -0700 (Tue, 01 Nov 2011)
Log Message:
-----------
test-case-names, and write fewer things using 'print'
Modified Paths:
--------------
CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/population.py
CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/sim.py
CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/test_sim.py
Modified: CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/population.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/population.py 2011-11-02 00:49:29 UTC (rev 8240)
+++ CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/population.py 2011-11-02 00:50:16 UTC (rev 8241)
@@ -1,3 +1,4 @@
+# -*- test-case-name: contrib.performance.loadtest.test_population -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
Modified: CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/sim.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/sim.py 2011-11-02 00:49:29 UTC (rev 8240)
+++ CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/sim.py 2011-11-02 00:50:16 UTC (rev 8241)
@@ -1,3 +1,4 @@
+# -*- test-case-name: contrib.performance.loadtest.test_sim -*-
##
# Copyright (c) 2011 Apple Inc. All rights reserved.
#
@@ -185,7 +186,7 @@
@classmethod
- def fromCommandLine(cls, args=None):
+ def fromCommandLine(cls, args=None, output=stdout):
if args is None:
args = argv[1:]
@@ -233,7 +234,7 @@
loader = options.config['accounts']['loader']
params = options.config['accounts']['params']
records.extend(namedAny(loader)(**params))
- print 'Loaded', len(records), 'accounts.'
+ output.write("Loaded {0} accounts.\n".format(len(records)))
return cls(server, arrival, parameters,
observers=observers, records=records,
@@ -278,9 +279,9 @@
def createArrivalPolicy(self):
return self.arrival.factory(self.reactor, **self.arrival.parameters)
-
- def run(self):
+
+ def run(self, output=stdout):
for obs in self.observers:
addObserver(obs.observe)
sim = self.createSimulator()
@@ -301,10 +302,11 @@
obs.report()
failures.extend(obs.failures())
if failures:
- print 'FAIL'
- print '\n'.join(failures)
+ output.write('FAIL\n')
+ output.write('\n'.join(failures))
+ output.write('\n')
else:
- print 'PASS'
+ output.write('PASS\n')
main = LoadSimulator.main
Modified: CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/test_sim.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/test_sim.py 2011-11-02 00:49:29 UTC (rev 8240)
+++ CalendarServer/branches/users/glyph/parallel-sim/contrib/performance/loadtest/test_sim.py 2011-11-02 00:50:16 UTC (rev 8241)
@@ -16,6 +16,7 @@
##
from plistlib import writePlistToString
+from cStringIO import StringIO
from twisted.python.log import msg
from twisted.python.usage import UsageError
@@ -261,7 +262,9 @@
}
configpath = FilePath(self.mktemp())
configpath.setContent(writePlistToString(config))
- sim = LoadSimulator.fromCommandLine(['--config', configpath.path])
+ io = StringIO()
+ sim = LoadSimulator.fromCommandLine(['--config', configpath.path], io)
+ self.assertEquals(io.getvalue(), "Loaded 2 accounts.\n")
self.assertEqual(2, len(sim.records))
self.assertEqual(sim.records[0].uid, 'foo')
self.assertEqual(sim.records[0].password, 'bar')
@@ -287,7 +290,8 @@
}
configpath = FilePath(self.mktemp())
configpath.setContent(writePlistToString(config))
- sim = LoadSimulator.fromCommandLine(['--config', configpath.path])
+ sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
+ StringIO())
self.assertEqual(99, len(sim.records))
self.assertEqual(sim.records[0].uid, 'user01')
self.assertEqual(sim.records[0].password, 'user01')
@@ -313,7 +317,8 @@
}
configpath = FilePath(self.mktemp())
configpath.setContent(writePlistToString(config))
- sim = LoadSimulator.fromCommandLine(['--config', configpath.path])
+ sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
+ StringIO())
self.assertEqual(2, len(sim.records))
self.assertEqual(sim.records[0].uid, 'user1')
self.assertEqual(sim.records[0].password, 'user1')
@@ -343,7 +348,8 @@
}
configpath = FilePath(self.mktemp())
configpath.setContent(writePlistToString(config))
- sim = LoadSimulator.fromCommandLine(['--config', configpath.path])
+ sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
+ StringIO())
self.assertEqual(3, len(sim.records))
self.assertEqual(sim.records[0].uid, 'USER001')
self.assertEqual(sim.records[0].password, 'PASSWORD001')
@@ -491,7 +497,10 @@
"http://example.com:123/",
Arrival(lambda reactor: NullArrival(), {}),
None, observers, reactor=Reactor())
- sim.run()
+ io = StringIO()
+ sim.run(io)
+ self.assertEquals(io.getvalue(), "PASS\n")
self.assertTrue(observers[0].reported)
self.assertEquals(
observers[0].events[0]['message'], (Reactor.message,))
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111101/4a86a2d9/attachment-0001.html>
More information about the calendarserver-changes
mailing list