diff options
| author | Ted Ross <tross@apache.org> | 2009-03-27 20:46:24 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2009-03-27 20:46:24 +0000 |
| commit | b264a276f994526ce24062c3f852fdd658857d29 (patch) | |
| tree | 6aedda9cc832c27d39856a6bb3f9dcc0b64ee146 /python/tests_0-10 | |
| parent | 2c8be931523ca30352ed01164ff70ac0f60fc02a (diff) | |
| download | qpid-python-b264a276f994526ce24062c3f852fdd658857d29.tar.gz | |
QPID-1702 QPID-1706
Updated qmf console in Python and Ruby
- Added support for asynchronous method invocation
- Added option to override timeout for method request and get request
- Added exception handler in delegates.rb to catch Sasl errors
- Added tests for the async method features
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@759341 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/tests_0-10')
| -rw-r--r-- | python/tests_0-10/management.py | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/python/tests_0-10/management.py b/python/tests_0-10/management.py index 545dc3db3b..29394c6a7d 100644 --- a/python/tests_0-10/management.py +++ b/python/tests_0-10/management.py @@ -20,6 +20,9 @@ from qpid.datatypes import Message, RangedSet from qpid.testlib import TestBase010 from qpid.management import managementChannel, managementClient +from threading import Condition +from time import sleep +import qmf.console class ManagementTest (TestBase010): """ @@ -52,7 +55,7 @@ class ManagementTest (TestBase010): self.assertEqual (res.body, body) mc.removeChannel (mch) - def test_broker_connectivity (self): + def test_methods_sync (self): """ Call the "echo" method on the broker to verify it is alive and talking. """ @@ -60,16 +63,16 @@ class ManagementTest (TestBase010): self.startQmf() brokers = self.qmf.getObjects(_class="broker") - self.assertEqual (len(brokers), 1) + self.assertEqual(len(brokers), 1) broker = brokers[0] body = "Echo Message Body" - for seq in range (1, 10): + for seq in range(1, 20): res = broker.echo(seq, body) - self.assertEqual (res.status, 0) - self.assertEqual (res.text, "OK") - self.assertEqual (res.sequence, seq) - self.assertEqual (res.body, body) + self.assertEqual(res.status, 0) + self.assertEqual(res.text, "OK") + self.assertEqual(res.sequence, seq) + self.assertEqual(res.body, body) def test_get_objects(self): self.startQmf() @@ -238,3 +241,57 @@ class ManagementTest (TestBase010): pq = self.qmf.getObjects(_class="queue", name="purge-queue")[0] self.assertEqual (pq.msgDepth,0) + def test_methods_async (self): + """ + """ + class Handler (qmf.console.Console): + def __init__(self): + self.cv = Condition() + self.xmtList = {} + self.rcvList = {} + + def methodResponse(self, broker, seq, response): + self.cv.acquire() + try: + self.rcvList[seq] = response + finally: + self.cv.release() + + def request(self, broker, count): + self.count = count + for idx in range(count): + self.cv.acquire() + try: + seq = broker.echo(idx, "Echo Message", _async = True) + self.xmtList[seq] = idx + finally: + self.cv.release() + + def check(self): + if self.count != len(self.xmtList): + return "fail (attempted send=%d, actual sent=%d)" % (self.count, len(self.xmtList)) + lost = 0 + mismatched = 0 + for seq in self.xmtList: + value = self.xmtList[seq] + if seq in self.rcvList: + result = self.rcvList.pop(seq) + if result.sequence != value: + mismatched += 1 + else: + lost += 1 + spurious = len(self.rcvList) + if lost == 0 and mismatched == 0 and spurious == 0: + return "pass" + else: + return "fail (lost=%d, mismatch=%d, spurious=%d)" % (lost, mismatched, spurious) + + handler = Handler() + self.startQmf(handler) + brokers = self.qmf.getObjects(_class="broker") + self.assertEqual(len(brokers), 1) + broker = brokers[0] + handler.request(broker, 20) + sleep(1) + self.assertEqual(handler.check(), "pass") + |
