Repository: qpid-interop-test Updated Branches: refs/heads/master aa01b8e0c -> 138dc7d1e
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/shims/qpid-proton-python/src/jms_messages_test/Sender.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/src/jms_messages_test/Sender.py b/shims/qpid-proton-python/src/jms_messages_test/Sender.py index 33a6acd..16c3770 100755 --- a/shims/qpid-proton-python/src/jms_messages_test/Sender.py +++ b/shims/qpid-proton-python/src/jms_messages_test/Sender.py @@ -29,27 +29,13 @@ from struct import pack, unpack import sys from traceback import format_exc +from qpid_interop_test.jms_types import create_annotation from proton import byte, char, float32, int32, Message, short, symbol from proton.handlers import MessagingHandler from proton.reactor import Container from qpid_interop_test.interop_test_errors import InteropTestError -# These values must tie in with the Qpid-JMS client values found in -# org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport -QPID_JMS_TYPE_ANNOTATION_NAME = symbol(u'x-opt-jms-msg-type') -QPID_JMS_TYPE_ANNOTATIONS = { - 'JMS_MESSAGE_TYPE': byte(0), - 'JMS_BYTESMESSAGE_TYPE': byte(3), - 'JMS_MAPMESSAGE_TYPE': byte(2), - 'JMS_OBJECTMESSAGE_TYPE': byte(1), - 'JMS_STREAMMESSAGE_TYPE': byte(4), - 'JMS_TEXTMESSAGE_TYPE': byte(5) - } -def create_annotation(jms_msg_type): - """Function which creates a message annotation for JMS message type as used by the Qpid JMS client""" - return {QPID_JMS_TYPE_ANNOTATION_NAME: QPID_JMS_TYPE_ANNOTATIONS[jms_msg_type]} - -class JmsSenderShim(MessagingHandler): +class JmsMessagesTestSender(MessagingHandler): """ This shim sends JMS messages of a particular JMS message type according to the test parameters list. This list contains three maps: @@ -61,7 +47,7 @@ class JmsSenderShim(MessagingHandler): with (or without) JMS headers and properties. """ def __init__(self, broker_ip_addr, queue_name, jms_msg_type, test_parameters_list): - super(JmsSenderShim, self).__init__() + super(JmsMessagesTestSender, self).__init__() self.broker_ip_addr = broker_ip_addr self.queue_name = queue_name self.jms_msg_type = jms_msg_type @@ -83,13 +69,13 @@ class JmsSenderShim(MessagingHandler): return def on_connection_error(self, event): - print 'JmsSenderShim.on_connection_error' + print 'JmsMessagesTestSender.on_connection_error' def on_session_error(self, event): - print 'JmsSenderShim.on_session_error' + print 'JmsMessagesTestSender.on_session_error' def on_link_error(self, event): - print 'JmsSenderShim.on_link_error' + print 'JmsMessagesTestSender.on_link_error' def on_accepted(self, event): """Event callback for when a sent message is accepted by the broker""" @@ -142,16 +128,16 @@ class JmsSenderShim(MessagingHandler): elif self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE': return self._create_jms_textmessage(test_value) else: - print 'jms-send: Unsupported JMS message type "%s"' % self.jms_msg_type + print 'JmsMessagesTestSender: Unsupported JMS message type "%s"' % self.jms_msg_type return None def _create_jms_message(self, test_value_type, test_value): """Create a JMS message type (without message body)""" if test_value_type != 'none': - raise InteropTestError('JmsSenderShim._create_jms_message: Unknown or unsupported subtype "%s"' % + raise InteropTestError('JmsMessagesTestSender._create_jms_message: Unknown or unsupported subtype "%s"' % test_value_type) if test_value is not None: - raise InteropTestError('JmsSenderShim._create_jms_message: Invalid value "%s" for subtype "%s"' % + raise InteropTestError('JmsMessagesTestSender._create_jms_message: Invalid value "%s" for subtype "%s"' % (test_value, test_value_type)) return Message(id=(self.sent+1), content_type='application/octet-stream', @@ -183,7 +169,7 @@ class JmsSenderShim(MessagingHandler): test_value_str = str(test_value) # remove unicode body_bytes = pack('!H', len(test_value_str)) + test_value_str else: - raise InteropTestError('JmsSenderShim._create_jms_bytesmessage: Unknown or unsupported subtype "%s"' % + raise InteropTestError('JmsMessagesTestSender._create_jms_bytesmessage: Unknown or unsupported subtype "%s"' % test_value_type) return Message(id=(self.sent+1), body=body_bytes, @@ -214,7 +200,7 @@ class JmsSenderShim(MessagingHandler): elif test_value_type == 'string': value = test_value else: - raise InteropTestError('JmsSenderShim._create_jms_mapmessage: Unknown or unsupported subtype "%s"' % + raise InteropTestError('JmsMessagesTestSender._create_jms_mapmessage: Unknown or unsupported subtype "%s"' % test_value_type) return Message(id=(self.sent+1), body={name: value}, @@ -240,7 +226,7 @@ class JmsSenderShim(MessagingHandler): java_class_str]) out_str_list = out_str.split('\n')[:-1] # remove trailing \n if out_str_list[0] != java_class_str: - raise InteropTestError('JmsSenderShim._s_get_java_obj_binary(): Call to JavaObjToBytes failed\n%s' % + raise InteropTestError('JmsMessagesTestSender._s_get_java_obj_binary(): Call to JavaObjToBytes failed\n%s' % out_str) return out_str_list[1].decode('hex') @@ -267,7 +253,7 @@ class JmsSenderShim(MessagingHandler): elif test_value_type == 'string': body_list = [test_value] else: - raise InteropTestError('JmsSenderShim._create_jms_streammessage: Unknown or unsupported subtype "%s"' % + raise InteropTestError('JmsMessagesTestSender._create_jms_streammessage: Unknown or unsupported subtype "%s"' % test_value_type) return Message(id=(self.sent+1), body=body_list, @@ -291,7 +277,8 @@ class JmsSenderShim(MessagingHandler): #print '#### sys.argv=%s' % sys.argv #print '>>> test_values=%s' % loads(sys.argv[4]) try: - Container(JmsSenderShim(sys.argv[1], sys.argv[2], sys.argv[3], loads(sys.argv[4]))).run() + SENDER = JmsMessagesTestSender(sys.argv[1], sys.argv[2], sys.argv[3], loads(sys.argv[4])) + Container(SENDER).run() except KeyboardInterrupt: pass except Exception as exc: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/amqp_dtx_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/amqp_dtx_test.py b/src/python/qpid_interop_test/amqp_dtx_test.py new file mode 100644 index 0000000..3c02f1e --- /dev/null +++ b/src/python/qpid_interop_test/amqp_dtx_test.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python + +""" +Module to test AMQP distributed transactions across different clients +""" + +# +# 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. +# + +import argparse +import sys +import unittest + +#from itertools import product +#from json import dumps +from os import getenv, path +#from time import mktime, time +#from uuid import UUID, uuid4 + +from proton import symbol +#import qpid_interop_test.broker_properties +import qpid_interop_test.shims +#from qpid_interop_test.test_type_map import TestTypeMap + +# TODO: propose a sensible default when installation details are worked out +QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') +if QPID_INTEROP_TEST_HOME is None: + print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' + sys.exit(1) + + +class AmqpDtxTestCase(unittest.TestCase): + """ + Abstract base class for AMQP distributed transactions (DTX) test cases + """ + + def run_test(self): + """ + Run this test by invoking the shim send method to send the test values, followed by the shim receive method + to receive the values. Finally, compare the sent values with the received values. + """ + pass + + +# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For +# every shim in this list, a test is dynamically constructed which tests it against itself as well as every +# other shim in the list. +# +# As new shims are added, add them into this map to have them included in the test cases. +PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_dtx_test', + 'Receiver') +PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_dtx_test', + 'Sender') +PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', 'amqp_dtx_test', + 'Receiver.py') +PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', 'amqp_dtx_test', + 'Sender.py') + +SHIM_MAP = {qpid_interop_test.shims.ProtonCppShim.NAME: \ + qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), + qpid_interop_test.shims.ProtonPythonShim.NAME: \ + qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), + } + + +class TestOptions(object): + """ + Class controlling command-line arguments used to control the test. + """ + def __init__(self): + parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' + 'for AMQP distrubuted (dtx) transactions') + parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', + help='Broker against which to run test suite.') + parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME', + help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys())) + self.args = parser.parse_args() + + +#--- Main program start --- + +if __name__ == '__main__': + + ARGS = TestOptions().args + #print 'ARGS:', ARGS # debug + + # Connect to broker to find broker type + CONNECTION_PROPS = qpid_interop_test.broker_properties.get_broker_properties(ARGS.broker) + if CONNECTION_PROPS is None: + print 'WARNING: Unable to get connection properties - unknown broker' + BROKER = 'unknown' + else: + BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ + else '<product not found>' + BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ + else '<version not found>' + BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ + else '<platform not found>' + print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) + print + sys.stdout.flush() + + # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed + # per AMQP type used as the key in map AmqpPrimitiveTypes.TYPE_MAP. + TEST_CASE_CLASSES = [] + + # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created + # type classes, each of which contains a test for the combinations of client shims + TEST_SUITE = unittest.TestSuite() + + # Remove shims excluded from the command-line + if ARGS.exclude_shim is not None: + for shim in ARGS.exclude_shim: + SHIM_MAP.pop(shim) + # Create test classes dynamically + + # Finally, run all the dynamically created tests + RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) + if not RES.wasSuccessful(): + sys.exit(1) # Errors or failures present http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/amqp_features_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/amqp_features_test.py b/src/python/qpid_interop_test/amqp_features_test.py new file mode 100644 index 0000000..c80e051 --- /dev/null +++ b/src/python/qpid_interop_test/amqp_features_test.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python + +""" +Module to test AMQP features across different clients +""" + +# +# 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. +# + +import argparse +import sys +import unittest + +#from itertools import product +#from json import dumps +from os import getenv, path +#from time import mktime, time +#from uuid import UUID, uuid4 + +from proton import symbol +#import qpid_interop_test.broker_properties +import qpid_interop_test.shims +#from qpid_interop_test.test_type_map import TestTypeMap + +# TODO: propose a sensible default when installation details are worked out +QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') +if QPID_INTEROP_TEST_HOME is None: + print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' + sys.exit(1) + + +class AmqpFeaturesTestCase(unittest.TestCase): + """ + Abstract base class for AMQP message features test cases + """ + + def run_test(self): + """ + Run this test by invoking the shim send method to send the test values, followed by the shim receive method + to receive the values. Finally, compare the sent values with the received values. + """ + pass + + +# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For +# every shim in this list, a test is dynamically constructed which tests it against itself as well as every +# other shim in the list. +# +# As new shims are added, add them into this map to have them included in the test cases. +PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_features_test', + 'Receiver') +PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_features_test', + 'Sender') +PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'amqp_features_test', 'Receiver.py') +PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'amqp_features_test', 'Sender.py') + +SHIM_MAP = {qpid_interop_test.shims.ProtonCppShim.NAME: \ + qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), + qpid_interop_test.shims.ProtonPythonShim.NAME: \ + qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), + } + + +class TestOptions(object): + """ + Class controlling command-line arguments used to control the test. + """ + def __init__(self): + parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' + 'for AMQP messaging features') + parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', + help='Broker against which to run test suite.') + parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME', + help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys())) + self.args = parser.parse_args() + + +#--- Main program start --- + +if __name__ == '__main__': + + ARGS = TestOptions().args + #print 'ARGS:', ARGS # debug + + # Connect to broker to find broker type + CONNECTION_PROPS = qpid_interop_test.broker_properties.get_broker_properties(ARGS.broker) + if CONNECTION_PROPS is None: + print 'WARNING: Unable to get connection properties - unknown broker' + BROKER = 'unknown' + else: + BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ + else '<product not found>' + BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ + else '<version not found>' + BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ + else '<platform not found>' + print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) + print + sys.stdout.flush() + + # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed + # per AMQP type used as the key in map AmqpPrimitiveTypes.TYPE_MAP. + TEST_CASE_CLASSES = [] + + # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created + # type classes, each of which contains a test for the combinations of client shims + TEST_SUITE = unittest.TestSuite() + + # Remove shims excluded from the command-line + if ARGS.exclude_shim is not None: + for shim in ARGS.exclude_shim: + SHIM_MAP.pop(shim) + # Create test classes dynamically + + # Finally, run all the dynamically created tests + RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) + if not RES.wasSuccessful(): + sys.exit(1) # Errors or failures present http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/amqp_large_content_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/amqp_large_content_test.py b/src/python/qpid_interop_test/amqp_large_content_test.py new file mode 100644 index 0000000..497e8d5 --- /dev/null +++ b/src/python/qpid_interop_test/amqp_large_content_test.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python + +""" +Module to test AMQP messages with large content (bodies and headers/properties) across different clients +""" + +# +# 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. +# + +import argparse +import sys +import unittest + +#from itertools import product +#from json import dumps +from os import getenv, path +#from time import mktime, time +#from uuid import UUID, uuid4 + +from proton import symbol +#import qpid_interop_test.broker_properties +import qpid_interop_test.shims +#from qpid_interop_test.test_type_map import TestTypeMap + +# TODO: propose a sensible default when installation details are worked out +QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') +if QPID_INTEROP_TEST_HOME is None: + print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' + sys.exit(1) + + + +class AmqpVariableSizeTypes(TestTypeMap): + """ + Class which contains all the described AMQP primitive types and the test values to be used in testing. + """ + + VARIABLE_SIZE_TYPE_MAP = { + 'binary': b'abcdefghijklmnopqrstuvwxyz0123456789', + 'string': u'abcdefghijklmnopqrstuvwxyz0123456789', + 'symbol': 'abcdefghijklmnopqrstuvwxyz0123456789', + 'list': [], + 'map': {}, + 'array': [], + } + + # This section contains tests that should be skipped because of know issues that would cause the test to fail. + # As the issues are resolved, these should be removed. + BROKER_SKIP = {} + + +class AmqpLargeContentTestCase(unittest.TestCase): + """ + Abstract base class for AMQP large content test cases + """ + + def run_test(self): + """ + Run this test by invoking the shim send method to send the test values, followed by the shim receive method + to receive the values. Finally, compare the sent values with the received values. + """ + pass + + +# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For +# every shim in this list, a test is dynamically constructed which tests it against itself as well as every +# other shim in the list. +# +# As new shims are added, add them into this map to have them included in the test cases. +PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', + 'amqp_large_content_test', 'Receiver') +PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', + 'amqp_large_content_test', 'Sender') +PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'amqp_large_content_test', 'Receiver.py') +PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'amqp_large_content_test', 'Sender.py') + +SHIM_MAP = {qpid_interop_test.shims.ProtonCppShim.NAME: \ + qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), + qpid_interop_test.shims.ProtonPythonShim.NAME: \ + qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), + } + + +class TestOptions(object): + """ + Class controlling command-line arguments used to control the test. + """ + def __init__(self): + parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' + 'for AMQP messages with large content') + parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', + help='Broker against which to run test suite.') + parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME', + help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys())) + self.args = parser.parse_args() + + +#--- Main program start --- + +if __name__ == '__main__': + + ARGS = TestOptions().args + #print 'ARGS:', ARGS # debug + + # Connect to broker to find broker type + CONNECTION_PROPS = qpid_interop_test.broker_properties.get_broker_properties(ARGS.broker) + if CONNECTION_PROPS is None: + print 'WARNING: Unable to get connection properties - unknown broker' + BROKER = 'unknown' + else: + BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ + else '<product not found>' + BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ + else '<version not found>' + BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ + else '<platform not found>' + print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) + print + sys.stdout.flush() + + # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed + # per AMQP type used as the key in map AmqpPrimitiveTypes.TYPE_MAP. + TEST_CASE_CLASSES = [] + + # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created + # type classes, each of which contains a test for the combinations of client shims + TEST_SUITE = unittest.TestSuite() + + # Remove shims excluded from the command-line + if ARGS.exclude_shim is not None: + for shim in ARGS.exclude_shim: + SHIM_MAP.pop(shim) + # Create test classes dynamically + + # Finally, run all the dynamically created tests + RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) + if not RES.wasSuccessful(): + sys.exit(1) # Errors or failures present http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/amqp_types_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/amqp_types_test.py b/src/python/qpid_interop_test/amqp_types_test.py index bde21f3..a61dfc6 100755 --- a/src/python/qpid_interop_test/amqp_types_test.py +++ b/src/python/qpid_interop_test/amqp_types_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -Module to test AMQP primitive types across different APIs +Module to test AMQP primitive types across different clients """ # http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/jms_dtx_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/jms_dtx_test.py b/src/python/qpid_interop_test/jms_dtx_test.py new file mode 100755 index 0000000..62588a8 --- /dev/null +++ b/src/python/qpid_interop_test/jms_dtx_test.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python + +""" +Module to test JMS distributed transactions (DTX) across different JMS clients +""" + +# +# 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. +# + +import argparse +import sys +import unittest + +#from itertools import product +#from json import dumps +from os import getenv, path + +from proton import symbol +#import qpid_interop_test.broker_properties +import qpid_interop_test.shims +#from qpid_interop_test.test_type_map import TestTypeMap + + +# TODO: propose a sensible default when installation details are worked out +QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') +if QPID_INTEROP_TEST_HOME is None: + print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' + sys.exit(1) +MAVEN_REPO_PATH = getenv('MAVEN_REPO_PATH', path.join(getenv('HOME'), '.m2', 'repository')) + + + +class JmsDtxTypeTestCase(unittest.TestCase): + """ + Abstract base class for JMS DTX test cases + """ + + def run_test(self, broker_addr, jms_message_type, test_values, send_shim, receive_shim): + """ + Run this test by invoking the shim send method to send the test values, followed by the shim receive method + to receive the values. Finally, compare the sent values with the received values. + """ + pass + + +PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', + 'jms_dtx_test', 'Receiver') +PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', + 'jms_dtx_test', 'Sender') +PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'jms_dtx_test', 'Receiver.py') +PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'jms_dtx_test', 'Sender.py') +QIT_JMS_CLASSPATH_FILE = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'cp.txt') +with open(QIT_JMS_CLASSPATH_FILE, 'r') as classpath_file: + QIT_JMS_CLASSPATH = classpath_file.read() +QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.interop_test.jms_dtx_test.Receiver' +QPID_JMS_SENDER_SHIM = 'org.apache.qpid.interop_test.jms_dtx_test.Sender' + +# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For +# every shim in this list, a test is dynamically constructed which tests it against itself as well as every +# other shim in the list. +# +# As new shims are added, add them into this map to have them included in the test cases. +SHIM_MAP = {qpid_interop_test.shims.ProtonCppShim.NAME: \ + qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), + qpid_interop_test.shims.ProtonPythonShim.NAME: \ + qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), + qpid_interop_test.shims.QpidJmsShim.NAME: \ + qpid_interop_test.shims.QpidJmsShim(QIT_JMS_CLASSPATH, QPID_JMS_SENDER_SHIM, QPID_JMS_RECEIVER_SHIM), + } + +# TODO: Complete the test options to give fine control over running tests +class TestOptions(object): + """ + Class controlling command-line arguments used to control the test. + """ + def __init__(self,): + parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' + 'for JMS distrubuted (dtx) transactions') + parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', + help='Broker against which to run test suite.') + parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME', + help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys())) + self.args = parser.parse_args() + + +#--- Main program start --- + +if __name__ == '__main__': + + ARGS = TestOptions().args + #print 'ARGS:', ARGS # debug + + # Connect to broker to find broker type + CONNECTION_PROPS = qpid_interop_test.broker_properties.get_broker_properties(ARGS.broker) + if CONNECTION_PROPS is None: + print 'WARNING: Unable to get connection properties - unknown broker' + BROKER = 'unknown' + else: + BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ + else '<product not found>' + BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ + else '<version not found>' + BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ + else '<platform not found>' + print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) + print + sys.stdout.flush() + + # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed + # per AMQP type used as the key in map JmsMessageTypes.TYPE_MAP. + TEST_CASE_CLASSES = [] + + # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created + # type classes, each of which contains a test for the combinations of client shims + TEST_SUITE = unittest.TestSuite() + + # Remove shims excluded from the command-line + if ARGS.exclude_shim is not None: + for shim in ARGS.exclude_shim: + SHIM_MAP.pop(shim) + # Create test classes dynamically + + # Finally, run all the dynamically created tests + RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) + if not RES.wasSuccessful(): + sys.exit(1) http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/jms_hdrs_props_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/jms_hdrs_props_test.py b/src/python/qpid_interop_test/jms_hdrs_props_test.py index 92a40d1..1edb054 100755 --- a/src/python/qpid_interop_test/jms_hdrs_props_test.py +++ b/src/python/qpid_interop_test/jms_hdrs_props_test.py @@ -610,7 +610,7 @@ class TestOptions(object): """ def __init__(self,): parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' - 'for JMS message types') + 'for JMS headers and properties') parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', help='Broker against which to run test suite.') # test_group = parser.add_mutually_exclusive_group() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/jms_large_content_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/jms_large_content_test.py b/src/python/qpid_interop_test/jms_large_content_test.py new file mode 100755 index 0000000..6387060 --- /dev/null +++ b/src/python/qpid_interop_test/jms_large_content_test.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python + +""" +Module to test JMS messages containing large content (either message bodies or properties) across different JMS clients +""" + +# +# 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. +# + +import argparse +import sys +import unittest + +#from itertools import product +#from json import dumps +from os import getenv, path + +from proton import symbol +#import qpid_interop_test.broker_properties +import qpid_interop_test.shims +#from qpid_interop_test.test_type_map import TestTypeMap + + +# TODO: propose a sensible default when installation details are worked out +QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') +if QPID_INTEROP_TEST_HOME is None: + print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' + sys.exit(1) +MAVEN_REPO_PATH = getenv('MAVEN_REPO_PATH', path.join(getenv('HOME'), '.m2', 'repository')) + + + +class JmsLargeContentTypeTestCase(unittest.TestCase): + """ + Abstract base class for JMS large content test cases + """ + + def run_test(self, broker_addr, jms_message_type, test_values, send_shim, receive_shim): + """ + Run this test by invoking the shim send method to send the test values, followed by the shim receive method + to receive the values. Finally, compare the sent values with the received values. + """ + pass + + +PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', + 'jms_large_content_test', 'Receiver') +PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', + 'jms_large_content_test', 'Sender') +PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'jms_large_content_test', 'Receiver.py') +PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', + 'jms_large_content_test', 'Sender.py') +QIT_JMS_CLASSPATH_FILE = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'cp.txt') +with open(QIT_JMS_CLASSPATH_FILE, 'r') as classpath_file: + QIT_JMS_CLASSPATH = classpath_file.read() +QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.interop_test.jms_large_content_test.Receiver' +QPID_JMS_SENDER_SHIM = 'org.apache.qpid.interop_test.jms_large_content_test.Sender' + +# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For +# every shim in this list, a test is dynamically constructed which tests it against itself as well as every +# other shim in the list. +# +# As new shims are added, add them into this map to have them included in the test cases. +SHIM_MAP = {qpid_interop_test.shims.ProtonCppShim.NAME: \ + qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), + qpid_interop_test.shims.ProtonPythonShim.NAME: \ + qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), + qpid_interop_test.shims.QpidJmsShim.NAME: \ + qpid_interop_test.shims.QpidJmsShim(QIT_JMS_CLASSPATH, QPID_JMS_SENDER_SHIM, QPID_JMS_RECEIVER_SHIM), + } + +# TODO: Complete the test options to give fine control over running tests +class TestOptions(object): + """ + Class controlling command-line arguments used to control the test. + """ + def __init__(self,): + parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' + 'for JMS messages containing large content') + parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', + help='Broker against which to run test suite.') + parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME', + help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys())) + self.args = parser.parse_args() + + +#--- Main program start --- + +if __name__ == '__main__': + + ARGS = TestOptions().args + #print 'ARGS:', ARGS # debug + + # Connect to broker to find broker type + CONNECTION_PROPS = qpid_interop_test.broker_properties.get_broker_properties(ARGS.broker) + if CONNECTION_PROPS is None: + print 'WARNING: Unable to get connection properties - unknown broker' + BROKER = 'unknown' + else: + BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ + else '<product not found>' + BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ + else '<version not found>' + BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ + else '<platform not found>' + print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) + print + sys.stdout.flush() + + # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed + # per AMQP type used as the key in map JmsMessageTypes.TYPE_MAP. + TEST_CASE_CLASSES = [] + + # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created + # type classes, each of which contains a test for the combinations of client shims + TEST_SUITE = unittest.TestSuite() + + # Remove shims excluded from the command-line + if ARGS.exclude_shim is not None: + for shim in ARGS.exclude_shim: + SHIM_MAP.pop(shim) + # Create test classes dynamically + + # Finally, run all the dynamically created tests + RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) + if not RES.wasSuccessful(): + sys.exit(1) http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/138dc7d1/src/python/qpid_interop_test/jms_types.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/jms_types.py b/src/python/qpid_interop_test/jms_types.py new file mode 100644 index 0000000..32745da --- /dev/null +++ b/src/python/qpid_interop_test/jms_types.py @@ -0,0 +1,39 @@ +""" +Common JMS types and definitions as implemented by QpidJMS +""" + +# +# 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 proton import byte, symbol + +QPID_JMS_TYPE_ANNOTATION_NAME = symbol(u'x-opt-jms-msg-type') + +QPID_JMS_TYPE_ANNOTATIONS = { + 'JMS_MESSAGE_TYPE': byte(0), + 'JMS_BYTESMESSAGE_TYPE': byte(3), + 'JMS_MAPMESSAGE_TYPE': byte(2), + 'JMS_OBJECTMESSAGE_TYPE': byte(1), + 'JMS_STREAMMESSAGE_TYPE': byte(4), + 'JMS_TEXTMESSAGE_TYPE': byte(5) + } + +def create_annotation(jms_msg_type): + """Function which creates a message annotation for JMS message type as used by the Qpid JMS client""" + return {QPID_JMS_TYPE_ANNOTATION_NAME: QPID_JMS_TYPE_ANNOTATIONS[jms_msg_type]} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org