Author: justi9
Date: 2007-11-15 14:52:03 -0500 (Thu, 15 Nov 2007)
New Revision: 1320
Modified:
mgmt/cumin/bin/cumin-test
mgmt/cumin/python/cumin/__init__.py
Log:
Adds the ability to connect a managed broker to the cumin-test
runtime.
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2007-11-15 19:27:19 UTC (rev 1319)
+++ mgmt/cumin/bin/cumin-test 2007-11-15 19:52:03 UTC (rev 1320)
@@ -1,6 +1,21 @@
#!/usr/bin/env python
import sys, os
+
+def usage():
+ print """
+Usage: cumin-test OPTIONS
+Options:
+ --port PORT
+ --data DATABASE-URL
+ --broker BROKER
+ --bench [HITS]
+ --profile
+ --no-debug
+ --no-demo-data
+""",
+ sys.exit(1)
+
from ConfigParser import SafeConfigParser
def load_args(argv):
@@ -40,8 +55,8 @@
conn = connectionForURI(connuri)
sqlhub.processConnection = conn
except KeyError:
- print "No data source; use --data DATABASE-URL"
- sys.exit(1)
+ print "No data source"
+ usage()
from time import time
from wooly.devel import BenchmarkHarness
@@ -51,11 +66,13 @@
from cumin.demo import *
from cumin.model import *
-def do_main(port, bench_hits, debug=True, demodata=True):
+def do_main(port, broker, bench_hits, debug=True, demodata=True):
model = CuminModel()
-
app = Cumin(model)
+ if broker:
+ app.add_managed_broker(broker)
+
if demodata:
data = DemoData(model)
data.load()
@@ -72,6 +89,7 @@
server.run()
def main():
+ in_broker = args.get("broker")
in_port = int(args.get("port", 9090))
in_profile = "profile" in args
in_debug = "no-debug" not in args
@@ -109,7 +127,7 @@
stats.strip_dirs()
else:
try:
- do_main(in_port, in_bench, in_debug, in_demodata)
+ do_main(in_port, in_broker, in_bench, in_debug, in_demodata)
except KeyboardInterrupt:
pass
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-15 19:27:19 UTC (rev 1319)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-15 19:52:03 UTC (rev 1320)
@@ -54,6 +54,10 @@
self.add_page(ClientXmlPage(self, "client.xml"))
self.add_page(ClientChartPage(self, "client.png"))
+ def add_managed_broker(self, broker):
+ host, port = broker.split(":")
+ self.mint.addManagedBroker(host, int(port))
+
class CuminServer(WebServer):
def __init__(self, port=9090):
model = CuminModel()