Merge "Fix object server tests to include content-type headers"
This commit is contained in:
commit
aebcc5898c
@ -6204,7 +6204,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
suffix = pickle.loads(resp.body).keys()[0]
|
suffix = pickle.loads(resp.body).keys()[0]
|
||||||
self.assertEqual(suffix, os.path.basename(
|
self.assertEqual(suffix, os.path.basename(
|
||||||
os.path.dirname(objfile._datadir)))
|
os.path.dirname(objfile._datadir)))
|
||||||
# tombsone still exists
|
# tombstone still exists
|
||||||
self.assertTrue(os.path.exists(tombstone_file))
|
self.assertTrue(os.path.exists(tombstone_file))
|
||||||
|
|
||||||
# after reclaim REPLICATE will rehash
|
# after reclaim REPLICATE will rehash
|
||||||
@ -6219,7 +6219,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
resp = replicate_request.get_response(self.object_controller)
|
resp = replicate_request.get_response(self.object_controller)
|
||||||
self.assertEqual(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
self.assertEqual({}, pickle.loads(resp.body))
|
self.assertEqual({}, pickle.loads(resp.body))
|
||||||
# and tombsone is reaped!
|
# and tombstone is reaped!
|
||||||
self.assertFalse(os.path.exists(tombstone_file))
|
self.assertFalse(os.path.exists(tombstone_file))
|
||||||
|
|
||||||
# N.B. with a small reclaim age like this - if proxy clocks get far
|
# N.B. with a small reclaim age like this - if proxy clocks get far
|
||||||
@ -6859,6 +6859,7 @@ class TestObjectServer(unittest.TestCase):
|
|||||||
headers = {
|
headers = {
|
||||||
'Expect': '100-continue',
|
'Expect': '100-continue',
|
||||||
'Content-Length': len(test_body),
|
'Content-Length': len(test_body),
|
||||||
|
'Content-Type': 'application/test',
|
||||||
'X-Timestamp': utils.Timestamp(time()).internal,
|
'X-Timestamp': utils.Timestamp(time()).internal,
|
||||||
}
|
}
|
||||||
conn = bufferedhttp.http_connect('127.0.0.1', self.port, 'sda1', '0',
|
conn = bufferedhttp.http_connect('127.0.0.1', self.port, 'sda1', '0',
|
||||||
@ -6876,6 +6877,7 @@ class TestObjectServer(unittest.TestCase):
|
|||||||
headers = {
|
headers = {
|
||||||
'Expect': '100-continue',
|
'Expect': '100-continue',
|
||||||
'Content-Length': len(test_body),
|
'Content-Length': len(test_body),
|
||||||
|
'Content-Type': 'application/test',
|
||||||
'X-Timestamp': utils.Timestamp(time()).internal,
|
'X-Timestamp': utils.Timestamp(time()).internal,
|
||||||
'X-Backend-Obj-Metadata-Footer': 'yes',
|
'X-Backend-Obj-Metadata-Footer': 'yes',
|
||||||
'X-Backend-Obj-Multipart-Mime-Boundary': 'boundary123',
|
'X-Backend-Obj-Multipart-Mime-Boundary': 'boundary123',
|
||||||
@ -6894,6 +6896,7 @@ class TestObjectServer(unittest.TestCase):
|
|||||||
headers = {
|
headers = {
|
||||||
'Expect': '100-continue',
|
'Expect': '100-continue',
|
||||||
'Content-Length': len(test_body),
|
'Content-Length': len(test_body),
|
||||||
|
'Content-Type': 'application/test',
|
||||||
'X-Timestamp': put_timestamp.internal,
|
'X-Timestamp': put_timestamp.internal,
|
||||||
}
|
}
|
||||||
conn = bufferedhttp.http_connect('127.0.0.1', self.port, 'sda1', '0',
|
conn = bufferedhttp.http_connect('127.0.0.1', self.port, 'sda1', '0',
|
||||||
@ -7526,7 +7529,8 @@ class TestZeroCopy(unittest.TestCase):
|
|||||||
url_path = '/sda1/2100/a/c/o'
|
url_path = '/sda1/2100/a/c/o'
|
||||||
|
|
||||||
self.http_conn.request('PUT', url_path, 'obj contents',
|
self.http_conn.request('PUT', url_path, 'obj contents',
|
||||||
{'X-Timestamp': '127082564.24709'})
|
{'X-Timestamp': '127082564.24709',
|
||||||
|
'Content-Type': 'application/test'})
|
||||||
response = self.http_conn.getresponse()
|
response = self.http_conn.getresponse()
|
||||||
self.assertEqual(response.status, 201)
|
self.assertEqual(response.status, 201)
|
||||||
response.read()
|
response.read()
|
||||||
@ -7544,7 +7548,8 @@ class TestZeroCopy(unittest.TestCase):
|
|||||||
url_path = '/sda1/2100/a/c/o'
|
url_path = '/sda1/2100/a/c/o'
|
||||||
|
|
||||||
self.http_conn.request('PUT', url_path, obj_contents,
|
self.http_conn.request('PUT', url_path, obj_contents,
|
||||||
{'X-Timestamp': '1402600322.52126'})
|
{'X-Timestamp': '1402600322.52126',
|
||||||
|
'Content-Type': 'application/test'})
|
||||||
response = self.http_conn.getresponse()
|
response = self.http_conn.getresponse()
|
||||||
self.assertEqual(response.status, 201)
|
self.assertEqual(response.status, 201)
|
||||||
response.read()
|
response.read()
|
||||||
@ -7561,7 +7566,8 @@ class TestZeroCopy(unittest.TestCase):
|
|||||||
ts = '1402601849.47475'
|
ts = '1402601849.47475'
|
||||||
|
|
||||||
self.http_conn.request('PUT', url_path, 'obj contents',
|
self.http_conn.request('PUT', url_path, 'obj contents',
|
||||||
{'X-Timestamp': ts})
|
{'X-Timestamp': ts,
|
||||||
|
'Content-Type': 'application/test'})
|
||||||
response = self.http_conn.getresponse()
|
response = self.http_conn.getresponse()
|
||||||
self.assertEqual(response.status, 201)
|
self.assertEqual(response.status, 201)
|
||||||
response.read()
|
response.read()
|
||||||
@ -7592,7 +7598,8 @@ class TestZeroCopy(unittest.TestCase):
|
|||||||
|
|
||||||
self.http_conn.request(
|
self.http_conn.request(
|
||||||
'PUT', url_path, '',
|
'PUT', url_path, '',
|
||||||
{'X-Timestamp': ts, 'Content-Length': '0'})
|
{'X-Timestamp': ts, 'Content-Length': '0',
|
||||||
|
'Content-Type': 'application/test'})
|
||||||
response = self.http_conn.getresponse()
|
response = self.http_conn.getresponse()
|
||||||
self.assertEqual(response.status, 201)
|
self.assertEqual(response.status, 201)
|
||||||
response.read()
|
response.read()
|
||||||
@ -7623,9 +7630,7 @@ class TestConfigOptionHandling(unittest.TestCase):
|
|||||||
conf_file = os.path.join(self.tmpdir, 'object-server.conf')
|
conf_file = os.path.join(self.tmpdir, 'object-server.conf')
|
||||||
with open(conf_file, 'w') as f:
|
with open(conf_file, 'w') as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
with mock.patch('swift.common.wsgi.monkey_patch_mimetools'):
|
return init_request_processor(conf_file, 'object-server')[:2]
|
||||||
app = init_request_processor(conf_file, 'object-server')[:2]
|
|
||||||
return app
|
|
||||||
|
|
||||||
def test_default(self):
|
def test_default(self):
|
||||||
config = """
|
config = """
|
||||||
@ -7639,8 +7644,8 @@ class TestConfigOptionHandling(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
app, config = self._app_config(config)
|
app, config = self._app_config(config)
|
||||||
self.assertNotIn('reclaim_age', config)
|
self.assertNotIn('reclaim_age', config)
|
||||||
self.assertEqual(app._diskfile_router[POLICIES.legacy].reclaim_age,
|
for policy in POLICIES:
|
||||||
604800)
|
self.assertEqual(app._diskfile_router[policy].reclaim_age, 604800)
|
||||||
|
|
||||||
def test_option_in_app(self):
|
def test_option_in_app(self):
|
||||||
config = """
|
config = """
|
||||||
@ -7655,8 +7660,8 @@ class TestConfigOptionHandling(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
app, config = self._app_config(config)
|
app, config = self._app_config(config)
|
||||||
self.assertEqual(config['reclaim_age'], '100')
|
self.assertEqual(config['reclaim_age'], '100')
|
||||||
self.assertEqual(app._diskfile_router[POLICIES.legacy].reclaim_age,
|
for policy in POLICIES:
|
||||||
100)
|
self.assertEqual(app._diskfile_router[policy].reclaim_age, 100)
|
||||||
|
|
||||||
def test_option_in_default(self):
|
def test_option_in_default(self):
|
||||||
config = """
|
config = """
|
||||||
@ -7671,8 +7676,8 @@ class TestConfigOptionHandling(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
app, config = self._app_config(config)
|
app, config = self._app_config(config)
|
||||||
self.assertEqual(config['reclaim_age'], '200')
|
self.assertEqual(config['reclaim_age'], '200')
|
||||||
self.assertEqual(app._diskfile_router[POLICIES.legacy].reclaim_age,
|
for policy in POLICIES:
|
||||||
200)
|
self.assertEqual(app._diskfile_router[policy].reclaim_age, 200)
|
||||||
|
|
||||||
def test_option_in_both(self):
|
def test_option_in_both(self):
|
||||||
config = """
|
config = """
|
||||||
@ -7688,8 +7693,8 @@ class TestConfigOptionHandling(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
app, config = self._app_config(config)
|
app, config = self._app_config(config)
|
||||||
self.assertEqual(config['reclaim_age'], '300')
|
self.assertEqual(config['reclaim_age'], '300')
|
||||||
self.assertEqual(app._diskfile_router[POLICIES.legacy].reclaim_age,
|
for policy in POLICIES:
|
||||||
300)
|
self.assertEqual(app._diskfile_router[policy].reclaim_age, 300)
|
||||||
|
|
||||||
# use paste "set" syntax to override global config value
|
# use paste "set" syntax to override global config value
|
||||||
config = """
|
config = """
|
||||||
@ -7705,8 +7710,8 @@ class TestConfigOptionHandling(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
app, config = self._app_config(config)
|
app, config = self._app_config(config)
|
||||||
self.assertEqual(config['reclaim_age'], '600')
|
self.assertEqual(config['reclaim_age'], '600')
|
||||||
self.assertEqual(app._diskfile_router[POLICIES.legacy].reclaim_age,
|
for policy in POLICIES:
|
||||||
600)
|
self.assertEqual(app._diskfile_router[policy].reclaim_age, 600)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user