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')
|
self.assertEqual(str(exceptions.ReplicationException('test')), 'test')
|
||||||
|
|
||||||
def test_replication_lock_timeout(self):
|
def test_replication_lock_timeout(self):
|
||||||
exc = exceptions.ReplicationLockTimeout(15, 'test')
|
with exceptions.ReplicationLockTimeout(15, 'test') as exc:
|
||||||
try:
|
|
||||||
self.assertTrue(isinstance(exc, exceptions.MessageTimeout))
|
self.assertTrue(isinstance(exc, exceptions.MessageTimeout))
|
||||||
finally:
|
|
||||||
exc.cancel()
|
|
||||||
|
|
||||||
def test_client_exception(self):
|
def test_client_exception(self):
|
||||||
strerror = 'test: HTTP://random:888/randompath?foo=1 666 reason: ' \
|
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)
|
self.assertIn('my error message', log_msg)
|
||||||
|
|
||||||
# test eventlet.Timeout
|
# test eventlet.Timeout
|
||||||
connection_timeout = ConnectionTimeout(42, 'my error message')
|
with ConnectionTimeout(42, 'my error message') \
|
||||||
log_exception(connection_timeout)
|
as connection_timeout:
|
||||||
log_msg = strip_value(sio)
|
log_exception(connection_timeout)
|
||||||
self.assertNotIn('Traceback', log_msg)
|
log_msg = strip_value(sio)
|
||||||
self.assertTrue('ConnectionTimeout' in log_msg)
|
self.assertNotIn('Traceback', log_msg)
|
||||||
self.assertTrue('(42s)' in log_msg)
|
self.assertTrue('ConnectionTimeout' in log_msg)
|
||||||
self.assertNotIn('my error message', log_msg)
|
self.assertTrue('(42s)' in log_msg)
|
||||||
connection_timeout.cancel()
|
self.assertNotIn('my error message', log_msg)
|
||||||
|
|
||||||
message_timeout = MessageTimeout(42, 'my error message')
|
with MessageTimeout(42, 'my error message') as message_timeout:
|
||||||
log_exception(message_timeout)
|
log_exception(message_timeout)
|
||||||
log_msg = strip_value(sio)
|
log_msg = strip_value(sio)
|
||||||
self.assertNotIn('Traceback', log_msg)
|
self.assertNotIn('Traceback', log_msg)
|
||||||
self.assertTrue('MessageTimeout' in log_msg)
|
self.assertTrue('MessageTimeout' in log_msg)
|
||||||
self.assertTrue('(42s)' in log_msg)
|
self.assertTrue('(42s)' in log_msg)
|
||||||
self.assertTrue('my error message' in log_msg)
|
self.assertTrue('my error message' in log_msg)
|
||||||
message_timeout.cancel()
|
|
||||||
|
|
||||||
# test BadStatusLine
|
# test BadStatusLine
|
||||||
log_exception(http_client.BadStatusLine(''))
|
log_exception(http_client.BadStatusLine(''))
|
||||||
|
@ -618,11 +618,9 @@ class TestObjectUpdater(unittest.TestCase):
|
|||||||
|
|
||||||
# final update has Timeout
|
# final update has Timeout
|
||||||
ou.logger.clear()
|
ou.logger.clear()
|
||||||
mock_connect = mock.MagicMock()
|
with Timeout(99) as exc, \
|
||||||
mock_connect.getresponse = mock.MagicMock(side_effect=Timeout(99))
|
mock.patch('swift.obj.updater.http_connect') as mock_connect:
|
||||||
|
mock_connect.return_value.getresponse.side_effect = exc
|
||||||
with mock.patch('swift.obj.updater.http_connect',
|
|
||||||
return_value=mock_connect):
|
|
||||||
ou.run_once()
|
ou.run_once()
|
||||||
self.assertTrue(os.path.exists(op_path))
|
self.assertTrue(os.path.exists(op_path))
|
||||||
self.assertEqual(ou.logger.get_increment_counts(),
|
self.assertEqual(ou.logger.get_increment_counts(),
|
||||||
@ -639,12 +637,9 @@ class TestObjectUpdater(unittest.TestCase):
|
|||||||
|
|
||||||
# final update has ConnectionTimeout
|
# final update has ConnectionTimeout
|
||||||
ou.logger.clear()
|
ou.logger.clear()
|
||||||
mock_connect = mock.MagicMock()
|
with ConnectionTimeout(9) as exc, \
|
||||||
mock_connect.getresponse = mock.MagicMock(
|
mock.patch('swift.obj.updater.http_connect') as mock_connect:
|
||||||
side_effect=ConnectionTimeout(9))
|
mock_connect.return_value.getresponse.side_effect = exc
|
||||||
|
|
||||||
with mock.patch('swift.obj.updater.http_connect',
|
|
||||||
return_value=mock_connect):
|
|
||||||
ou.run_once()
|
ou.run_once()
|
||||||
self.assertTrue(os.path.exists(op_path))
|
self.assertTrue(os.path.exists(op_path))
|
||||||
self.assertEqual(ou.logger.get_increment_counts(),
|
self.assertEqual(ou.logger.get_increment_counts(),
|
||||||
|
Loading…
Reference in New Issue
Block a user