summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-06-05 17:51:34 +0000
committerGordon Sim <gsim@apache.org>2008-06-05 17:51:34 +0000
commitacf5b889a13ea039528d8fb58a06397e813f1e90 (patch)
tree7996665ac26840a0e4132ead5e163138ca8ef246 /python
parent2def26872faa040e47eb2355c8eb567149264c7a (diff)
downloadqpid-python-acf5b889a13ea039528d8fb58a06397e813f1e90.tar.gz
cleanup old irrelevant tests (from 0-10 preview functions)
fix dtx.recover test git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@663675 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python')
-rw-r--r--python/cpp_failing_0-10.txt13
-rw-r--r--python/tests_0-10/dtx.py7
-rw-r--r--python/tests_0-10/execution.py29
-rw-r--r--python/tests_0-10/message.py207
-rw-r--r--python/tests_0-10/testlib.py66
5 files changed, 2 insertions, 320 deletions
diff --git a/python/cpp_failing_0-10.txt b/python/cpp_failing_0-10.txt
index cc1e57bca0..e69de29bb2 100644
--- a/python/cpp_failing_0-10.txt
+++ b/python/cpp_failing_0-10.txt
@@ -1,13 +0,0 @@
-tests.codec.FieldTableTestCase.test_field_table_decode
-tests.codec.FieldTableTestCase.test_field_table_multiple_name_value_pair
-tests.codec.FieldTableTestCase.test_field_table_name_value_pair
-tests_0-10.execution.ExecutionTests.test_flush
-tests_0-10.dtx.DtxTests.test_recover
-tests_0-10.message.MessageTests.test_no_size
-tests_0-10.message.MessageTests.test_qos_prefetch_count
-tests_0-10.message.MessageTests.test_qos_prefetch_size
-tests_0-10.message.MessageTests.test_recover
-tests_0-10.message.MessageTests.test_recover_requeue
-tests_0-10.testlib.TestBaseTest.testAssertEmptyFail
-tests_0-10.testlib.TestBaseTest.testAssertEmptyPass
-tests_0-10.testlib.TestBaseTest.testMessageProperties
diff --git a/python/tests_0-10/dtx.py b/python/tests_0-10/dtx.py
index 796152794f..25c2defd3b 100644
--- a/python/tests_0-10/dtx.py
+++ b/python/tests_0-10/dtx.py
@@ -653,22 +653,19 @@ class DtxTests(TestBase010):
session.dtx_rollback(xid=tx)
xids = session.dtx_recover().in_doubt
- print "xids=%s" % xids
#rollback the prepared transactions returned by recover
for x in xids:
session.dtx_rollback(xid=x)
#validate against the expected list of prepared transactions
- actual = set(xids)
- expected = set(prepared)
+ actual = set([x.global_id for x in xids]) #TODO: come up with nicer way to test these
+ expected = set([x.global_id for x in prepared])
intersection = actual.intersection(expected)
if intersection != expected:
missing = expected.difference(actual)
extra = actual.difference(expected)
- for x in missing:
- session.dtx_rollback(xid=x)
self.fail("Recovered xids not as expected. missing: %s; extra: %s" % (missing, extra))
def test_bad_resume(self):
diff --git a/python/tests_0-10/execution.py b/python/tests_0-10/execution.py
deleted file mode 100644
index 3ff6d8ea65..0000000000
--- a/python/tests_0-10/execution.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-from qpid.content import Content
-from qpid.testlib import testrunner, TestBase
-
-class ExecutionTests (TestBase):
- def test_flush(self):
- channel = self.channel
- for i in [1, 2, 3]:
- channel.message_transfer(
- content=Content(properties={'routing_key':str(i)}))
- assert(channel.completion.wait(channel.completion.command_id, timeout=1))
diff --git a/python/tests_0-10/message.py b/python/tests_0-10/message.py
index 8f3d7bdaef..e4dc5566bd 100644
--- a/python/tests_0-10/message.py
+++ b/python/tests_0-10/message.py
@@ -304,199 +304,6 @@ class MessageTests(TestBase010):
self.fail("Got unexpected message: " + extra.body)
except Empty: None
-
- def test_recover(self):
- """
- Test recover behaviour
- """
- session = self.session
- session.queue_declare(queue="queue-a", exclusive=True, auto_delete=True)
- session.queue_bind(exchange="amq.fanout", queue="queue-a")
- session.queue_declare(queue="queue-b", exclusive=True, auto_delete=True)
- session.queue_bind(exchange="amq.fanout", queue="queue-b")
-
- self.subscribe(queue="queue-a", destination="unconfirmed", confirm_mode=1)
- self.subscribe(queue="queue-b", destination="confirmed", confirm_mode=0)
- confirmed = session.incoming("confirmed")
- unconfirmed = session.incoming("unconfirmed")
-
- data = ["One", "Two", "Three", "Four", "Five"]
- for d in data:
- session.message_transfer(destination="amq.fanout", content=Content(body=d))
-
- for q in [confirmed, unconfirmed]:
- for d in data:
- self.assertEqual(d, q.get(timeout=1).content.body)
- self.assertEmpty(q)
-
- session.message_recover(requeue=False)
-
- self.assertEmpty(confirmed)
-
- while len(data):
- msg = None
- for d in data:
- msg = unconfirmed.get(timeout=1)
- self.assertEqual(d, msg.body)
- self.assertEqual(True, msg.content['redelivered'])
- self.assertEmpty(unconfirmed)
- data.remove(msg.body)
- msg.complete(cumulative=False)
- session.message_recover(requeue=False)
-
-
- def test_recover_requeue(self):
- """
- Test requeing on recovery
- """
- session = self.session
- session.queue_declare(queue="test-requeue", exclusive=True, auto_delete=True)
-
- self.subscribe(queue="test-requeue", destination="consumer_tag", confirm_mode=1)
- queue = session.incoming("consumer_tag")
-
- session.message_transfer(content=Content(properties={'routing_key' : "test-requeue"}, body="One"))
- session.message_transfer(content=Content(properties={'routing_key' : "test-requeue"}, body="Two"))
- session.message_transfer(content=Content(properties={'routing_key' : "test-requeue"}, body="Three"))
- session.message_transfer(content=Content(properties={'routing_key' : "test-requeue"}, body="Four"))
- session.message_transfer(content=Content(properties={'routing_key' : "test-requeue"}, body="Five"))
-
- msg1 = queue.get(timeout=1)
- msg2 = queue.get(timeout=1)
- msg3 = queue.get(timeout=1)
- msg4 = queue.get(timeout=1)
- msg5 = queue.get(timeout=1)
-
- self.assertEqual("One", msg1.content.body)
- self.assertEqual("Two", msg2.content.body)
- self.assertEqual("Three", msg3.content.body)
- self.assertEqual("Four", msg4.content.body)
- self.assertEqual("Five", msg5.content.body)
-
- msg2.complete(cumulative=True) #One and Two
- msg4.complete(cumulative=False) #Four
-
- session.message_cancel(destination="consumer_tag")
-
- #publish a new message
- session.message_transfer(content=Content(properties={'routing_key' : "test-requeue"}, body="Six"))
- #requeue unacked messages (Three and Five)
- session.message_recover(requeue=True)
-
- self.subscribe(queue="test-requeue", destination="consumer_tag")
- queue2 = session.incoming("consumer_tag")
-
- msg3b = queue2.get(timeout=1)
- msg5b = queue2.get(timeout=1)
-
- self.assertEqual("Three", msg3b.content.body)
- self.assertEqual("Five", msg5b.content.body)
-
- self.assertEqual(True, msg3b.content['redelivered'])
- self.assertEqual(True, msg5b.content['redelivered'])
-
- self.assertEqual("Six", queue2.get(timeout=1).content.body)
-
- try:
- extra = queue2.get(timeout=1)
- self.fail("Got unexpected message in second queue: " + extra.content.body)
- except Empty: None
- try:
- extra = queue.get(timeout=1)
- self.fail("Got unexpected message in original queue: " + extra.content.body)
- except Empty: None
-
-
- def test_qos_prefetch_count(self):
- """
- Test that the prefetch count specified is honoured
- """
- #setup: declare queue and subscribe
- session = self.session
- session.queue_declare(queue="test-prefetch-count", exclusive=True, auto_delete=True)
- subscription = self.subscribe(queue="test-prefetch-count", destination="consumer_tag", confirm_mode=1)
- queue = session.incoming("consumer_tag")
-
- #set prefetch to 5:
- session.message_qos(prefetch_count=5)
-
- #publish 10 messages:
- for i in range(1, 11):
- session.message_transfer(content=Content(properties={'routing_key' : "test-prefetch-count"}, body="Message %d" % i))
-
- #only 5 messages should have been delivered:
- for i in range(1, 6):
- msg = queue.get(timeout=1)
- self.assertEqual("Message %d" % i, msg.body)
- try:
- extra = queue.get(timeout=1)
- self.fail("Got unexpected 6th message in original queue: " + extra.content.body)
- except Empty: None
-
- #ack messages and check that the next set arrive ok:
- msg.complete()
-
- for i in range(6, 11):
- msg = queue.get(timeout=1)
- self.assertEqual("Message %d" % i, msg.body)
-
- msg.complete()
-
- try:
- extra = queue.get(timeout=1)
- self.fail("Got unexpected 11th message in original queue: " + extra.content.body)
- except Empty: None
-
-
-
- def test_qos_prefetch_size(self):
- """
- Test that the prefetch size specified is honoured
- """
- #setup: declare queue and subscribe
- session = self.session
- session.queue_declare(queue="test-prefetch-size", exclusive=True, auto_delete=True)
- subscription = self.subscribe(queue="test-prefetch-size", destination="consumer_tag", confirm_mode=1)
- queue = session.incoming("consumer_tag")
-
- #set prefetch to 50 bytes (each message is 9 or 10 bytes):
- session.message_qos(prefetch_size=50)
-
- #publish 10 messages:
- for i in range(1, 11):
- session.message_transfer(content=Content(properties={'routing_key' : "test-prefetch-size"}, body="Message %d" % i))
-
- #only 5 messages should have been delivered (i.e. 45 bytes worth):
- for i in range(1, 6):
- msg = queue.get(timeout=1)
- self.assertEqual("Message %d" % i, msg.body)
-
- try:
- extra = queue.get(timeout=1)
- self.fail("Got unexpected 6th message in original queue: " + extra.content.body)
- except Empty: None
-
- #ack messages and check that the next set arrive ok:
- msg.complete()
-
- for i in range(6, 11):
- msg = queue.get(timeout=1)
- self.assertEqual("Message %d" % i, msg.body)
-
- msg.complete()
-
- try:
- extra = queue.get(timeout=1)
- self.fail("Got unexpected 11th message in original queue: " + extra.content.body)
- except Empty: None
-
- #make sure that a single oversized message still gets delivered
- large = "abcdefghijklmnopqrstuvwxyz"
- large = large + "-" + large;
- session.message_transfer(content=Content(properties={'routing_key' : "test-prefetch-size"}, body=large))
- msg = queue.get(timeout=1)
- self.assertEqual(large, msg.body)
-
def test_reject(self):
session = self.session
session.queue_declare(queue = "q", exclusive=True, auto_delete=True, alternate_exchange="amq.fanout")
@@ -972,20 +779,6 @@ class MessageTests(TestBase010):
#ensure there are no other messages
self.assertEmpty(queueC)
- def test_no_size(self):
- self.queue_declare(queue = "q", exclusive=True, auto_delete=True)
-
- ssn = self.session
- ssn.message_transfer(content=SizelessContent(properties={'routing_key' : "q"}, body="message-body"))
-
- ssn.message_subscribe(queue = "q", destination="d", confirm_mode = 0)
- ssn.message_flow(unit = ssn.credit_unit.message, value = 0xFFFFFFFF, destination = "d")
- ssn.message_flow(unit = ssn.credit_unit.byte, value = 0xFFFFFFFF, destination = "d")
-
- queue = session.incoming("d")
- msg = queue.get(timeout = 3)
- self.assertEquals("message-body", msg.body)
-
def test_empty_body(self):
session = self.session
session.queue_declare(queue="xyz", exclusive=True, auto_delete=True)
diff --git a/python/tests_0-10/testlib.py b/python/tests_0-10/testlib.py
deleted file mode 100644
index a0355c4ce0..0000000000
--- a/python/tests_0-10/testlib.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# Tests for the testlib itself.
-#
-
-from qpid.content import Content
-from qpid.testlib import testrunner, TestBase
-from Queue import Empty
-
-import sys
-from traceback import *
-
-def mytrace(frame, event, arg):
- print_stack(frame);
- print "===="
- return mytrace
-
-class TestBaseTest(TestBase):
- """Verify TestBase functions work as expected"""
-
- def testAssertEmptyPass(self):
- """Test assert empty works"""
- self.queue_declare(queue="empty")
- q = self.consume("empty")
- self.assertEmpty(q)
- try:
- q.get(timeout=1)
- self.fail("Queue is not empty.")
- except Empty: None # Ignore
-
- def testAssertEmptyFail(self):
- self.queue_declare(queue="full")
- q = self.consume("full")
- self.channel.message_transfer(content=Content("", properties={'routing_key':"full"}))
- try:
- self.assertEmpty(q);
- self.fail("assertEmpty did not assert on non-empty queue")
- except AssertionError: None # Ignore
-
- def testMessageProperties(self):
- """Verify properties are passed with message"""
- props={"x":1, "y":2}
- self.queue_declare(queue="q")
- q = self.consume("q")
- self.assertPublishGet(q, routing_key="q", properties=props)
-
-
-