summaryrefslogtreecommitdiff
path: root/python/qpid
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-03-19 20:34:32 +0000
committerAlan Conway <aconway@apache.org>2007-03-19 20:34:32 +0000
commit61c0db2359216685e697facac5351bdd836035d7 (patch)
tree1e070c23f405f82e528dee9a91fd3bbfddf86fed /python/qpid
parentf934d8a2d5d91d802fcc791a8492bd92abafc327 (diff)
downloadqpid-python-61c0db2359216685e697facac5351bdd836035d7.tar.gz
Merged revisions 507491-507559,507561-507601,507603-507621,507623-507671,507673-507959,507961-507992,507994-508097,508099-508149,508151-508155,508157-508232,508234-508378,508380-508390,508392-508459,508461-508704,508707-509615,509617-509737,509739-509753,509756-509833,509835-510106,510108-510160,510162-510179,510181-510552,510554-510704,510706-510911,510913-510985,510987-511003,511005-514750,514752-515720,515722-516156,516158-516458,516461-516484,516486-516488,516490-517823,517825,517827,517829,517831-517832,517834-517848,517850,517852-517854,517856-517858,517860-517877,517879-517886,517888-517891,517893-517903,517905,517907-517928,517930,517932-518197,518201-518206,518208-518230,518232,518235,518237,518239-518240,518243-518245,518247-518255,518257,518259-518260,518262,518264,518266-518292,518294-518707 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9 ........ r507491 | gsim | 2007-02-14 06:39:26 -0500 (Wed, 14 Feb 2007) | 3 lines Expanded the use of batched acks to a few other places in tests. ........ r508377 | gsim | 2007-02-16 07:03:37 -0500 (Fri, 16 Feb 2007) | 4 lines Updated failing list for java (some of these result in test suite blocking) Added better error handling when connection closes without close method ........ r508396 | gsim | 2007-02-16 08:54:54 -0500 (Fri, 16 Feb 2007) | 3 lines Fix: use message_resume not channel_resume ........ r509611 | gsim | 2007-02-20 10:39:14 -0500 (Tue, 20 Feb 2007) | 3 lines Fixed bug where response id rather than request id was being used to get listener for response. ........ r509617 | gsim | 2007-02-20 10:52:31 -0500 (Tue, 20 Feb 2007) | 3 lines Updated list of failing tests for java broker on this branch. ........ r510096 | gsim | 2007-02-21 11:49:27 -0500 (Wed, 21 Feb 2007) | 5 lines Fixed bug in references where map wasn't qualified in close Attach reference to transfer, as it will be deleted on close Altered tests to get reference from the message on the queue rather than looking them up from channel as they are already gone there ........ r510114 | astitcher | 2007-02-21 12:37:36 -0500 (Wed, 21 Feb 2007) | 3 lines r1224@fuschia: andrew | 2007-02-21 17:20:59 +0000 Updated expected cpp broker test failures ........ r510128 | gsim | 2007-02-21 13:06:02 -0500 (Wed, 21 Feb 2007) | 3 lines Ensure socket is closed in tearDown ........ r510913 | gsim | 2007-02-23 06:37:08 -0500 (Fri, 23 Feb 2007) | 3 lines Revised list of failing tests for java broker on this branch ........ r515363 | aconway | 2007-03-06 18:35:08 -0500 (Tue, 06 Mar 2007) | 6 lines * python/qpid/peer.py (Channel.__init__): use reliable framing if version >= 0-8. * python/qpid/spec.py (Spec.__init__): Remove unused parameter. * python/qpid/testlib.py (TestRunner._parseargs): Add --errata option, set default errata only if --spec is not present. ........ r518707 | aconway | 2007-03-15 13:49:44 -0400 (Thu, 15 Mar 2007) | 6 lines * python/qpid/peer.py (Peer.close): Close delegate *before* channels. Otherwise we get a race: closing a channel can wake a client thread, which may see client.closed as still false. Was causing bogus exceptions in some tests. ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@520094 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
-rw-r--r--python/qpid/client.py11
-rw-r--r--python/qpid/connection.py3
-rw-r--r--python/qpid/peer.py11
-rw-r--r--python/qpid/reference.py2
-rw-r--r--python/qpid/spec.py5
-rw-r--r--python/qpid/testlib.py53
6 files changed, 56 insertions, 29 deletions
diff --git a/python/qpid/client.py b/python/qpid/client.py
index ea6aa7901a..e548ef0e99 100644
--- a/python/qpid/client.py
+++ b/python/qpid/client.py
@@ -76,7 +76,8 @@ class Client:
self.locale = locale
self.tune_params = tune_params
- self.conn = Connection(connect(self.host, self.port), self.spec)
+ self.socket = connect(self.host, self.port)
+ self.conn = Connection(self.socket, self.spec)
self.peer = Peer(self.conn, ClientDelegate(self), self.opened)
self.conn.init()
@@ -90,6 +91,9 @@ class Client:
def opened(self, ch):
ch.references = References()
+ def close(self):
+ self.socket.close()
+
class ClientDelegate(Delegate):
def __init__(self, client):
@@ -112,9 +116,8 @@ class ClientDelegate(Delegate):
def message_transfer(self, ch, msg):
if isinstance(msg.body, ReferenceId):
- self.client.queue(msg.destination).put(ch.references.get(msg.body.id))
- else:
- self.client.queue(msg.destination).put(msg)
+ msg.reference = ch.references.get(msg.body.id)
+ self.client.queue(msg.destination).put(msg)
def message_open(self, ch, msg):
ch.references.open(msg.reference)
diff --git a/python/qpid/connection.py b/python/qpid/connection.py
index 0785fe8774..cdfa2c2dc0 100644
--- a/python/qpid/connection.py
+++ b/python/qpid/connection.py
@@ -53,6 +53,9 @@ class SockIO:
def flush(self):
pass
+ def close(self):
+ self.sock.shutdown(socket.SHUT_RDWR)
+
def connect(host, port):
sock = socket.socket()
sock.connect((host, port))
diff --git a/python/qpid/peer.py b/python/qpid/peer.py
index 6c8c6647c9..28db20f187 100644
--- a/python/qpid/peer.py
+++ b/python/qpid/peer.py
@@ -97,9 +97,12 @@ class Peer:
self.fatal()
def close(self, reason):
+ # We must close the delegate first because closing channels
+ # may wake up waiting threads and we don't want them to see
+ # the delegate as open.
+ self.delegate.close(reason)
for ch in self.channels.values():
ch.close(reason)
- self.delegate.close(reason)
def writer(self):
try:
@@ -144,7 +147,7 @@ class Requester:
self.write(frame, content)
def receive(self, channel, frame):
- listener = self.outstanding.pop(frame.id)
+ listener = self.outstanding.pop(frame.request_id)
listener(channel, frame)
class Responder:
@@ -178,8 +181,8 @@ class Channel:
self.requester = Requester(self.write)
self.responder = Responder(self.write)
- # XXX: better switch
- self.reliable = False
+ # Use reliable framing if version == 0-9.
+ self.reliable = (spec.major == 0 and spec.minor == 9)
self.synchronous = True
def close(self, reason):
diff --git a/python/qpid/reference.py b/python/qpid/reference.py
index d357560390..48ecb67656 100644
--- a/python/qpid/reference.py
+++ b/python/qpid/reference.py
@@ -111,7 +111,7 @@ class References:
self.get(id).close()
self.lock.acquire()
try:
- del map[id]
+ self.map.pop(id)
finally:
self.lock.release()
diff --git a/python/qpid/spec.py b/python/qpid/spec.py
index e430c45b96..4f0661bcbc 100644
--- a/python/qpid/spec.py
+++ b/python/qpid/spec.py
@@ -79,12 +79,11 @@ class Spec(Metadata):
PRINT=["major", "minor", "file"]
- def __init__(self, major, minor, file, errata):
+ def __init__(self, major, minor, file):
Metadata.__init__(self)
self.major = major
self.minor = minor
self.file = file
- self.errata = errata
self.constants = SpecContainer()
self.classes = SpecContainer()
# methods indexed by classname_methname
@@ -275,7 +274,7 @@ def load_fields(nd, l, domains):
def load(specfile, *errata):
doc = xmlutil.parse(specfile)
spec_root = doc["amqp"][0]
- spec = Spec(int(spec_root["@major"]), int(spec_root["@minor"]), specfile, errata)
+ spec = Spec(int(spec_root["@major"]), int(spec_root["@minor"]), specfile)
for root in [spec_root] + map(lambda x: xmlutil.parse(x)["amqp"][0], errata):
# constants
diff --git a/python/qpid/testlib.py b/python/qpid/testlib.py
index dcbf0ed91c..05641bce7e 100644
--- a/python/qpid/testlib.py
+++ b/python/qpid/testlib.py
@@ -26,6 +26,7 @@ import qpid.client, qpid.spec
import Queue
from getopt import getopt, GetoptError
from qpid.content import Content
+from qpid.message import Message
def findmodules(root):
"""Find potential python modules under directory root"""
@@ -56,15 +57,16 @@ class TestRunner:
run-tests [options] [test*]
The name of a test is package.module.ClassName.testMethod
Options:
- -?/-h/--help : this message
+ -?/-h/--help : this message
-s/--spec <spec.xml> : URL of AMQP XML specification or one of these abbreviations:
0-8 - use the default 0-8 specification.
0-9 - use the default 0-9 specification.
+ -e/--errata <errata.xml> : file containing amqp XML errata
-b/--broker [<user>[/<password>]@]<host>[:<port>] : broker to connect to
- -v/--verbose : verbose - lists tests as they are run.
- -d/--debug : enable debug logging.
- -i/--ignore <test> : ignore the named test.
- -I/--ignore-file : file containing patterns to ignore.
+ -v/--verbose : verbose - lists tests as they are run.
+ -d/--debug : enable debug logging.
+ -i/--ignore <test> : ignore the named test.
+ -I/--ignore-file : file containing patterns to ignore.
"""
sys.exit(1)
@@ -103,24 +105,27 @@ Options:
for opt, value in opts:
if opt in ("-?", "-h", "--help"): self._die()
if opt in ("-s", "--spec"): self.specfile = value
+ if opt in ("-e", "--errata"): self.errata.append(value)
if opt in ("-b", "--broker"): self.setBroker(value)
if opt in ("-v", "--verbose"): self.verbose = 2
if opt in ("-d", "--debug"): logging.basicConfig(level=logging.DEBUG)
if opt in ("-i", "--ignore"): self.ignore.append(value)
if opt in ("-I", "--ignore-file"): self.ignoreFile(value)
+ # Abbreviations for default settings.
if (self.specfile == "0-8"):
- self.specfile = "../specs/amqp.0-8.xml"
+ self.specfile = "../specs/amqp.0-8.xml"
if (self.specfile == "0-9"):
- self.specfile = "../specs/amqp.0-9.xml"
- self.errata = ["../specs/amqp-errata.0-9.xml"]
+ self.specfile = "../specs/amqp.0-9.xml"
+ self.errata.append("../specs/amqp-errata.0-9.xml")
+ if (self.specfile == None):
+ self._die("No XML specification provided")
print "Using specification from:", self.specfile
self.spec = qpid.spec.load(self.specfile, *self.errata)
if len(self.tests) == 0:
if self.use08spec():
- testdir="tests_0-8"
+ self.tests=findmodules("tests_0-8")
else:
- testdir="tests"
- self.tests=findmodules(testdir)
+ self.tests=findmodules("tests")
def testSuite(self):
class IgnoringTestSuite(unittest.TestSuite):
@@ -137,7 +142,11 @@ Options:
self._parseargs(args)
runner = unittest.TextTestRunner(descriptions=False,
verbosity=self.verbose)
- result = runner.run(self.testSuite())
+ try:
+ result = runner.run(self.testSuite())
+ except:
+ print "Unhandled error in test:", sys.exc_info()
+
if (self.ignore):
print "======================================="
print "NOTE: the following tests were ignored:"
@@ -181,10 +190,18 @@ class TestBase(unittest.TestCase):
self.channel.channel_open()
def tearDown(self):
- for ch, q in self.queues:
- ch.queue_delete(queue=q)
- for ch, ex in self.exchanges:
- ch.exchange_delete(exchange=ex)
+ try:
+ for ch, q in self.queues:
+ ch.queue_delete(queue=q)
+ for ch, ex in self.exchanges:
+ ch.exchange_delete(exchange=ex)
+ except:
+ print "Error on tearDown:", sys.exc_info()
+
+ if not self.client.closed:
+ self.client.channel(0).connection_close(reply_code=200)
+ else:
+ self.client.close()
def connect(self, *args, **keys):
"""Create a new connction, return the Client object"""
@@ -261,13 +278,15 @@ class TestBase(unittest.TestCase):
"""
self.assertPublishGet(self.consume(queue), exchange, routing_key, properties)
- def assertChannelException(self, expectedCode, message):
+ def assertChannelException(self, expectedCode, message):
+ if not isinstance(message, Message): self.fail("expected channel_close method")
self.assertEqual("channel", message.method.klass.name)
self.assertEqual("close", message.method.name)
self.assertEqual(expectedCode, message.reply_code)
def assertConnectionException(self, expectedCode, message):
+ if not isinstance(message, Message): self.fail("expected connection_close method")
self.assertEqual("connection", message.method.klass.name)
self.assertEqual("close", message.method.name)
self.assertEqual(expectedCode, message.reply_code)