Skip to content

Commit aa7c328

Browse files
d-w-moorealanking
authored andcommitted
[#3][#562] skip issue 562 (leaking connections) test for Python2
Silence Python2 string-type mismatches. These also caused some tests to fail if they were logging to io.BytesIO objects.
1 parent 86d16df commit aa7c328

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

irods/manager/data_object_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def make_FileOpenRequest(**extra_opts):
430430
returned_values['session'] = directed_sess
431431
conn.release()
432432
conn = directed_sess.pool.get_connection()
433-
logger.debug('redirect_to_host = %s', redirected_host)
433+
logger.debug(u'redirect_to_host = %s', redirected_host)
434434

435435
# Restore RESC HIER for DATA_OBJ_OPEN call
436436
if requested_hierarchy is not None:

irods/parallel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def bytes_range_for_thread( i, num_threads, total_bytes, chunk ):
340340

341341
ranges = [bytes_range_for_thread(i, num_threads, total_size, bytes_per_thread) for i in range(num_threads)]
342342

343-
logger.info("num_threads = %s ; bytes_per_thread = %s", num_threads, bytes_per_thread)
343+
logger.info(u"num_threads = %s ; bytes_per_thread = %s", num_threads, bytes_per_thread)
344344

345345
_queueLength = extra_options.get('_queueLength',0)
346346
if _queueLength > 0:
@@ -364,7 +364,7 @@ def bytes_range_for_thread( i, num_threads, total_bytes, chunk ):
364364
kw.RESC_HIER_STR_KW: hier_str,
365365
kw.REPLICA_TOKEN_KW: replica_token })
366366
mgr.add_io( Io )
367-
logger.debug('target_host = %s', Io.raw.session.pool.account.host)
367+
logger.debug(u'target_host = %s', Io.raw.session.pool.account.host)
368368
if File is None: File = gen_file_handle()
369369
futures.append(executor.submit( _io_part, Io, byte_range, File, Operation, mgr, str(counter), queueObject))
370370
counter += 1

irods/test/data_obj_test.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ def tearDown(self):
107107
self.sess.cleanup()
108108

109109
@staticmethod
110-
def In_Memory_Stream():
111-
return io.BytesIO() if sys.version_info < (3,) else io.StringIO()
110+
def In_Memory_Stream(always_unicode = False):
111+
return io.StringIO() if sys.version_info >= (3,) or always_unicode \
112+
else io.BytesIO()
112113

113114

114115
@contextlib.contextmanager
@@ -318,9 +319,9 @@ def test_put_get_parallel_autoswitch_A__235(self):
318319
options = { kw.DEST_RESC_NAME_KW:Root,
319320
kw.RESC_NAME_KW:Root }
320321

321-
PUT_LOG = self.In_Memory_Stream()
322-
GET_LOG = self.In_Memory_Stream()
323-
NumThreadsRegex = re.compile('^num_threads\s*=\s*(\d+)',re.MULTILINE)
322+
PUT_LOG = self.In_Memory_Stream(always_unicode = True)
323+
GET_LOG = self.In_Memory_Stream(always_unicode = True)
324+
NumThreadsRegex = re.compile(u'^num_threads\s*=\s*(\d+)',re.MULTILINE)
324325

325326
try:
326327
logger = logging.getLogger('irods.parallel')
@@ -830,7 +831,7 @@ def do_test_redirect_in_data_object_put_and_get__issue_452(self, content, data_c
830831
data_ctx['initialize']()
831832
sess = data_ctx['session']
832833
remote_name = data_ctx['path']
833-
PUT_LOG = self.In_Memory_Stream()
834+
PUT_LOG = self.In_Memory_Stream(always_unicode = True)
834835
with helpers.enableLogging(logging.getLogger('irods.manager.data_object_manager'),
835836
logging.StreamHandler, (PUT_LOG,), level_ = logging.DEBUG),\
836837
helpers.enableLogging(logging.getLogger('irods.parallel'),
@@ -839,11 +840,11 @@ def do_test_redirect_in_data_object_put_and_get__issue_452(self, content, data_c
839840
def srch(BUF):
840841
nthr = 0
841842
search_text = BUF.getvalue()
842-
find_iterator = itertools.chain( re.finditer('redirect_to_host = (\S+)', search_text),
843-
re.finditer('target_host = (\S+)', search_text) )
843+
find_iterator = itertools.chain( re.finditer(u'redirect_to_host = (\S+)', search_text),
844+
re.finditer(u'target_host = (\S+)', search_text) )
844845
for match in find_iterator:
845846
nthr += 1
846-
self.assertEqual(match.group(1), 'localhost')
847+
self.assertEqual(match.group(1), u'localhost')
847848
occur_threshold = (1 if len(content) <= 32*MEBI else 2)
848849
self.assertGreaterEqual(nthr, occur_threshold)
849850
srch(PUT_LOG)
@@ -858,7 +859,7 @@ def srch(BUF):
858859
data_ctx_get = next(generator)
859860
data_ctx_get['initialize']()
860861
sess = data_ctx_get['session']
861-
GET_LOG = self.In_Memory_Stream()
862+
GET_LOG = self.In_Memory_Stream(always_unicode = True)
862863
with helpers.enableLogging(logging.getLogger('irods.manager.data_object_manager'),
863864
logging.StreamHandler, (GET_LOG,), level_ = logging.DEBUG),\
864865
helpers.enableLogging(logging.getLogger('irods.parallel'),
@@ -2097,6 +2098,7 @@ def test_touch_operation_does_not_work_when_given_a_collection__525(self):
20972098
with self.assertRaises(ex.InvalidInputArgument):
20982099
user_session.data_objects.touch(home_collection_path)
20992100

2101+
@unittest.skipIf(six.PY2, "Python2 won't destruct an out-of-scope iRODSSession due to lazy GC ref-cycle detection.")
21002102
def test_client_redirect_lets_go_of_connections__issue_562(self):
21012103
self._skip_unless_connected_to_local_computer_by_other_than_localhost_synonym()
21022104
# Force data object connections to redirect by enforcing a non-equivalent hostname for their resource

0 commit comments

Comments
 (0)