summaryrefslogtreecommitdiff
path: root/tests/src/py/qpid_tests/broker_0_10/priority.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/py/qpid_tests/broker_0_10/priority.py')
-rw-r--r--tests/src/py/qpid_tests/broker_0_10/priority.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/tests/src/py/qpid_tests/broker_0_10/priority.py b/tests/src/py/qpid_tests/broker_0_10/priority.py
index f99e908d76..bf4f1209b1 100644
--- a/tests/src/py/qpid_tests/broker_0_10/priority.py
+++ b/tests/src/py/qpid_tests/broker_0_10/priority.py
@@ -112,11 +112,11 @@ class PriorityTests (Base):
#check all messages on the queue were received by the browser; don't relay on any specific ordering at present
assert set([m.content for m in msgs]) == set([m.content for m in received])
- def ring_queue_check(self, msgs):
+ def ring_queue_check(self, msgs, count=10):
"""
Ensure that a ring queue removes lowest priority messages first.
"""
- snd = self.ssn.sender(address("priority-ring-queue", arguments="x-qpid-priorities:10, 'qpid.policy_type':ring, 'qpid.max_count':10"),
+ snd = self.ssn.sender(address("priority-ring-queue", arguments="x-qpid-priorities:10, 'qpid.policy_type':ring, 'qpid.max_count':%s" % count),
durable=self.durable())
for m in msgs: snd.send(m)
@@ -126,23 +126,31 @@ class PriorityTests (Base):
while True: received.append(rcv.fetch(0))
except Empty: None
- expected = []
- for m in msgs:
- while len(expected) > 9:
- expected=sorted_(expected, key=lambda x: priority_level(x.priority,10))
- expected.pop(0)
- expected.append(m)
- #print "sent %s; expected %s; got %s" % ([m.content for m in msgs], [m.content for m in expected], [m.content for m in received])
+ expected = sorted_(msgs, key=lambda x: priority_level(x.priority,10))[len(msgs)-count:]
+ expected = sorted_(expected, key=lambda x: priority_level(x.priority,10), reverse=True)
+ #print "sent %s; expected %s; got %s" % ([m.priority for m in msgs], [m.priority for m in expected], [m.priority for m in received])
+ #print "sent %s; expected %s; got %s" % ([m.content for m in msgs], [m.content for m in expected], [m.content for m in received])
assert [m.content for m in expected] == [m.content for m in received]
def test_ring_queue_1(self):
priorities = [4,5,3,6,9,9,2,9,2,9,9,1,9,9,9,3,3,3,9,9,3,9,3,9,9,9,9,9,9,2,3]
- seq = content("msg")
+ seq = content("msg")
self.ring_queue_check([Message(content=seq.next(), priority = p) for p in priorities])
def test_ring_queue_2(self):
- priorities = [9,0,2,3,6,9,9,2,9,2,9,9,1,9,4,7,1,1,3,9,9,3,9,3,9,9,9,1,9,9,2,3,0,9]
- seq = content("msg")
+ priorities = [9,0,2,3,6,3,4,2,9,2,9,9,1,9,4,7,1,1,3,9,7,3,9,3,9,1,5,1,9,7,2,3,0,9]
+ seq = content("msg")
+ self.ring_queue_check([Message(content=seq.next(), priority = p) for p in priorities])
+
+ def test_ring_queue_3(self):
+ #test case given for QPID-3866
+ priorities = [8,9,5,1,2,2,3,4,9,7,8,9,9,2]
+ seq = content("msg")
+ self.ring_queue_check([Message(content=seq.next(), priority = p) for p in priorities], 5)
+
+ def test_ring_queue_4(self):
+ priorities = [9,0,2,3,6,3,4,2,9,2,9,3,1,9,4,7,1,1,3,2,7,3,9,3,6,1,5,1,9,7,2,3,0,2]
+ seq = content("msg")
self.ring_queue_check([Message(content=seq.next(), priority = p) for p in priorities])
def test_requeue(self):
@@ -169,6 +177,7 @@ class PriorityTests (Base):
for expected in sorted_(msgs, key=lambda m: priority_level(m.priority,10), reverse=True):
msg = rcv.fetch(0)
#print "expected priority %s got %s" % (expected.priority, msg.priority)
+ #print "expected content %s got %s" % (expected.content, msg.content)
assert msg.content == expected.content
self.ssn.acknowledge(msg)
@@ -231,7 +240,7 @@ def sorted_(msgs, key=None, reverse=False):
Workaround lack of sorted builtin function in python 2.3 and lack
of keyword arguments to list.sort()
"""
- temp = msgs
+ temp = [m for m in msgs]
temp.sort(key_to_cmp(key, reverse=reverse))
return temp