Merge "Wait on greenthreads before unmocking http_connect"
This commit is contained in:
commit
e50ab92aaa
@ -735,8 +735,9 @@ class TestObjectController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers=put_headers, body='test')
|
||||
|
||||
with mock.patch('swift.obj.server.http_connect', fake_http_connect):
|
||||
with mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''):
|
||||
with mock.patch('swift.obj.server.http_connect', fake_http_connect), \
|
||||
mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''), \
|
||||
fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
@ -778,8 +779,9 @@ class TestObjectController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'POST'},
|
||||
headers=post_headers)
|
||||
|
||||
with mock.patch('swift.obj.server.http_connect', fake_http_connect):
|
||||
with mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''):
|
||||
with mock.patch('swift.obj.server.http_connect', fake_http_connect), \
|
||||
mock.patch('swift.common.utils.HASH_PATH_PREFIX', ''), \
|
||||
fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
@ -842,10 +844,10 @@ class TestObjectController(unittest.TestCase):
|
||||
os.listdir(os.path.join(
|
||||
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])
|
||||
|
||||
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(
|
||||
POLICIES[1], update_etag='override_etag')
|
||||
|
||||
@ -1970,9 +1972,9 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Timestamp': '1',
|
||||
'Content-Type': 'application/new1',
|
||||
'Content-Length': '0'})
|
||||
with fake_spawn(), mock.patch.object(
|
||||
object_server, 'http_connect',
|
||||
mock_http_connect(201)):
|
||||
with mock.patch.object(
|
||||
object_server, 'http_connect', mock_http_connect(201)):
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
timestamp = normalize_timestamp(time())
|
||||
@ -1986,9 +1988,9 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Timestamp': '1',
|
||||
'Content-Type': 'application/new1',
|
||||
'Content-Length': '0'})
|
||||
with fake_spawn(), mock.patch.object(
|
||||
object_server, 'http_connect',
|
||||
mock_http_connect(500)):
|
||||
with mock.patch.object(
|
||||
object_server, 'http_connect', mock_http_connect(500)):
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
timestamp = normalize_timestamp(time())
|
||||
@ -2002,9 +2004,10 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Timestamp': '1',
|
||||
'Content-Type': 'application/new1',
|
||||
'Content-Length': '0'})
|
||||
with fake_spawn(), mock.patch.object(
|
||||
with mock.patch.object(
|
||||
object_server, 'http_connect',
|
||||
mock_http_connect(500, with_exc=True)):
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
|
||||
@ -3204,8 +3207,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Device': 'sda1',
|
||||
'X-Container-Partition': 'p',
|
||||
'Content-Type': 'text/plain'})
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
@ -3243,8 +3246,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Device': 'sda1',
|
||||
'X-Container-Partition': 'p',
|
||||
'Content-Type': 'text/html'})
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
@ -3281,8 +3284,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Device': 'sda1',
|
||||
'X-Container-Partition': 'p',
|
||||
'Content-Type': 'text/enriched'})
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
@ -3319,8 +3322,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Host': '10.0.0.1:8080',
|
||||
'X-Container-Device': 'sda1',
|
||||
'X-Container-Partition': 'p'})
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
@ -3350,8 +3353,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Host': '10.0.0.1:8080',
|
||||
'X-Container-Device': 'sda1',
|
||||
'X-Container-Partition': 'p'})
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
@ -3819,8 +3822,9 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Delete-At-Partition': '6237',
|
||||
'X-Delete-At-Device': 'sdp,sdq'})
|
||||
|
||||
with fake_spawn(), mock.patch.object(
|
||||
with mock.patch.object(
|
||||
object_server, 'http_connect', fake_http_connect):
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
|
||||
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-Device': 'sdb1, sdf1'})
|
||||
|
||||
with fake_spawn(), mock.patch.object(
|
||||
with mock.patch.object(
|
||||
object_server, 'http_connect', fake_http_connect):
|
||||
with fake_spawn():
|
||||
req.get_response(self.object_controller)
|
||||
|
||||
http_connect_args.sort(key=operator.itemgetter('ipaddr'))
|
||||
@ -4008,8 +4013,9 @@ class TestObjectController(unittest.TestCase):
|
||||
headers['X-Object-Sysmeta-Ec-Frag-Index'] = '2'
|
||||
req = Request.blank(
|
||||
'/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:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
@ -4244,8 +4250,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'X-Container-Partition': 'cpartition',
|
||||
'X-Container-Device': 'cdevice',
|
||||
'Content-Type': 'text/plain'}, body='')
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
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'},
|
||||
headers=headers, body='')
|
||||
with fake_spawn(), mocked_http_conn(
|
||||
200, give_connect=capture_updates) as fake_conn:
|
||||
with mocked_http_conn(200, give_connect=capture_updates) as fake_conn:
|
||||
with fake_spawn():
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
@ -4326,7 +4332,7 @@ class TestObjectController(unittest.TestCase):
|
||||
given_args[:] = args
|
||||
diskfile_mgr = self.object_controller._diskfile_router[policy]
|
||||
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)
|
||||
self.assertRaises(StopIteration, fake_conn.code_iter.next)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
|
Loading…
x
Reference in New Issue
Block a user