QPIDIT-109: Added Python 3 compatibility to Python shims; Added Python 3 shims to tests, but left them commented out for now unitl issues with having both Proton's Python 2 and Python 3 bindings available at the same time.
diff --git a/config.sh.in b/config.sh.in
index 55c11a3..a58e3de 100644
--- a/config.sh.in
+++ b/config.sh.in
@@ -18,6 +18,6 @@
export QPID_INTEROP_TEST_HOME=@CMAKE_SOURCE_DIR@
export QIT_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@
-export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/lib64/proton/bindings/python:@CMAKE_INSTALL_PREFIX@/lib/@PYTHON_DIR_NAME@/site-packages:$PYTHONPATH
+export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/lib64/proton/bindings/python:@CMAKE_INSTALL_PREFIX@/lib/@PYTHON_DIR_NAME@/site-packages:@CMAKE_INSTALL_PREFIX@/libexec/qpid_interop_test/shims/qpid-proton-python:$PYTHONPATH
export LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib64:$LD_LIBRARY_PATH
export PATH=@CMAKE_INSTALL_PREFIX@/lib/@PYTHON_DIR_NAME@/site-packages/qpid_interop_test:$PATH
diff --git a/setup.py b/setup.py
index 9f892c6..a4d0821 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,10 @@
package_dir={'qpid_interop_test': 'src/python/qpid_interop_test'},
# Shims, installed into {INSTALL_PREFIX}/libexec/qpid_interop_test/shims/
- data_files=[('%s/qpid-proton-python/amqp_types_test' % SHIM_DIR,
+ data_files=[ ('%s/qpid-proton-python' % SHIM_DIR,
+ ['shims/qpid-proton-python/src/_compat.py']
+ ),
+ ('%s/qpid-proton-python/amqp_types_test' % SHIM_DIR,
['shims/qpid-proton-python/src/amqp_types_test/Receiver.py',
'shims/qpid-proton-python/src/amqp_types_test/Sender.py',
]
diff --git a/shims/qpid-proton-python/src/_compat.py b/shims/qpid-proton-python/src/_compat.py
new file mode 100644
index 0000000..bafedc7
--- /dev/null
+++ b/shims/qpid-proton-python/src/_compat.py
@@ -0,0 +1,50 @@
+"""
+Python compatibility library that will help shims run under
+both Python 2.7 and Python 3.x
+"""
+
+#
+# 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 string
+import sys
+import types
+
+IS_PY3 = sys.version_info[0] == 3
+
+if IS_PY3:
+ def _letters():
+ return string.ascii_letters
+ def _long(i, r):
+ return int(i, r)
+ def _unichr(i):
+ return chr(i)
+ def _unicode(i):
+ return str(i)
+
+else:
+ def _letters():
+ return string.letters
+ def _long(i, r):
+ return long(i, r)
+ def _unichr(i):
+ return unichr(i)
+ def _unicode(i):
+ return unicode(i)
+
diff --git a/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py b/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
index 90d039f..d958fad 100755
--- a/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
+++ b/shims/qpid-proton-python/src/amqp_large_content_test/Receiver.py
@@ -32,6 +32,8 @@
from proton.handlers import MessagingHandler
from proton.reactor import Container
+import _compat
+
class AmqpLargeContentTestReceiver(MessagingHandler):
"""
Reciver shim for AMQP dtx test
@@ -65,7 +67,7 @@
size, num_elts = self.get_list_size(event.message.body)
else:
size, num_elts = self.get_map_size(event.message.body)
- if len(self.received_value_list) == 0: # list is empty
+ if not self.received_value_list: # list is empty
self.received_value_list.append((size, [num_elts]))
else:
found = False
@@ -84,8 +86,12 @@
@staticmethod
def get_str_message_size(message):
"""Find the size of a bytes, unicode or symbol message in MB"""
- if isinstance(message, bytes) or isinstance(message, unicode) or isinstance(message, symbol):
- return len(str(message)) / 1024 / 1024 # in MB
+ if _compat.IS_PY3:
+ if isinstance(message, (bytes, string, symbol)):
+ return len(str(message)) / 1024 / 1024 # in MB
+ else:
+ if isinstance(message, (bytes, unicode, symbol)):
+ return len(str(message)) / 1024 / 1024 # in MB
return None
@staticmethod
@@ -121,10 +127,10 @@
try:
RECEIVER = AmqpLargeContentTestReceiver(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
Container(RECEIVER).run()
- print sys.argv[3]
- print dumps(RECEIVER.get_received_value_list())
+ print(sys.argv[3])
+ print(dumps(RECEIVER.get_received_value_list()))
except KeyboardInterrupt:
pass
except Exception as exc:
- print os.path.basename(sys.argv[0]), 'EXCEPTION', exc
- print format_exc()
+ print(os.path.basename(sys.argv[0]), 'EXCEPTION', exc)
+ print(format_exc())
diff --git a/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py b/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
index 16e90c1..955c46e 100755
--- a/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
+++ b/shims/qpid-proton-python/src/amqp_large_content_test/Sender.py
@@ -32,6 +32,8 @@
from proton.handlers import MessagingHandler
from proton.reactor import Container
+import _compat
+
class AmqpLargeContentTestSender(MessagingHandler):
"""
Sender shim for AMQP dtx test
@@ -79,7 +81,7 @@
if self.amqp_type == 'binary':
return Message(body=bytes(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
if self.amqp_type == 'string':
- return Message(body=unicode(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
+ return Message(body=_compat._unicode(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
if self.amqp_type == 'symbol':
return Message(body=symbol(AmqpLargeContentTestSender.create_test_string(tot_size_bytes)))
if self.amqp_type == 'list':
@@ -102,7 +104,7 @@
size_per_elt_bytes = tot_size_bytes / num_elts
test_list = []
for _ in range(num_elts):
- test_list.append(unicode(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes)))
+ test_list.append(_compat._unicode(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes)))
return test_list
@staticmethod
@@ -111,8 +113,8 @@
size_per_elt_bytes = tot_size_bytes / num_elts
test_map = {}
for elt_no in range(num_elts):
- test_map[unicode('elt_%06d' % elt_no)] = \
- unicode(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes))
+ test_map[_compat._unicode('elt_%06d' % elt_no)] = \
+ _compat._unicode(AmqpLargeContentTestSender.create_test_string(size_per_elt_bytes))
return test_map
def on_accepted(self, event):
@@ -137,6 +139,6 @@
except KeyboardInterrupt:
pass
except Exception as exc:
- print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc
- print format_exc()
+ print(os.path.basename(sys.argv[0]), 'EXCEPTION:', exc)
+ print(format_exc())
\ No newline at end of file
diff --git a/shims/qpid-proton-python/src/amqp_types_test/Receiver.py b/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
index 0336d98..9d3dc19 100755
--- a/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
+++ b/shims/qpid-proton-python/src/amqp_types_test/Receiver.py
@@ -28,7 +28,8 @@
from json import dumps
import os.path
-from string import digits, letters, punctuation
+#from string import digits, letters, punctuation
+import string
from struct import pack, unpack
import sys
from traceback import format_exc
@@ -36,6 +37,8 @@
from proton.handlers import MessagingHandler
from proton.reactor import Container
+import _compat
+
class AmqpTypesTestReceiver(MessagingHandler):
"""
Reciver shim for AMQP types test
@@ -95,7 +98,8 @@
elif self.amqp_type == 'decimal128':
self.received_value_list.append('0x' + ''.join(['%02x' % ord(c) for c in event.message.body]).strip())
elif self.amqp_type == 'char':
- if ord(event.message.body) < 0x80 and event.message.body in digits + letters + punctuation + " ":
+ if ord(event.message.body) < 0x80 and event.message.body in \
+ string.digits + _compat._letters + string.punctuation + " ":
self.received_value_list.append(event.message.body)
else:
self.received_value_list.append(hex(ord(event.message.body)))
@@ -107,7 +111,7 @@
self.amqp_type == 'map':
self.received_value_list.append(event.message.body)
else:
- print 'receive: Unsupported AMQP type "%s"' % self.amqp_type
+ print('receive: Unsupported AMQP type "%s"' % self.amqp_type)
return
self.received += 1
if self.received >= self.expected:
@@ -122,10 +126,10 @@
try:
RECEIVER = AmqpTypesTestReceiver(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
Container(RECEIVER).run()
- print sys.argv[3]
- print dumps(RECEIVER.get_received_value_list())
+ print(sys.argv[3])
+ print(dumps(RECEIVER.get_received_value_list()))
except KeyboardInterrupt:
pass
except Exception as exc:
- print os.path.basename(sys.argv[0]), 'EXCEPTION', exc
- print format_exc()
+ print(os.path.basename(sys.argv[0]), 'EXCEPTION', exc)
+ print(format_exc())
diff --git a/shims/qpid-proton-python/src/amqp_types_test/Sender.py b/shims/qpid-proton-python/src/amqp_types_test/Sender.py
index b6cfcd2..df47c15 100755
--- a/shims/qpid-proton-python/src/amqp_types_test/Sender.py
+++ b/shims/qpid-proton-python/src/amqp_types_test/Sender.py
@@ -38,6 +38,8 @@
from proton.handlers import MessagingHandler
from proton.reactor import Container
+import _compat
+
class AmqpTypesTestSender(MessagingHandler):
"""
Sender shim for AMQP types test
@@ -79,58 +81,56 @@
"""
if self.amqp_type == 'null':
return Message(id=(self.sent+1), body=None)
- elif self.amqp_type == 'boolean':
+ if self.amqp_type == 'boolean':
return Message(id=(self.sent+1), body=True if test_value == 'True' else False)
- elif self.amqp_type == 'ubyte':
+ if self.amqp_type == 'ubyte':
return Message(id=(self.sent+1), body=ubyte(int(test_value, 16)))
- elif self.amqp_type == 'ushort':
+ if self.amqp_type == 'ushort':
return Message(id=(self.sent+1), body=ushort(int(test_value, 16)))
- elif self.amqp_type == 'uint':
+ if self.amqp_type == 'uint':
return Message(id=(self.sent+1), body=uint(int(test_value, 16)))
- elif self.amqp_type == 'ulong':
+ if self.amqp_type == 'ulong':
return Message(id=(self.sent+1), body=ulong(int(test_value, 16)))
- elif self.amqp_type == 'byte':
+ if self.amqp_type == 'byte':
return Message(id=(self.sent+1), body=byte(int(test_value, 16)))
- elif self.amqp_type == 'short':
+ if self.amqp_type == 'short':
return Message(id=(self.sent+1), body=short(int(test_value, 16)))
- elif self.amqp_type == 'int':
+ if self.amqp_type == 'int':
return Message(id=(self.sent+1), body=int32(int(test_value, 16)))
- elif self.amqp_type == 'long':
- return Message(id=(self.sent+1), body=long(int(test_value, 16)))
- elif self.amqp_type == 'float':
+ if self.amqp_type == 'long':
+ return Message(id=(self.sent+1), body=_compat._long(test_value, 16))
+ if self.amqp_type == 'float':
return Message(id=(self.sent+1), body=float32(unpack('!f', test_value[2:].decode('hex'))[0]))
- elif self.amqp_type == 'double':
+ if self.amqp_type == 'double':
return Message(id=(self.sent+1), body=unpack('!d', test_value[2:].decode('hex'))[0])
- elif self.amqp_type == 'decimal32':
+ if self.amqp_type == 'decimal32':
return Message(id=(self.sent+1), body=decimal32(int(test_value[2:], 16)))
- elif self.amqp_type == 'decimal64':
- l64 = long(test_value[2:], 16)
+ if self.amqp_type == 'decimal64':
+ l64 = _compat._long(test_value[2:], 16)
return Message(id=(self.sent+1), body=decimal64(l64))
- elif self.amqp_type == 'decimal128':
+ if self.amqp_type == 'decimal128':
return Message(id=(self.sent+1), body=decimal128(test_value[2:].decode('hex')))
- elif self.amqp_type == 'char':
+ if self.amqp_type == 'char':
if len(test_value) == 1: # Format 'a'
return Message(id=(self.sent+1), body=char(test_value))
- else:
- val = int(test_value, 16)
- return Message(id=(self.sent+1), body=char(unichr(val)))
- elif self.amqp_type == 'timestamp':
+ val = int(test_value, 16)
+ return Message(id=(self.sent+1), body=char(_compat._unichr(val)))
+ if self.amqp_type == 'timestamp':
return Message(id=(self.sent+1), body=timestamp(int(test_value, 16)))
- elif self.amqp_type == 'uuid':
+ if self.amqp_type == 'uuid':
return Message(id=(self.sent+1), body=UUID(test_value))
- elif self.amqp_type == 'binary':
+ if self.amqp_type == 'binary':
return Message(id=(self.sent+1), body=bytes(test_value))
- elif self.amqp_type == 'string':
- return Message(id=(self.sent+1), body=unicode(test_value))
- elif self.amqp_type == 'symbol':
+ if self.amqp_type == 'string':
+ return Message(id=(self.sent+1), body=_compat._unicode(test_value))
+ if self.amqp_type == 'symbol':
return Message(id=(self.sent+1), body=symbol(test_value))
- elif self.amqp_type == 'list':
+ if self.amqp_type == 'list':
return Message(id=(self.sent+1), body=test_value)
- elif self.amqp_type == 'map':
+ if self.amqp_type == 'map':
return Message(id=(self.sent+1), body=test_value)
- else:
- print 'send: Unsupported AMQP type "%s"' % self.amqp_type
- return None
+ print('send: Unsupported AMQP type "%s"' % self.amqp_type)
+ return None
def on_accepted(self, event):
"""Event callback for when a sent message is accepted by the broker"""
@@ -154,6 +154,6 @@
except KeyboardInterrupt:
pass
except Exception as exc:
- print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc
- print format_exc()
+ print(os.path.basename(sys.argv[0]), 'EXCEPTION:', exc)
+ print(format_exc())
\ No newline at end of file
diff --git a/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py b/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
index 386adaa..cf9813a 100755
--- a/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
+++ b/shims/qpid-proton-python/src/jms_hdrs_props_test/Receiver.py
@@ -23,18 +23,18 @@
# under the License.
#
-from json import dumps, loads
from struct import pack, unpack
from subprocess import check_output
import sys
from time import strftime, time
from traceback import format_exc
+from json import dumps, loads
-from qpid_interop_test.jms_types import QPID_JMS_TYPE_ANNOTATION_NAME
-from qpid_interop_test.interop_test_errors import InteropTestError
-from proton import byte, symbol
+from proton import byte
from proton.handlers import MessagingHandler
from proton.reactor import Container
+from qpid_interop_test.jms_types import QPID_JMS_TYPE_ANNOTATION_NAME
+from qpid_interop_test.interop_test_errors import InteropTestError
class JmsHdrsPropsTestReceiver(MessagingHandler):
@@ -98,13 +98,13 @@
event.connection.close()
def on_connection_error(self, event):
- print 'JmsReceiverShim.on_connection_error'
+ print('JmsReceiverShim.on_connection_error')
def on_session_error(self, event):
- print 'JmsReceiverShim.on_session_error'
+ print('JmsReceiverShim.on_session_error')
def on_link_error(self, event):
- print 'JmsReceiverShim.on_link_error'
+ print('JmsReceiverShim.on_link_error')
def _handle_message(self, message):
"""Handles the analysis of a received message"""
@@ -120,7 +120,7 @@
return self._receive_jms_streammessage(message)
if self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE':
return self._receive_jms_textmessage(message)
- print 'jms-receive: Unsupported JMS message type "%s"' % self.jms_msg_type
+ print('jms-receive: Unsupported JMS message type "%s"' % self.jms_msg_type)
return None
def _get_tot_num_messages(self):
@@ -330,7 +330,7 @@
raise InteropTestError('JMS_EXPIRATION header is non-zero')
# 4. Message ID
message_id = message.id
- if (len(message_id) == 0):
+ if not message_id: # message_id has length 0
raise InteropTestError('JMS_MESSAGEID header is empty (zero-length)')
# TODO: Find a check for this
# 5. Message priority
@@ -383,14 +383,14 @@
# 2: Queue name
# 3: JMS message type
# 4: JSON Test parameters containing 2 maps: [testValuesMap, flagMap]
-#print '#### sys.argv=%s' % sys.argv
+#print('#### sys.argv=%s' % sys.argv)
try:
RECEIVER = JmsHdrsPropsTestReceiver(sys.argv[1], sys.argv[2], sys.argv[3], loads(sys.argv[4]))
Container(RECEIVER).run()
- print sys.argv[3]
- print dumps([RECEIVER.get_received_value_map(), RECEIVER.get_jms_header_map(), RECEIVER.get_jms_property_map()])
+ print(sys.argv[3])
+ print(dumps([RECEIVER.get_received_value_map(), RECEIVER.get_jms_header_map(), RECEIVER.get_jms_property_map()]))
except KeyboardInterrupt:
pass
except Exception as exc:
- print 'jms-receiver-shim EXCEPTION:', exc
- print format_exc()
+ print('jms-receiver-shim EXCEPTION:', exc)
+ print(format_exc())
diff --git a/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py b/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
index 2e24478..d70974e 100755
--- a/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
+++ b/shims/qpid-proton-python/src/jms_hdrs_props_test/Sender.py
@@ -23,20 +23,22 @@
# under the License.
#
-from json import loads
import os.path
from struct import pack, unpack
from subprocess import check_output
import sys
from traceback import format_exc
+from json import loads
-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
+from qpid_interop_test.jms_types import create_annotation
from qpid_interop_test.test_type_map import TestTypeMap
+import _compat
+
class JmsHdrsPropsTestSender(MessagingHandler):
"""
@@ -75,13 +77,13 @@
return
def on_connection_error(self, event):
- print 'JmsSenderShim.on_connection_error'
+ print('JmsSenderShim.on_connection_error')
def on_session_error(self, event):
- print 'JmsSenderShim.on_session_error'
+ print('JmsSenderShim.on_session_error')
def on_link_error(self, event):
- print 'JmsSenderShim.on_link_error'
+ print('JmsSenderShim.on_link_error')
def on_accepted(self, event):
"""Event callback for when a sent message is accepted by the broker"""
@@ -126,20 +128,19 @@
"""Create a single message of the appropriate JMS message type"""
if self.jms_msg_type == 'JMS_MESSAGE_TYPE':
return self._create_jms_message(test_value_type, test_value, hdr_kwargs, hdr_annotations)
- elif self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
return self._create_jms_bytesmessage(test_value_type, test_value, hdr_kwargs, hdr_annotations)
- elif self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE':
return self._create_jms_mapmessage(test_value_type, test_value, "%s%03d" % (test_value_type, value_num),
hdr_kwargs, hdr_annotations)
- elif self.jms_msg_type == 'JMS_OBJECTMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_OBJECTMESSAGE_TYPE':
return self._create_jms_objectmessage('%s:%s' % (test_value_type, test_value), hdr_kwargs, hdr_annotations)
- elif self.jms_msg_type == 'JMS_STREAMMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_STREAMMESSAGE_TYPE':
return self._create_jms_streammessage(test_value_type, test_value, hdr_kwargs, hdr_annotations)
- elif self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE':
return self._create_jms_textmessage(test_value, hdr_kwargs, hdr_annotations)
- else:
- print 'jms-send: Unsupported JMS message type "%s"' % self.jms_msg_type
- return None
+ print('jms-send: Unsupported JMS message type "%s"' % self.jms_msg_type)
+ return None
def _create_jms_message(self, test_value_type, test_value, hdr_kwargs, hdr_annotations):
"""Create a JMS message type (without message body)"""
@@ -173,7 +174,7 @@
elif test_value_type == 'int':
body_bytes = pack('!i', int(test_value, 16))
elif test_value_type == 'long':
- body_bytes = pack('!q', long(test_value, 16))
+ body_bytes = pack('!q', _compat._long(test_value, 16))
elif test_value_type == 'short':
body_bytes = pack('!h', short(test_value, 16))
elif test_value_type == 'string':
@@ -208,7 +209,7 @@
elif test_value_type == 'int':
value = int32(int(test_value, 16))
elif test_value_type == 'long':
- value = long(test_value, 16)
+ value = _compat._long(test_value, 16)
elif test_value_type == 'short':
value = short(int(test_value, 16))
elif test_value_type == 'string':
@@ -265,7 +266,7 @@
elif test_value_type == 'int':
body_list = [int32(int(test_value, 16))]
elif test_value_type == 'long':
- body_list = [long(test_value, 16)]
+ body_list = [_compat._long(test_value, 16)]
elif test_value_type == 'short':
body_list = [short(int(test_value, 16))]
elif test_value_type == 'string':
@@ -283,7 +284,7 @@
def _create_jms_textmessage(self, test_value_text, hdr_kwargs, hdr_annotations):
"""Create a JMS text message"""
return Message(id=(self.sent+1),
- body=unicode(test_value_text),
+ body=_compat._unicode(test_value_text),
annotations=TestTypeMap.merge_dicts(create_annotation('JMS_TEXTMESSAGE_TYPE'),
hdr_annotations),
**hdr_kwargs)
@@ -350,7 +351,7 @@
elif value_type == 'int':
message.properties[property_name] = int(value, 16)
elif value_type == 'long':
- message.properties[property_name] = long(value, 16)
+ message.properties[property_name] = _compat._long(value, 16)
elif value_type == 'short':
message.properties[property_name] = short(int(value, 16))
elif value_type == 'string':
@@ -366,13 +367,13 @@
# 2: Queue name
# 3: JMS message type
# 4: JSON Test parameters containing 3 maps: [testValueMap, testHeadersMap, testPropertiesMap]
-#print '#### sys.argv=%s' % sys.argv
-#print '>>> test_values=%s' % loads(sys.argv[4])
+#print('#### sys.argv=%s' % sys.argv)
+#print('>>> test_values=%s' % loads(sys.argv[4]))
try:
SENDER = JmsHdrsPropsTestSender(sys.argv[1], sys.argv[2], sys.argv[3], loads(sys.argv[4]))
Container(SENDER).run()
except KeyboardInterrupt:
pass
except Exception as exc:
- print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc
- print format_exc()
+ print(os.path.basename(sys.argv[0]), 'EXCEPTION:', exc)
+ print(format_exc())
diff --git a/shims/qpid-proton-python/src/jms_messages_test/Receiver.py b/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
index cdec89c..e7d1172 100755
--- a/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
+++ b/shims/qpid-proton-python/src/jms_messages_test/Receiver.py
@@ -29,11 +29,11 @@
import sys
from traceback import format_exc
-from qpid_interop_test.jms_types import QPID_JMS_TYPE_ANNOTATION_NAME
-from proton import byte, symbol
+from proton import byte
from proton.handlers import MessagingHandler
from proton.reactor import Container
from qpid_interop_test.interop_test_errors import InteropTestError
+from qpid_interop_test.jms_types import QPID_JMS_TYPE_ANNOTATION_NAME
class JmsMessagesTestReceiver(MessagingHandler):
"""
@@ -83,13 +83,13 @@
event.connection.close()
def on_connection_error(self, event):
- print 'JmsMessagesTestReceiver.on_connection_error'
+ print('JmsMessagesTestReceiver.on_connection_error')
def on_session_error(self, event):
- print 'JmsMessagesTestReceiver.on_session_error'
+ print('JmsMessagesTestReceiver.on_session_error')
def on_link_error(self, event):
- print 'JmsMessagesTestReceiver.on_link_error'
+ print('JmsMessagesTestReceiver.on_link_error')
def _handle_message(self, message):
"""Handles the analysis of a received message"""
@@ -105,7 +105,7 @@
return self._receive_jms_streammessage(message)
if self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE':
return self._receive_jms_textmessage(message)
- print 'jms-receive: Unsupported JMS message type "%s"' % self.jms_msg_type
+ print('jms-receive: Unsupported JMS message type "%s"' % self.jms_msg_type)
return None
def _get_tot_num_messages(self):
@@ -274,14 +274,14 @@
# 2: Queue name
# 3: JMS message type
# 4: JSON Test parameters containing 2 maps: [testValuesMap, flagMap]
-#print '#### sys.argv=%s' % sys.argv
+#print('#### sys.argv=%s' % sys.argv)
try:
RECEIVER = JmsMessagesTestReceiver(sys.argv[1], sys.argv[2], sys.argv[3], loads(sys.argv[4]))
Container(RECEIVER).run()
- print sys.argv[3]
- print dumps(RECEIVER.get_received_value_map())
+ print(sys.argv[3])
+ print(dumps(RECEIVER.get_received_value_map()))
except KeyboardInterrupt:
pass
except Exception as exc:
- print 'jms-receiver-shim EXCEPTION:', exc
- print format_exc()
+ print('jms-receiver-shim EXCEPTION:', exc)
+ print(format_exc())
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 1bb1683..472b014 100755
--- a/shims/qpid-proton-python/src/jms_messages_test/Sender.py
+++ b/shims/qpid-proton-python/src/jms_messages_test/Sender.py
@@ -29,11 +29,12 @@
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 import byte, char, float32, int32, Message, short
from proton.handlers import MessagingHandler
from proton.reactor import Container
from qpid_interop_test.interop_test_errors import InteropTestError
+from qpid_interop_test.jms_types import create_annotation
+import _compat
class JmsMessagesTestSender(MessagingHandler):
"""
@@ -70,13 +71,13 @@
return
def on_connection_error(self, event):
- print 'JmsMessagesTestSender.on_connection_error'
+ print('JmsMessagesTestSender.on_connection_error')
def on_session_error(self, event):
- print 'JmsMessagesTestSender.on_session_error'
+ print('JmsMessagesTestSender.on_session_error')
def on_link_error(self, event):
- print 'JmsMessagesTestSender.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"""
@@ -118,19 +119,18 @@
"""Create a single message of the appropriate JMS message type"""
if self.jms_msg_type == 'JMS_MESSAGE_TYPE':
return self._create_jms_message(test_value_type, test_value)
- elif self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
return self._create_jms_bytesmessage(test_value_type, test_value)
- elif self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE':
return self._create_jms_mapmessage(test_value_type, test_value, "%s%03d" % (test_value_type, value_num))
- elif self.jms_msg_type == 'JMS_OBJECTMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_OBJECTMESSAGE_TYPE':
return self._create_jms_objectmessage('%s:%s' % (test_value_type, test_value))
- elif self.jms_msg_type == 'JMS_STREAMMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_STREAMMESSAGE_TYPE':
return self._create_jms_streammessage(test_value_type, test_value)
- elif self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE':
+ if self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE':
return self._create_jms_textmessage(test_value)
- else:
- print 'JmsMessagesTestSender: Unsupported JMS message type "%s"' % self.jms_msg_type
- return None
+ 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)"""
@@ -162,7 +162,7 @@
elif test_value_type == 'int':
body_bytes = pack('!i', int(test_value, 16))
elif test_value_type == 'long':
- body_bytes = pack('!q', long(test_value, 16))
+ body_bytes = pack('!q', _compat._long(test_value, 16))
elif test_value_type == 'short':
body_bytes = pack('!h', short(test_value, 16))
elif test_value_type == 'string':
@@ -195,7 +195,7 @@
elif test_value_type == 'int':
value = int32(int(test_value, 16))
elif test_value_type == 'long':
- value = long(test_value, 16)
+ value = _compat._long(test_value, 16)
elif test_value_type == 'short':
value = short(int(test_value, 16))
elif test_value_type == 'string':
@@ -248,7 +248,7 @@
elif test_value_type == 'int':
body_list = [int32(int(test_value, 16))]
elif test_value_type == 'long':
- body_list = [long(test_value, 16)]
+ body_list = [_compat._long(test_value, 16)]
elif test_value_type == 'short':
body_list = [short(int(test_value, 16))]
elif test_value_type == 'string':
@@ -264,7 +264,7 @@
def _create_jms_textmessage(self, test_value_text):
"""Create a JMS text message"""
return Message(id=(self.sent+1),
- body=unicode(test_value_text),
+ body=_compat._unicode(test_value_text),
annotations=create_annotation('JMS_TEXTMESSAGE_TYPE'))
@@ -275,13 +275,13 @@
# 2: Queue name
# 3: JMS message type
# 4: JSON Test parameters containing 3 maps: [testValueMap, testHeadersMap, testPropertiesMap]
-#print '#### sys.argv=%s' % sys.argv
-#print '>>> test_values=%s' % loads(sys.argv[4])
+#print('#### sys.argv=%s' % sys.argv)
+#print('>>> test_values=%s' % loads(sys.argv[4]))
try:
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:
- print 'jms-sender-shim EXCEPTION:', exc
- print format_exc()
+ print('jms-sender-shim EXCEPTION:', exc)
+ print(format_exc())
diff --git a/src/python/qpid_interop_test/amqp_large_content_test.py b/src/python/qpid_interop_test/amqp_large_content_test.py
index 3b0688f..1d215c4 100755
--- a/src/python/qpid_interop_test/amqp_large_content_test.py
+++ b/src/python/qpid_interop_test/amqp_large_content_test.py
@@ -49,14 +49,25 @@
"""
TYPE_MAP = {
- # List of sizes in Mb
- 'binary': [1, 10, 100],
- 'string': [1, 10, 100],
- 'symbol': [1, 10, 100],
+ # List of sizes in Mb (1024*1024 bytes)
+ # TODO: Until the issue of SLOW Proton performance for large messages is solved, the 100MB tests are
+ # disabled.
+ 'binary': [1, 10, #100],
+ ],
+ 'string': [1, 10, #100],
+ ],
+ 'symbol': [1, 10, #100],
+ ],
# Tuple of two elements: (tot size of list/map in MB, List of no elements in list)
# The num elements lists are powers of 2 so that they divide evenly into the size in MB (1024 * 1024 bytes)
- 'list': [[1, [1, 16, 256, 4096]], [10, [1, 16, 256, 4096]], [100, [1, 16, 256, 4096]]],
- 'map': [[1, [1, 16, 256, 4096]], [10, [1, 16, 256, 4096]], [100, [1, 16, 256, 4096]]],
+ 'list': [[1, [1, 16, 256, 4096]],
+ [10, [1, 16, 256, 4096]],
+ #[100, [1, 16, 256, 4096]]
+ ],
+ 'map': [[1, [1, 16, 256, 4096]],
+ [10, [1, 16, 256, 4096]],
+ #[100, [1, 16, 256, 4096]]],
+ ],
#'array': [[1, [1, 16, 256, 4096]], [10, [1, 16, 256, 4096]], [100, [1, 16, 256, 4096]]]
}
@@ -223,8 +234,11 @@
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.ProtonPython2Shim.NAME: \
+ qpid_interop_test.shims.ProtonPython2Shim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM),
+ # TODO: Enable the Python3 shim when Proton can build both Python2 and Python3 bindings
+ #qpid_interop_test.shims.ProtonPython3Shim.NAME: \
+ # qpid_interop_test.shims.ProtonPython3Shim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM),
}
# Add shims that need detection during installation only if the necessary bits are present
# AMQP DotNetLite client
diff --git a/src/python/qpid_interop_test/amqp_types_test.py b/src/python/qpid_interop_test/amqp_types_test.py
index 9971c2c..ed027ca 100755
--- a/src/python/qpid_interop_test/amqp_types_test.py
+++ b/src/python/qpid_interop_test/amqp_types_test.py
@@ -460,8 +460,11 @@
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.ProtonPython2Shim.NAME: \
+ qpid_interop_test.shims.ProtonPython2Shim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM),
+ # TODO: Enable the Python3 shim when Proton can build both Python2 and Python3 bindings
+ #qpid_interop_test.shims.ProtonPython3Shim.NAME: \
+ # qpid_interop_test.shims.ProtonPython3Shim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM),
}
# Add shims that need detection during installation only if the necessary bits are present
# Rhea Javascript client
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 61a2ed2..baf0f64 100755
--- a/src/python/qpid_interop_test/jms_hdrs_props_test.py
+++ b/src/python/qpid_interop_test/jms_hdrs_props_test.py
@@ -701,8 +701,11 @@
# 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.ProtonPython2Shim.NAME: \
+ qpid_interop_test.shims.ProtonPython2Shim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM),
+ # TODO: Enable the Python3 shim when Proton can build both Python2 and Python3 bindings
+ #qpid_interop_test.shims.ProtonPython3Shim.NAME: \
+ # qpid_interop_test.shims.ProtonPython3Shim(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),
}
diff --git a/src/python/qpid_interop_test/jms_messages_test.py b/src/python/qpid_interop_test/jms_messages_test.py
index 8fd6b48..29ab3ff 100755
--- a/src/python/qpid_interop_test/jms_messages_test.py
+++ b/src/python/qpid_interop_test/jms_messages_test.py
@@ -354,8 +354,11 @@
# 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.ProtonPython2Shim.NAME: \
+ qpid_interop_test.shims.ProtonPython2Shim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM),
+ # TODO: Enable the Python3 shim when Proton can build both Python2 and Python3 bindings
+ #qpid_interop_test.shims.ProtonPython3Shim.NAME: \
+ # qpid_interop_test.shims.ProtonPython3Shim(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),
}
diff --git a/src/python/qpid_interop_test/shims.py b/src/python/qpid_interop_test/shims.py
index 52716bb..ecc4610 100644
--- a/src/python/qpid_interop_test/shims.py
+++ b/src/python/qpid_interop_test/shims.py
@@ -178,13 +178,23 @@
receiver.daemon = True
return receiver
-class ProtonPythonShim(Shim):
+
+class ProtonPython2Shim(Shim):
"""Shim for qpid-proton Python client"""
- NAME = 'ProtonPython'
+ NAME = 'ProtonPython2'
def __init__(self, sender_shim, receiver_shim):
- super(ProtonPythonShim, self).__init__(sender_shim, receiver_shim)
- self.send_params = [self.sender_shim]
- self.receive_params = [self.receiver_shim]
+ super(ProtonPython2Shim, self).__init__(sender_shim, receiver_shim)
+ self.send_params = ['python', self.sender_shim]
+ self.receive_params = ['python', self.receiver_shim]
+
+
+class ProtonPython3Shim(Shim):
+ """Shim for qpid-proton Python client"""
+ NAME = 'ProtonPython3'
+ def __init__(self, sender_shim, receiver_shim):
+ super(ProtonPython3Shim, self).__init__(sender_shim, receiver_shim)
+ self.send_params = ['python3', self.sender_shim]
+ self.receive_params = ['python3', self.receiver_shim]
class ProtonCppShim(Shim):