Author: eallen
Date: 2008-11-13 10:07:41 -0500 (Thu, 13 Nov 2008)
New Revision: 2795
Modified:
mgmt/trunk/cumin/python/cumin/test.py
Log:
Fixed queue and exchange tests.
Modified: mgmt/trunk/cumin/python/cumin/test.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/test.py 2008-11-13 13:55:29 UTC (rev 2794)
+++ mgmt/trunk/cumin/python/cumin/test.py 2008-11-13 15:07:41 UTC (rev 2795)
@@ -264,14 +264,8 @@
form = p.main.broker.link_add
form.show(s)
- host = dict()
- host["name"] = "localhost"
- host["port"] = "9991"
- host["password"] = ""
- host["username"] = ""
- form.host.set(s, host)
-
- form.durable.set(s, "transient")
+ form.host.set(s, "localhost")
+ form.port.set(s, "9991")
form.submit(s)
p.process(s)
@@ -282,15 +276,11 @@
def predicate():
for item in Link.selectBy(vhost=vhost, host="localhost",
port=9991):
+ self.env.link = item
return True
wait(predicate)
- try:
- self.env.link = Link.selectBy(vhost=vhost, host="localhost",
port=9991)[0]
- except IndexError:
- raise Exception("Link not created")
-
self.run_children(session)
class LinkRemove(Test):
@@ -349,15 +339,11 @@
def predicate():
for item in Bridge.selectBy(link=self.env.link,
dest=self.env.broker_exchange.name, key="cumin.key"):
+ self.env.bridge = item
return True
wait(predicate)
- try:
- self.env.bridge = Bridge.selectBy(link=self.env.link,
dest=self.env.broker_exchange.name, key="cumin.key")[0]
- except IndexError:
- raise Exception("Route not created")
-
class Remove(Test):
def do_run(self, session):
p, s = self.env.page_and_session()
@@ -379,10 +365,6 @@
wait(predicate)
- # if it timed out, raise an exception
- if not self.env.bridge.deletionTime:
- raise Exception("Route not removed")
-
class BrokerRegistrationTest(Test):
def __init__(self, env, parent):
super(BrokerRegistrationTest, self).__init__(env, parent)
@@ -570,6 +552,7 @@
direct = binding["test"]
direct["name"] = "amq.direct"
direct["type"] = "direct"
+ direct["key"] = "amq.direct.key"
form.bindings.dict_param.set(s, binding)
@@ -605,17 +588,21 @@
wait(predicate)
- # if it timed out, raise an exception
- if not self.env.binding_direct.deletionTime:
- raise Exception("Direct Binding not removed")
+ class BindTopic(Test):
+ def __init__(self, env, parent):
+ super(BindQueueTest.BindTopic, self).__init__(env, parent)
- class BindTopic(Test):
+ self.RemoveBindTopic(env, self)
+
def do_run(self, session):
p, s = self.env.page_and_session()
- frame = p.main.broker.queue.show_object(s, self.env.queue)
+ p.main.broker.set_object(s, self.env.broker.registration)
+ p.main.broker.queue.set_object(s, self.env.queue)
- form = frame.binding_add
+ form = p.main.broker.queue.binding_add
+ form.show(s)
+
binding = dict()
binding["test"] = {}
direct = binding["test"]
@@ -631,17 +618,43 @@
def predicate():
for item in Binding.selectBy(queue=self.env.queue,
bindingKey="topic.key"):
+ self.env.binding_topic = item
return True
wait(predicate)
+ class RemoveBindTopic(Test):
+ def do_run(self, session):
+ p, s = self.env.page_and_session()
+
+ p.main.broker.set_object(s, self.env.broker_registration)
+
+ form = p.main.broker.bindings_remove.show(s)
+ form.ids.set([self.env.binding_topic.id])
+ form.submit(s)
+
+ p.process(s)
+
+ self.env.check_redirect(p, s)
+
+ def predicate():
+ return self.env.binding_topic.deletionTime
+
+ wait(predicate)
+
class BindFanout(Test):
+ def __init__(self, env, parent):
+ super(BindQueueTest.BindFanout, self).__init__(env, parent)
+
+ self.RemoveBindFanout(env, self)
+
def do_run(self, session):
p, s = self.env.page_and_session()
- frame = p.main.broker.queue.show_object(s, self.env.queue)
+ p.main.broker.set_object(s, self.env.broker.registration)
+ p.main.broker.queue.set_object(s, self.env.queue)
- form = frame.binding_add
+ form = p.main.broker.queue.binding_add
form.show(s)
binding = dict()
@@ -659,23 +672,38 @@
def predicate():
for item in Binding.selectBy(queue=self.env.queue):
if item.exchange.name == "amq.fanout":
+ self.env.binding_fanout = item
return True
wait(predicate)
- for item in Binding.selectBy(queue=self.env.queue):
- if item.exchange.name == "amq.fanout":
- return
+ class RemoveBindFanout(Test):
+ def do_run(self, session):
+ p, s = self.env.page_and_session()
- raise Exception("Fanout Binding not added")
+ p.main.broker.set_object(s, self.env.broker_registration)
+ form = p.main.broker.bindings_remove.show(s)
+ form.ids.set([self.env.binding_fanout.id])
+ form.submit(s)
+
+ p.process(s)
+
+ self.env.check_redirect(p, s)
+
+ def predicate():
+ return self.env.binding_fanout.deletionTime
+
+ wait(predicate)
+
class BindHeaders(Test):
def do_run(self, session):
p, s = self.env.page_and_session()
- frame = p.main.broker.queue.show_object(s, self.env.queue)
+ p.main.broker.set_object(s, self.env.broker.registration)
+ p.main.broker.queue.set_object(s, self.env.queue)
- form = frame.binding_add
+ form = p.main.broker.queue.binding_add
form.show(s)
binding = dict()
@@ -722,8 +750,6 @@
form = p.main.broker.queue_add
form.show(s)
form.namef.set(s, name)
- form.durable.set(s, "durable")
- form.autodelete.set(s, "preserve")
form.submit(s)
p.process(s)
@@ -761,15 +787,11 @@
def predicate():
for item in Queue.selectBy(vhost=vhost, name=name):
+ self.env.broker_queue = item
return True
wait(predicate)
- try:
- self.env.broker_queue = Queue.selectBy(vhost=vhost, name=name)[0]
- except IndexError:
- raise Exception("Queue not found")
-
self.run_children(session)
class Remove(Test):
@@ -794,55 +816,54 @@
wait(predicate)
+class AddExchangeTest(Test):
+ def do_run(self, session):
+ name = "cumin.exchange.%s" % session.id
+ p, s = self.env.page_and_session()
+
+ reg = self.env.broker_registration
+ p.main.broker.set_object(s, reg)
+
+ form = p.main.broker.exchange_add
+ form.show(s)
+
+ form.exchange_name.set(s, name)
+ form.exchange_type.set(s, "topic")
+ form.submit(s)
+
+ p.process(s)
+
+ self.env.check_redirect(p, s)
+
+ vhost = self.env.vhost
+ # wait for newly created exchange to show up
+ def predicate():
+ for item in Exchange.selectBy(vhost=vhost, name=name):
+ self.env.added_exchange = item
+ return True
+
+ wait(predicate)
+
class ExchangeTest(Test):
def __init__(self, env, parent):
super(ExchangeTest, self).__init__(env, parent)
- self.Add(env, self)
+ AddExchangeTest(env, self)
self.Remove(env, self)
def do_run(self, session):
vhost = self.env.vhost
name = self.env.broker_exchange.name
- try:
- self.env.exchange = Exchange.selectBy(vhost=vhost, name=name)[0]
- except IndexError:
- raise Exception("Exchange not found")
+ def predicate():
+ for item in Exchange.selectBy(vhost=vhost, name=name):
+ self.env.broker_exchange = item
+ return True
+ wait(predicate)
+
self.run_children(session)
- class Add(Test):
- def do_run(self, session):
- name = "cumin.exchange.%s" % session.id
- p, s = self.env.page_and_session()
-
- reg = self.env.broker_registration
- p.main.broker.set_object(s, reg)
-
- form = p.main.broker.exchange_add
- form.show(s)
- form.exchange_name.set(s, name)
- form.type.set(s, "topic")
- form.submit(s)
-
- p.process(s)
-
- self.env.check_redirect(p, s)
-
- vhost = self.env.vhost
- # wait for newly created exchange to show up
- def predicate():
- for item in Exchange.selectBy(vhost=vhost, name=name):
- return True
-
- wait(predicate)
-
- try:
- self.env.added_exchange = Exchange.selectBy(vhost=vhost, name=name)[0]
- except IndexError:
- raise Exception("Exchange %s not added" % name)
-
class Remove(Test):
def do_run(self, session):
# try to delete it
@@ -860,8 +881,6 @@
self.env.check_redirect(p, s)
- name = "cumin.exchange.%s" % session.id
-
# wait for newly created exchange to get marked as deleted
def predicate():
return self.env.added_exchange.deletionTime