[CalendarServer-changes] [7788] CalendarServer/trunk/contrib/performance/loadtest
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 14 06:49:22 PDT 2011
Revision: 7788
http://trac.macosforge.org/projects/calendarserver/changeset/7788
Author: exarkun at twistedmatrix.com
Date: 2011-07-14 06:49:20 -0700 (Thu, 14 Jul 2011)
Log Message:
-----------
Make the default config plist the default
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-13 22:44:34 UTC (rev 7787)
+++ CalendarServer/trunk/contrib/performance/loadtest/sim.py 2011-07-14 13:49:20 UTC (rev 7788)
@@ -43,7 +43,10 @@
def recordsFromCSVFile(path):
- pathObj = FilePath(__file__).parent().preauthChild(path)
+ if path.startswith('/'):
+ pathObj = FilePath(path)
+ else:
+ pathObj = FilePath(__file__).parent().preauthChild(path)
return [
_DirectoryRecord(*line.decode('utf-8').split(u','))
for line
@@ -79,26 +82,18 @@
Command line configuration options for the load simulator.
"""
config = None
+ _defaultConfig = FilePath(__file__).sibling("config.plist")
optParameters = [
("runtime", "t", None,
"Specify the limit (seconds) on the time to run the simulation.",
- int)]
+ int),
+ ("config", None, _defaultConfig,
+ "Configuration plist file name from which to read simulation parameters.",
+ FilePath),
+ ]
- def opt_config(self, path):
- """
- Configuration plist file name from which to read simulation parameters.
- """
- try:
- configFile = FilePath(path).open()
- except IOError, e:
- raise UsageError("--config %s: %s" % (path, e.strerror))
- try:
- self.config = readPlist(configFile)
- except ExpatError, e:
- raise UsageError("--config %s: %s" % (path, e))
-
def opt_logfile(self, filename):
"""
Enable normal logging to some file. - for stdout.
@@ -135,8 +130,18 @@
def postOptions(self):
- if self.config is None:
- raise UsageError("Specify a configuration file using --config <path>")
+ try:
+ configFile = self['config'].open()
+ except IOError, e:
+ raise UsageError("--config %s: %s" % (
+ self['config'].path, e.strerror))
+ try:
+ try:
+ self.config = readPlist(configFile)
+ except ExpatError, e:
+ raise UsageError("--config %s: %s" % (self['config'].path, e))
+ finally:
+ configFile.close()
Arrival = namedtuple('Arrival', 'factory parameters')
Modified: CalendarServer/trunk/contrib/performance/loadtest/test_sim.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-13 22:44:34 UTC (rev 7787)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_sim.py 2011-07-14 13:49:20 UTC (rev 7788)
@@ -49,16 +49,13 @@
class SimOptionsTests(TestCase):
- def test_missingConfig(self):
+ def test_defaultConfig(self):
"""
- If the I{config} option is not specified,
- L{SimOptions.parseOptions} raises a L{UsageError} indicating
- it is required.
+ If the I{config} option is not specified, the default config.plist in
+ the source tree is used.
"""
options = SimOptions()
- exc = self.assertRaises(UsageError, options.parseOptions, [])
- self.assertEquals(
- str(exc), "Specify a configuration file using --config <path>")
+ self.assertEqual(options['config'], FilePath(__file__).sibling('config.plist'))
def test_configFileNotFound(self):
@@ -67,12 +64,12 @@
L{SimOptions.parseOptions} raises a L{UsageError} indicating
this.
"""
- name = self.mktemp()
+ name = FilePath(self.mktemp())
options = SimOptions()
exc = self.assertRaises(
- UsageError, options.parseOptions, ['--config', name])
+ UsageError, options.parseOptions, ['--config', name.path])
self.assertEquals(
- str(exc), "--config %s: No such file or directory" % (name,))
+ str(exc), "--config %s: No such file or directory" % (name.path,))
def test_configFileNotParseable(self):
@@ -82,14 +79,14 @@
L{SimOptions.parseOptions} raises a L{UsageError} indicating
this.
"""
- config = self.mktemp()
- FilePath(config).setContent("some random junk")
+ config = FilePath(self.mktemp())
+ config.setContent("some random junk")
options = SimOptions()
exc = self.assertRaises(
- UsageError, options.parseOptions, ['--config', config])
+ UsageError, options.parseOptions, ['--config', config.path])
self.assertEquals(
str(exc),
- "--config %s: syntax error: line 1, column 0" % (config,))
+ "--config %s: syntax error: line 1, column 0" % (config.path,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110714/46b65808/attachment-0001.html>
More information about the calendarserver-changes
mailing list