[rhmessaging-commits] rhmessaging commits: r2179 - in mgmt/trunk/cumin: python/cumin and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Jul 7 20:43:06 EDT 2008


Author: justi9
Date: 2008-07-07 20:43:06 -0400 (Mon, 07 Jul 2008)
New Revision: 2179

Modified:
   mgmt/trunk/cumin/bin/cumin-test
   mgmt/trunk/cumin/python/cumin/model.py
   mgmt/trunk/cumin/python/cumin/test.py
   mgmt/trunk/cumin/python/cumin/util.py
Log:
If no broker is given, try to spin up a broker on a random port

Modified: mgmt/trunk/cumin/bin/cumin-test
===================================================================
--- mgmt/trunk/cumin/bin/cumin-test	2008-07-07 14:17:52 UTC (rev 2178)
+++ mgmt/trunk/cumin/bin/cumin-test	2008-07-08 00:43:06 UTC (rev 2179)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 import sys, os
-from time import time
+from time import time, sleep
 
 from cumin import *
 from cumin.test import *
@@ -23,8 +23,16 @@
 
     app.init()
 
-    host, port = parse_broker_addr(config.broker)
+    if config.broker:
+        host, port = parse_broker_addr(config.broker)
+    else:
+        # XXX change this to 49152..65535 when the underlying datatype
+        # supports it
+        host, port = "localhost", randint(16384, 32767)
 
+        broker = TestBroker("/usr/sbin/qpidd", port)
+        broker.start()
+
     env = TestEnvironment(app, host, port, config.spec)
     env.init();
 
@@ -38,8 +46,8 @@
 def main():
     config = CuminConfig()
 
-    summ = ("ADDR", "Register new test broker at ADDR")
-    config.add_param("broker", str, "localhost:5672", summ)
+    summ = ("ADDR", "Use existing broker at ADDR")
+    config.add_param("broker", str, None, summ)
 
     config.init()
 

Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py	2008-07-07 14:17:52 UTC (rev 2178)
+++ mgmt/trunk/cumin/python/cumin/model.py	2008-07-08 00:43:06 UTC (rev 2179)
@@ -420,6 +420,7 @@
 
                 return object
             except Exception, e:
+                log.exception("Action failed")
                 completion(e.message or "failed")
 
     class Edit(CuminAction):

Modified: mgmt/trunk/cumin/python/cumin/test.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/test.py	2008-07-07 14:17:52 UTC (rev 2178)
+++ mgmt/trunk/cumin/python/cumin/test.py	2008-07-08 00:43:06 UTC (rev 2179)
@@ -2,12 +2,39 @@
 from mint import *
 from traceback import print_exc, extract_tb
 from datetime import datetime
+from threading import Thread
+from popen2 import Popen4
+from shutil import copyfileobj
 import qpid, quirk, wooly
 
 from cumin import Cumin
 from util import *
 import time
 
+class TestBroker(Thread):
+    def __init__(self, path, port):
+        super(TestBroker, self).__init__()
+
+        self.path = path
+        self.port = port
+        self.command = (path, "--port", str(port),
+                        "--auth", "no",
+                        "-t",
+                        "--no-data-dir")
+        self.output = "qpidd-test.log"
+        self.setDaemon(True)
+
+    def run(self):
+        out = open(self.output, "w")
+
+        try:
+            pop = Popen4(self.command)
+            copyfileobj(pop.fromchild, out)
+            exit_code = pop.wait()
+            print exit_code
+        finally:
+            print "hmmm!"
+
 class TestEnvironment(object):
     def __init__(self, app, broker_host, broker_port, spec_path):
         self.app = app
@@ -65,7 +92,7 @@
 class TestSession(object):
     def __init__(self, env):
         self.env = env
-        self.id = datetime.now().strftime("test-%H-%M-%S")
+        self.id = short_id()
 
         self.stack = list()
         self.passed = list()

Modified: mgmt/trunk/cumin/python/cumin/util.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/util.py	2008-07-07 14:17:52 UTC (rev 2178)
+++ mgmt/trunk/cumin/python/cumin/util.py	2008-07-08 00:43:06 UTC (rev 2179)
@@ -1,7 +1,12 @@
+import sys
 from time import mktime
 from ConfigParser import SafeConfigParser
 from logging import getLogger
+from random import randint
 
+def short_id():
+    return "%08x" % randint(0, sys.maxint)
+
 def sorted_by(seq, attr="name"):
     return sorted(seq, cmp, lambda x: getattr(x, attr))
 




More information about the rhmessaging-commits mailing list