Modified: qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/dtx.py URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/dtx.py?rev=1172657&r1=1172656&r2=1172657&view=diff ============================================================================== --- qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/dtx.py (original) +++ qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/dtx.py Mon Sep 19 15:13:18 2011 @@ -6,9 +6,9 @@ # 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 @@ -36,7 +36,7 @@ class DtxTests(TestBase010): and the appropriate result verified. The other tests enforce more specific rules and behaviour on a - per-method or per-field basis. + per-method or per-field basis. """ XA_RBROLLBACK = 1 @@ -49,8 +49,8 @@ class DtxTests(TestBase010): self.session = self.conn.session("dtx-session", 1) def test_simple_commit(self): - """ - Test basic one-phase commit behaviour. + """ + Test basic one-phase commit behaviour. """ guard = self.keepQueuesAlive(["queue-a", "queue-b"]) session = self.session @@ -73,8 +73,8 @@ class DtxTests(TestBase010): self.assertMessageId("commit", "queue-b") def test_simple_prepare_commit(self): - """ - Test basic two-phase commit behaviour. + """ + Test basic two-phase commit behaviour. """ guard = self.keepQueuesAlive(["queue-a", "queue-b"]) session = self.session @@ -100,8 +100,8 @@ class DtxTests(TestBase010): def test_simple_rollback(self): - """ - Test basic rollback behaviour. + """ + Test basic rollback behaviour. """ guard = self.keepQueuesAlive(["queue-a", "queue-b"]) session = self.session @@ -123,8 +123,8 @@ class DtxTests(TestBase010): self.assertMessageId("rollback", "queue-a") def test_simple_prepare_rollback(self): - """ - Test basic rollback behaviour after the transaction has been prepared. + """ + Test basic rollback behaviour after the transaction has been prepared. """ guard = self.keepQueuesAlive(["queue-a", "queue-b"]) session = self.session @@ -146,18 +146,18 @@ class DtxTests(TestBase010): #check result self.assertMessageCount(1, "queue-a") self.assertMessageCount(0, "queue-b") - self.assertMessageId("prepare-rollback", "queue-a") + self.assertMessageId("prepare-rollback", "queue-a") def test_select_required(self): """ check that an error is flagged if select is not issued before - start or end + start or end """ session = self.session tx = self.xid("dummy") try: session.dtx_start(xid=tx) - + #if we get here we have failed, but need to do some cleanup: session.dtx_end(xid=tx) session.dtx_rollback(xid=tx) @@ -197,10 +197,10 @@ class DtxTests(TestBase010): other.close() session1.dtx_end(xid=tx) session1.dtx_rollback(xid=tx) - + #verification: if failed: self.assertEquals(530, error.args[0].error_code) - else: self.fail("Xid already known, expected exception!") + else: self.fail("Xid already known, expected exception!") def test_forget_xid_on_completion(self): """ @@ -210,8 +210,8 @@ class DtxTests(TestBase010): #do some transactional work & complete the transaction self.test_simple_commit() # session has been reset, so reselect for use with dtx - self.session.dtx_select() - + self.session.dtx_select() + #start association for the same xid as the previously completed txn tx = self.xid("my-xid") self.session.dtx_start(xid=tx) @@ -237,9 +237,9 @@ class DtxTests(TestBase010): self.assertEquals(503, e.args[0].error_code) def test_start_join(self): - """ + """ Verify 'join' behaviour, where a session is associated with a - transaction that is already associated with another session. + transaction that is already associated with another session. """ guard = self.keepQueuesAlive(["one", "two"]) #create two sessions & select them for use with dtx: @@ -269,14 +269,14 @@ class DtxTests(TestBase010): #mark end on both sessions session1.dtx_end(xid=tx) session2.dtx_end(xid=tx) - + #commit and check session1.dtx_commit(xid=tx, one_phase=True) self.assertMessageCount(1, "one") self.assertMessageCount(1, "two") self.assertMessageId("a", "two") self.assertMessageId("b", "one") - + def test_suspend_resume(self): """ @@ -300,7 +300,7 @@ class DtxTests(TestBase010): session.dtx_start(xid=tx, resume=True) self.swap(session, "two", "one")#swap 'b' from 'two' to 'one' session.dtx_end(xid=tx) - + #commit and check session.dtx_commit(xid=tx, one_phase=True) self.assertMessageCount(1, "one") @@ -308,7 +308,7 @@ class DtxTests(TestBase010): self.assertMessageId("a", "two") self.assertMessageId("b", "one") - def test_suspend_start_end_resume(self): + def test_suspend_start_end_resume(self): """ Test suspension and resumption of an association with work done on another transaction when the first transaction is @@ -332,7 +332,7 @@ class DtxTests(TestBase010): session.dtx_start(xid=tx, resume=True) self.swap(session, "two", "one")#swap 'b' from 'two' to 'one' session.dtx_end(xid=tx) - + #commit and check session.dtx_commit(xid=tx, one_phase=True) self.assertMessageCount(1, "one") @@ -341,10 +341,10 @@ class DtxTests(TestBase010): self.assertMessageId("b", "one") def test_end_suspend_and_fail(self): - """ + """ Verify that the correct error is signalled if the suspend and fail flag are both set when disassociating a transaction from - the session + the session """ session = self.session session.dtx_select() @@ -356,16 +356,16 @@ class DtxTests(TestBase010): except SessionException, e: self.assertEquals(503, e.args[0].error_code) - #cleanup + #cleanup other = self.connect() session = other.session("cleanup", 1) session.dtx_rollback(xid=tx) session.close() other.close() - + def test_end_unknown_xid(self): - """ + """ Verifies that the correct exception is thrown when an attempt is made to end the association for a xid not previously associated with the session @@ -382,7 +382,7 @@ class DtxTests(TestBase010): def test_end(self): """ Verify that the association is terminated by end and subsequent - operations are non-transactional + operations are non-transactional """ guard = self.keepQueuesAlive(["tx-queue"]) session = self.conn.session("alternate", 1) @@ -408,7 +408,7 @@ class DtxTests(TestBase010): session.message_accept(RangedSet(msg.id)) session.close() - session = self.session + session = self.session #commit the transaction and check that the first message (and #only the first message) is then delivered session.dtx_commit(xid=tx, one_phase=True) @@ -418,7 +418,7 @@ class DtxTests(TestBase010): def test_invalid_commit_one_phase_true(self): """ Test that a commit with one_phase = True is rejected if the - transaction in question has already been prepared. + transaction in question has already been prepared. """ other = self.connect() tester = other.session("tester", 1) @@ -447,7 +447,7 @@ class DtxTests(TestBase010): def test_invalid_commit_one_phase_false(self): """ Test that a commit with one_phase = False is rejected if the - transaction in question has not yet been prepared. + transaction in question has not yet been prepared. """ other = self.connect() tester = other.session("tester", 1) @@ -474,7 +474,7 @@ class DtxTests(TestBase010): def test_invalid_commit_not_ended(self): """ - Test that a commit fails if the xid is still associated with a session. + Test that a commit fails if the xid is still associated with a session. """ other = self.connect() tester = other.session("tester", 1) @@ -502,7 +502,7 @@ class DtxTests(TestBase010): def test_invalid_rollback_not_ended(self): """ - Test that a rollback fails if the xid is still associated with a session. + Test that a rollback fails if the xid is still associated with a session. """ other = self.connect() tester = other.session("tester", 1) @@ -531,7 +531,7 @@ class DtxTests(TestBase010): def test_invalid_prepare_not_ended(self): """ - Test that a prepare fails if the xid is still associated with a session. + Test that a prepare fails if the xid is still associated with a session. """ other = self.connect() tester = other.session("tester", 1) @@ -586,9 +586,9 @@ class DtxTests(TestBase010): session1.dtx_rollback(xid=tx) def test_get_timeout(self): - """ + """ Check that get-timeout returns the correct value, (and that a - transaction with a timeout can complete normally) + transaction with a timeout can complete normally) """ session = self.session tx = self.xid("dummy") @@ -599,12 +599,12 @@ class DtxTests(TestBase010): session.dtx_set_timeout(xid=tx, timeout=60) self.assertEqual(60, session.dtx_get_timeout(xid=tx).timeout) self.assertEqual(self.XA_OK, session.dtx_end(xid=tx).status) - self.assertEqual(self.XA_OK, session.dtx_rollback(xid=tx).status) - + self.assertEqual(self.XA_OK, session.dtx_rollback(xid=tx).status) + def test_set_timeout(self): - """ + """ Test the timeout of a transaction results in the expected - behaviour + behaviour """ guard = self.keepQueuesAlive(["queue-a", "queue-b"]) @@ -627,7 +627,7 @@ class DtxTests(TestBase010): self.assertMessageId("timeout", "queue-a") #check the correct codes are returned when we try to complete the txn self.assertEqual(self.XA_RBTIMEOUT, session.dtx_end(xid=tx).status) - self.assertEqual(self.XA_RBTIMEOUT, session.dtx_rollback(xid=tx).status) + self.assertEqual(self.XA_RBTIMEOUT, session.dtx_rollback(xid=tx).status) @@ -649,20 +649,20 @@ class DtxTests(TestBase010): if i in [2, 5, 6, 8]: session.dtx_prepare(xid=tx) prepared.append(tx) - else: + else: session.dtx_rollback(xid=tx) xids = session.dtx_recover().in_doubt - + #rollback the prepared transactions returned by recover for x in xids: - session.dtx_rollback(xid=x) + session.dtx_rollback(xid=x) #validate against the expected list of prepared transactions 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) @@ -723,7 +723,7 @@ class DtxTests(TestBase010): session.message_transfer(message=Message(dp, mp, "DtxMessage")) #start the transaction: - session.dtx_select() + session.dtx_select() self.assertEqual(self.XA_OK, self.session.dtx_start(xid=tx).status) #'swap' the message from one queue to the other, under that transaction: @@ -760,7 +760,7 @@ class DtxTests(TestBase010): def getMessageProperty(self, msg, prop): for h in msg.headers: if hasattr(h, prop): return getattr(h, prop) - return None + return None def keepQueuesAlive(self, names): session = self.conn.session("nasty", 99) @@ -768,7 +768,7 @@ class DtxTests(TestBase010): session.queue_declare(queue=n, auto_delete=True) session.message_subscribe(destination=n, queue=n) return session - + def createMessage(self, session, key, id, body): dp=session.delivery_properties(routing_key=key) mp=session.message_properties(correlation_id=id)
Modified: qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/exchange.py URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/exchange.py?rev=1172657&r1=1172656&r2=1172657&view=diff ============================================================================== --- qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/exchange.py (original) +++ qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/exchange.py Mon Sep 19 15:13:18 2011 @@ -226,8 +226,6 @@ class DefaultExchangeRuleTests(TestHelpe # Test automatic binding by queue name. self.queue_declare(queue="d") self.assertPublishConsume(queue="d", routing_key="d") - # Test explicit bind to default queue - self.verifyDirectExchange("") # TODO aconway 2006-09-27: Fill in empty tests: @@ -460,7 +458,30 @@ class MiscellaneousErrorsTests(TestHelpe self.fail("Expected 530 for redeclaration of exchange with different type.") except SessionException, e: self.assertEquals(530, e.args[0].error_code) - + + def testDefaultAccessBind(self): + try: + self.session.queue_declare(queue="my-queue", auto_delete=True, exclusive=True) + self.session.exchange_bind(exchange="", queue="my-queue", binding_key="another-key") + self.fail("Expected 542 (invalid-argument) code for bind to default exchange.") + except SessionException, e: + self.assertEquals(542, e.args[0].error_code) + + def testDefaultAccessUnbind(self): + try: + self.session.queue_declare(queue="my-queue", auto_delete=True, exclusive=True) + self.session.exchange_unbind(exchange="", queue="my-queue", binding_key="my-queue") + self.fail("Expected 542 (invalid-argument) code for unbind from default exchange.") + except SessionException, e: + self.assertEquals(542, e.args[0].error_code) + + def testDefaultAccessDelete(self): + try: + self.session.exchange_delete(exchange="") + self.fail("Expected 542 (invalid-argument) code for delete of default exchange.") + except SessionException, e: + self.assertEquals(542, e.args[0].error_code) + class ExchangeTests(TestHelper): def testHeadersBindNoMatchArg(self): self.session.queue_declare(queue="q", exclusive=True, auto_delete=True) Modified: qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/message.py URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/message.py?rev=1172657&r1=1172656&r2=1172657&view=diff ============================================================================== --- qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/message.py (original) +++ qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_10/message.py Mon Sep 19 15:13:18 2011 @@ -508,6 +508,47 @@ class MessageTests(TestBase010): msgB = q.get(timeout=10) + def test_window_stop(self): + """ + Ensure window based flow control reacts to stop correctly + """ + session = self.session + #setup subscriber on a test queue + session.queue_declare(queue = "q", exclusive=True, auto_delete=True) + session.message_subscribe(queue = "q", destination = "c") + session.message_set_flow_mode(flow_mode = 1, destination = "c") + session.message_flow(unit = session.credit_unit.message, value = 5, destination = "c") + session.message_flow(unit = session.credit_unit.byte, value = 0xFFFFFFFFL, destination = "c") + + + #send batch of messages to queue + for i in range(0, 10): + session.message_transfer(message=Message(session.delivery_properties(routing_key="q"), "Message %d" % (i+1))) + + #retrieve all delivered messages + q = session.incoming("c") + for i in range(0, 5): + msg = q.get(timeout = 1) + session.receiver._completed.add(msg.id)#TODO: this may be done automatically + self.assertDataEquals(session, msg, "Message %d" % (i+1)) + + session.message_stop(destination = "c") + + #now send completions, normally used to move window forward, + #but after a stop should not do so + session.channel.session_completed(session.receiver._completed) + + #check no more messages are sent + self.assertEmpty(q) + + #re-establish window and check remaining messages + session.message_flow(unit = session.credit_unit.message, value = 5, destination = "c") + session.message_flow(unit = session.credit_unit.byte, value = 0xFFFFFFFFL, destination = "c") + for i in range(0, 5): + msg = q.get(timeout = 1) + self.assertDataEquals(session, msg, "Message %d" % (i+6)) + + def test_subscribe_not_acquired(self): """ Test the not-acquired modes works as expected for a simple case Propchange: qpid/branches/qpid-3346/qpid/tests/src/py/qpid_tests/broker_0_9/queue.py ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Sep 19 15:13:18 2011 @@ -1,4 +1,4 @@ /qpid/branches/qmfv2/qpid/python/tests_0-9/queue.py:902858,902894 /qpid/branches/qpid-2935/qpid/tests/src/py/qpid_tests/broker_0_9/queue.py:1061302-1072333 /qpid/branches/qpid.rnr/python/tests_0-9/queue.py:894071-896158 -/qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_9/queue.py:1156188 +/qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_9/queue.py:1144319-1172654 Modified: qpid/branches/qpid-3346/qpid/tools/src/py/qpid-config URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/tools/src/py/qpid-config?rev=1172657&r1=1172656&r2=1172657&view=diff ============================================================================== --- qpid/branches/qpid-3346/qpid/tools/src/py/qpid-config (original) +++ qpid/branches/qpid-3346/qpid/tools/src/py/qpid-config Mon Sep 19 15:13:18 2011 @@ -39,11 +39,6 @@ Usage: qpid-config [OPTIONS] qpid-config [OPTIONS] unbind <exchange-name> <queue-name> [binding-key]""" description = """ -ADDRESS syntax: - - [username/password@] hostname [:<port>] - [username/password@] ip-address [:<port>] - Examples: $ qpid-config add queue q @@ -102,6 +97,7 @@ class Config: self._flowStopSize = None self._flowResumeSize = None self._extra_arguments = [] + self._returnCode = 0 config = Config() @@ -159,7 +155,7 @@ def OptionsAndArguments(argv): group1 = OptionGroup(parser, "General Options") group1.add_option("-t", "--timeout", action="store", type="int", default=10, metavar="<secs>", help="Maximum time to wait for broker connection (in seconds)") group1.add_option("-b", "--bindings", action="store_true", help="Show bindings in queue or exchange list") - group1.add_option("-a", "--broker-addr", action="store", type="string", default="localhost:5672", metavar="<address>", help="Address of qpidd broker") + group1.add_option("-a", "--broker-addr", action="store", type="string", default="localhost:5672", metavar="<address>", help="Address of qpidd broker with syntax: [username/password@] hostname | ip-address [:<port>]") group1.add_option("--sasl-mechanism", action="store", type="string", metavar="<mech>", help="SASL mechanism for authentication (e.g. EXTERNAL, ANONYMOUS, PLAIN, CRAM-MD, DIGEST-MD5, GSSAPI). SASL automatically picks the most secure available mechanism - use this option to override.") parser.add_option_group(group1) @@ -172,7 +168,7 @@ def OptionsAndArguments(argv): group3 = OptionGroup(parser, "Options for Adding Queues") group3.add_option("--cluster-durable", action="store_true", help="The new queue becomes durable if there is only one functioning cluster node") group3.add_option("--file-count", action="store", type="int", default=8, metavar="<n>", help="Number of files in queue's persistence journal") - group3.add_option("--file-size", action="store", type="int", default=24, metavar="<n>", help="File size in pages (64Kib/page)") + group3.add_option("--file-size", action="store", type="int", default=24, metavar="<n>", help="File size in pages (64KiB/page)") group3.add_option("--max-queue-size", action="store", type="int", metavar="<n>", help="Maximum in-memory queue size as bytes") group3.add_option("--max-queue-count", action="store", type="int", metavar="<n>", help="Maximum in-memory queue size as a number of messages") group3.add_option("--limit-policy", action="store", choices=["none", "reject", "flow-to-disk", "ring", "ring-strict"], metavar="<policy>", help="Action to take when queue limit is reached") @@ -359,9 +355,16 @@ class BrokerManager: caption1 = "Type " caption2 = "Exchange Name" maxNameLen = len(caption2) + found = False for ex in exchanges: if self.match(ex.name, filter): if len(ex.name) > maxNameLen: maxNameLen = len(ex.name) + found = True + if not found: + global config + config._returnCode = 1 + return + print "%s%-*s Attributes" % (caption1, maxNameLen, caption2) line = "" for i in range(((maxNameLen + len(caption1)) / 5) + 5): @@ -398,12 +401,18 @@ class BrokerManager: def QueueList(self, filter): queues = self.qmf.getObjects(_class="queue", _agent=self.brokerAgent) - caption = "Queue Name" maxNameLen = len(caption) + found = False for q in queues: if self.match(q.name, filter): if len(q.name) > maxNameLen: maxNameLen = len(q.name) + found = True + if not found: + global config + config._returnCode = 1 + return + print "%-*s Attributes" % (maxNameLen, caption) line = "" for i in range((maxNameLen / 5) + 5): @@ -675,7 +684,7 @@ def main(argv=None): print "Failed: %s: %s" % (e.__class__.__name__, e) return 1 - return 0 + return config._returnCode if __name__ == "__main__": sys.exit(main()) Modified: qpid/branches/qpid-3346/qpid/tools/src/py/qpid-route URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/tools/src/py/qpid-route?rev=1172657&r1=1172656&r2=1172657&view=diff ============================================================================== --- qpid/branches/qpid-3346/qpid/tools/src/py/qpid-route (original) +++ qpid/branches/qpid-3346/qpid/tools/src/py/qpid-route Mon Sep 19 15:13:18 2011 @@ -217,11 +217,11 @@ class RouteManager: added = False links = self.qmf.getObjects(_class="link") for link in links: - url = BrokerURL("%s:%d" % (link.host, link.port)) + url = BrokerURL(host=link.host, port=link.port) if url.name() not in self.brokerList: print " %s..." % url.name(), try: - b = self.qmf.addBroker("%s:%d" % (link.host, link.port), config._connTimeout) + b = self.qmf.addBroker(url, config._connTimeout) self.brokerList[url.name()] = b added = True print "Ok" @@ -245,7 +245,7 @@ class RouteManager: for bridge in bridges: if bridge.src == ex: link = bridge._linkRef_ - fromUrl = "%s:%s" % (link.host, link.port) + fromUrl = BrokerURL(host=link.host, port=link.port) toUrl = bridge.getBroker().getUrl() found = False for pair in pairs: Modified: qpid/branches/qpid-3346/qpid/tools/src/py/qpid-tool URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/tools/src/py/qpid-tool?rev=1172657&r1=1172656&r2=1172657&view=diff ============================================================================== --- qpid/branches/qpid-3346/qpid/tools/src/py/qpid-tool (original) +++ qpid/branches/qpid-3346/qpid/tools/src/py/qpid-tool Mon Sep 19 15:13:18 2011 @@ -350,7 +350,7 @@ class QmfData(Console): self.notNone(prop.unit), notes, self.notNone(prop.desc)) rows.append(row) for stat in schema.getStatistics(): - row = (stat.name, self.typeName(stat.type), "", self.notNone(prop.unit), "", self.notNone(prop.desc)) + row = (stat.name, self.typeName(stat.type), "", self.notNone(stat.unit), "", self.notNone(stat.desc)) rows.append(row) self.disp.table(title, heads, rows) --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected]
