Merge "Wait on greenthreads before unmocking http_connect"

This commit is contained in:
Jenkins
2016-03-15 00:17:01 +00:00
committed by Gerrit Code Review

View File

@@ -735,8 +735,9 @@ class TestObjectController(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT'}, environ={'REQUEST_METHOD': 'PUT'},
headers=put_headers, body='test') headers=put_headers, body='test')
with mock.patch('swift.obj.server.http_connect', fake_http_connect): with mock.patch('swift.obj.server.http_connect', fake_http_connect), \
with mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''): mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''), \
fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -778,8 +779,9 @@ class TestObjectController(unittest.TestCase):
environ={'REQUEST_METHOD': 'POST'}, environ={'REQUEST_METHOD': 'POST'},
headers=post_headers) headers=post_headers)
with mock.patch('swift.obj.server.http_connect', fake_http_connect): with mock.patch('swift.obj.server.http_connect', fake_http_connect), \
with mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''): mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''), \
fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 202) self.assertEqual(resp.status_int, 202)
@@ -842,10 +844,10 @@ class TestObjectController(unittest.TestCase):
os.listdir(os.path.join( os.listdir(os.path.join(
device_dir, diskfile.get_async_dir(policy)))) device_dir, diskfile.get_async_dir(policy))))
def test_PUT_then_POST_async_updates_with_repl_policy(self): def test_PUT_then_POST_async_pendings_with_repl_policy(self):
self._test_PUT_then_POST_async_pendings(POLICIES[0]) self._test_PUT_then_POST_async_pendings(POLICIES[0])
def test_PUT_then_POST_async_updates_with_EC_policy(self): def test_PUT_then_POST_async_pendings_with_EC_policy(self):
self._test_PUT_then_POST_async_pendings( self._test_PUT_then_POST_async_pendings(
POLICIES[1], update_etag='override_etag') POLICIES[1], update_etag='override_etag')
@@ -1970,9 +1972,9 @@ class TestObjectController(unittest.TestCase):
'X-Container-Timestamp': '1', 'X-Container-Timestamp': '1',
'Content-Type': 'application/new1', 'Content-Type': 'application/new1',
'Content-Length': '0'}) 'Content-Length': '0'})
with fake_spawn(), mock.patch.object( with mock.patch.object(
object_server, 'http_connect', object_server, 'http_connect', mock_http_connect(201)):
mock_http_connect(201)): with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
timestamp = normalize_timestamp(time()) timestamp = normalize_timestamp(time())
@@ -1986,9 +1988,9 @@ class TestObjectController(unittest.TestCase):
'X-Container-Timestamp': '1', 'X-Container-Timestamp': '1',
'Content-Type': 'application/new1', 'Content-Type': 'application/new1',
'Content-Length': '0'}) 'Content-Length': '0'})
with fake_spawn(), mock.patch.object( with mock.patch.object(
object_server, 'http_connect', object_server, 'http_connect', mock_http_connect(500)):
mock_http_connect(500)): with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
timestamp = normalize_timestamp(time()) timestamp = normalize_timestamp(time())
@@ -2002,9 +2004,10 @@ class TestObjectController(unittest.TestCase):
'X-Container-Timestamp': '1', 'X-Container-Timestamp': '1',
'Content-Type': 'application/new1', 'Content-Type': 'application/new1',
'Content-Length': '0'}) 'Content-Length': '0'})
with fake_spawn(), mock.patch.object( with mock.patch.object(
object_server, 'http_connect', object_server, 'http_connect',
mock_http_connect(500, with_exc=True)): mock_http_connect(500, with_exc=True)):
with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -3204,8 +3207,8 @@ class TestObjectController(unittest.TestCase):
'X-Container-Device': 'sda1', 'X-Container-Device': 'sda1',
'X-Container-Partition': 'p', 'X-Container-Partition': 'p',
'Content-Type': 'text/plain'}) 'Content-Type': 'text/plain'})
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -3243,8 +3246,8 @@ class TestObjectController(unittest.TestCase):
'X-Container-Device': 'sda1', 'X-Container-Device': 'sda1',
'X-Container-Partition': 'p', 'X-Container-Partition': 'p',
'Content-Type': 'text/html'}) 'Content-Type': 'text/html'})
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -3281,8 +3284,8 @@ class TestObjectController(unittest.TestCase):
'X-Container-Device': 'sda1', 'X-Container-Device': 'sda1',
'X-Container-Partition': 'p', 'X-Container-Partition': 'p',
'Content-Type': 'text/enriched'}) 'Content-Type': 'text/enriched'})
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -3319,8 +3322,8 @@ class TestObjectController(unittest.TestCase):
'X-Container-Host': '10.0.0.1:8080', 'X-Container-Host': '10.0.0.1:8080',
'X-Container-Device': 'sda1', 'X-Container-Device': 'sda1',
'X-Container-Partition': 'p'}) 'X-Container-Partition': 'p'})
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 204) self.assertEqual(resp.status_int, 204)
@@ -3350,8 +3353,8 @@ class TestObjectController(unittest.TestCase):
'X-Container-Host': '10.0.0.1:8080', 'X-Container-Host': '10.0.0.1:8080',
'X-Container-Device': 'sda1', 'X-Container-Device': 'sda1',
'X-Container-Partition': 'p'}) 'X-Container-Partition': 'p'})
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 404) self.assertEqual(resp.status_int, 404)
@@ -3819,8 +3822,9 @@ class TestObjectController(unittest.TestCase):
'X-Delete-At-Partition': '6237', 'X-Delete-At-Partition': '6237',
'X-Delete-At-Device': 'sdp,sdq'}) 'X-Delete-At-Device': 'sdp,sdq'})
with fake_spawn(), mock.patch.object( with mock.patch.object(
object_server, 'http_connect', fake_http_connect): object_server, 'http_connect', fake_http_connect):
with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -3931,8 +3935,9 @@ class TestObjectController(unittest.TestCase):
'X-Container-Host': '1.2.3.4:5, 6.7.8.9:10', 'X-Container-Host': '1.2.3.4:5, 6.7.8.9:10',
'X-Container-Device': 'sdb1, sdf1'}) 'X-Container-Device': 'sdb1, sdf1'})
with fake_spawn(), mock.patch.object( with mock.patch.object(
object_server, 'http_connect', fake_http_connect): object_server, 'http_connect', fake_http_connect):
with fake_spawn():
req.get_response(self.object_controller) req.get_response(self.object_controller)
http_connect_args.sort(key=operator.itemgetter('ipaddr')) http_connect_args.sort(key=operator.itemgetter('ipaddr'))
@@ -4008,8 +4013,9 @@ class TestObjectController(unittest.TestCase):
headers['X-Object-Sysmeta-Ec-Frag-Index'] = '2' headers['X-Object-Sysmeta-Ec-Frag-Index'] = '2'
req = Request.blank( req = Request.blank(
'/sda1/p/a/c/o', method='PUT', body='', headers=headers) '/sda1/p/a/c/o', method='PUT', body='', headers=headers)
with fake_spawn(), mocked_http_conn( with mocked_http_conn(
500, 500, give_connect=capture_updates) as fake_conn: 500, 500, give_connect=capture_updates) as fake_conn:
with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -4244,8 +4250,8 @@ class TestObjectController(unittest.TestCase):
'X-Container-Partition': 'cpartition', 'X-Container-Partition': 'cpartition',
'X-Container-Device': 'cdevice', 'X-Container-Device': 'cdevice',
'Content-Type': 'text/plain'}, body='') 'Content-Type': 'text/plain'}, body='')
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -4285,8 +4291,8 @@ class TestObjectController(unittest.TestCase):
} }
req = Request.blank('/sda1/0/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, req = Request.blank('/sda1/0/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers=headers, body='') headers=headers, body='')
with fake_spawn(), mocked_http_conn( with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
200, give_connect=capture_updates) as fake_conn: with fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)
@@ -4326,7 +4332,7 @@ class TestObjectController(unittest.TestCase):
given_args[:] = args given_args[:] = args
diskfile_mgr = self.object_controller._diskfile_router[policy] diskfile_mgr = self.object_controller._diskfile_router[policy]
diskfile_mgr.pickle_async_update = fake_pickle_async_update diskfile_mgr.pickle_async_update = fake_pickle_async_update
with fake_spawn(), mocked_http_conn(500) as fake_conn: with mocked_http_conn(500) as fake_conn, fake_spawn():
resp = req.get_response(self.object_controller) resp = req.get_response(self.object_controller)
self.assertRaises(StopIteration, fake_conn.code_iter.next) self.assertRaises(StopIteration, fake_conn.code_iter.next)
self.assertEqual(resp.status_int, 201) self.assertEqual(resp.status_int, 201)