Merge "tests: Clean up some dangling timeouts"
This commit is contained in:
commit
3429a11c39
@ -26,11 +26,8 @@ class TestExceptions(unittest.TestCase):
|
||||
self.assertEqual(str(exceptions.ReplicationException('test')), 'test')
|
||||
|
||||
def test_replication_lock_timeout(self):
|
||||
exc = exceptions.ReplicationLockTimeout(15, 'test')
|
||||
try:
|
||||
with exceptions.ReplicationLockTimeout(15, 'test') as exc:
|
||||
self.assertTrue(isinstance(exc, exceptions.MessageTimeout))
|
||||
finally:
|
||||
exc.cancel()
|
||||
|
||||
def test_client_exception(self):
|
||||
strerror = 'test: HTTP://random:888/randompath?foo=1 666 reason: ' \
|
||||
|
@ -1965,23 +1965,22 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertIn('my error message', log_msg)
|
||||
|
||||
# test eventlet.Timeout
|
||||
connection_timeout = ConnectionTimeout(42, 'my error message')
|
||||
log_exception(connection_timeout)
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('ConnectionTimeout' in log_msg)
|
||||
self.assertTrue('(42s)' in log_msg)
|
||||
self.assertNotIn('my error message', log_msg)
|
||||
connection_timeout.cancel()
|
||||
with ConnectionTimeout(42, 'my error message') \
|
||||
as connection_timeout:
|
||||
log_exception(connection_timeout)
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('ConnectionTimeout' in log_msg)
|
||||
self.assertTrue('(42s)' in log_msg)
|
||||
self.assertNotIn('my error message', log_msg)
|
||||
|
||||
message_timeout = MessageTimeout(42, 'my error message')
|
||||
log_exception(message_timeout)
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('MessageTimeout' in log_msg)
|
||||
self.assertTrue('(42s)' in log_msg)
|
||||
self.assertTrue('my error message' in log_msg)
|
||||
message_timeout.cancel()
|
||||
with MessageTimeout(42, 'my error message') as message_timeout:
|
||||
log_exception(message_timeout)
|
||||
log_msg = strip_value(sio)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('MessageTimeout' in log_msg)
|
||||
self.assertTrue('(42s)' in log_msg)
|
||||
self.assertTrue('my error message' in log_msg)
|
||||
|
||||
# test BadStatusLine
|
||||
log_exception(http_client.BadStatusLine(''))
|
||||
|
@ -618,11 +618,9 @@ class TestObjectUpdater(unittest.TestCase):
|
||||
|
||||
# final update has Timeout
|
||||
ou.logger.clear()
|
||||
mock_connect = mock.MagicMock()
|
||||
mock_connect.getresponse = mock.MagicMock(side_effect=Timeout(99))
|
||||
|
||||
with mock.patch('swift.obj.updater.http_connect',
|
||||
return_value=mock_connect):
|
||||
with Timeout(99) as exc, \
|
||||
mock.patch('swift.obj.updater.http_connect') as mock_connect:
|
||||
mock_connect.return_value.getresponse.side_effect = exc
|
||||
ou.run_once()
|
||||
self.assertTrue(os.path.exists(op_path))
|
||||
self.assertEqual(ou.logger.get_increment_counts(),
|
||||
@ -639,12 +637,9 @@ class TestObjectUpdater(unittest.TestCase):
|
||||
|
||||
# final update has ConnectionTimeout
|
||||
ou.logger.clear()
|
||||
mock_connect = mock.MagicMock()
|
||||
mock_connect.getresponse = mock.MagicMock(
|
||||
side_effect=ConnectionTimeout(9))
|
||||
|
||||
with mock.patch('swift.obj.updater.http_connect',
|
||||
return_value=mock_connect):
|
||||
with ConnectionTimeout(9) as exc, \
|
||||
mock.patch('swift.obj.updater.http_connect') as mock_connect:
|
||||
mock_connect.return_value.getresponse.side_effect = exc
|
||||
ou.run_once()
|
||||
self.assertTrue(os.path.exists(op_path))
|
||||
self.assertEqual(ou.logger.get_increment_counts(),
|
||||
|
Loading…
Reference in New Issue
Block a user