Merge "Fix object server test not using correct policy"
This commit is contained in:
commit
b20cf75922
@ -504,17 +504,18 @@ class TestObjectController(unittest.TestCase):
|
|||||||
update_etag = update_etag or '098f6bcd4621d373cade4e832627b4f6'
|
update_etag = update_etag or '098f6bcd4621d373cade4e832627b4f6'
|
||||||
|
|
||||||
def mock_container_update(ctlr, op, account, container, obj, request,
|
def mock_container_update(ctlr, op, account, container, obj, request,
|
||||||
headers_out, objdevice, policy_idx):
|
headers_out, objdevice, policy):
|
||||||
calls_made.append(headers_out)
|
calls_made.append((headers_out, policy))
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'X-Timestamp': t[1].internal,
|
'X-Timestamp': t[1].internal,
|
||||||
'Content-Type': 'application/octet-stream;swift_bytes=123456789',
|
'Content-Type': 'application/octet-stream;swift_bytes=123456789',
|
||||||
'Content-Length': '4',
|
'Content-Length': '4',
|
||||||
'X-Backend-Storage-Policy': int(policy)}
|
'X-Backend-Storage-Policy-Index': int(policy)}
|
||||||
if policy.policy_type == EC_POLICY:
|
if policy.policy_type == EC_POLICY:
|
||||||
headers['X-Backend-Container-Update-Override-Etag'] = update_etag
|
headers['X-Backend-Container-Update-Override-Etag'] = update_etag
|
||||||
headers['X-Object-Sysmeta-Ec-Etag'] = update_etag
|
headers['X-Object-Sysmeta-Ec-Etag'] = update_etag
|
||||||
|
headers['X-Object-Sysmeta-Ec-Frag-Index'] = 2
|
||||||
|
|
||||||
req = Request.blank('/sda1/p/a/c/o',
|
req = Request.blank('/sda1/p/a/c/o',
|
||||||
environ={'REQUEST_METHOD': 'PUT'},
|
environ={'REQUEST_METHOD': 'PUT'},
|
||||||
@ -532,15 +533,16 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'x-content-type': 'application/octet-stream;swift_bytes=123456789',
|
'x-content-type': 'application/octet-stream;swift_bytes=123456789',
|
||||||
'x-timestamp': t[1].internal,
|
'x-timestamp': t[1].internal,
|
||||||
'x-etag': update_etag})
|
'x-etag': update_etag})
|
||||||
self.assertDictEqual(expected_headers, calls_made[0])
|
self.assertDictEqual(expected_headers, calls_made[0][0])
|
||||||
|
self.assertEqual(policy, calls_made[0][1])
|
||||||
|
|
||||||
# POST with no metadata newer than the data should return 409,
|
# POST with no metadata newer than the data should return 409,
|
||||||
# container update not expected
|
# container update not expected
|
||||||
calls_made = []
|
calls_made = []
|
||||||
req = Request.blank('/sda1/p/a/c/o',
|
req = Request.blank(
|
||||||
environ={'REQUEST_METHOD': 'POST'},
|
'/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'POST'},
|
||||||
headers={'X-Timestamp': t[0].internal,
|
headers={'X-Timestamp': t[0].internal,
|
||||||
'X-Backend-Storage-Policy': int(policy)})
|
'X-Backend-Storage-Policy-Index': int(policy)})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
mock_container_update):
|
mock_container_update):
|
||||||
@ -554,10 +556,10 @@ class TestObjectController(unittest.TestCase):
|
|||||||
# POST with newer metadata returns success and container update
|
# POST with newer metadata returns success and container update
|
||||||
# is expected
|
# is expected
|
||||||
calls_made = []
|
calls_made = []
|
||||||
req = Request.blank('/sda1/p/a/c/o',
|
req = Request.blank(
|
||||||
environ={'REQUEST_METHOD': 'POST'},
|
'/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'POST'},
|
||||||
headers={'X-Timestamp': t[3].internal,
|
headers={'X-Timestamp': t[3].internal,
|
||||||
'X-Backend-Storage-Policy': int(policy)})
|
'X-Backend-Storage-Policy-Index': int(policy)})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
mock_container_update):
|
mock_container_update):
|
||||||
@ -572,15 +574,16 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'x-content-type-timestamp': t[1].internal,
|
'x-content-type-timestamp': t[1].internal,
|
||||||
'x-meta-timestamp': t[3].internal,
|
'x-meta-timestamp': t[3].internal,
|
||||||
'x-etag': update_etag})
|
'x-etag': update_etag})
|
||||||
self.assertDictEqual(expected_headers, calls_made[0])
|
self.assertDictEqual(expected_headers, calls_made[0][0])
|
||||||
|
self.assertEqual(policy, calls_made[0][1])
|
||||||
|
|
||||||
# POST with no metadata newer than existing metadata should return
|
# POST with no metadata newer than existing metadata should return
|
||||||
# 409, container update not expected
|
# 409, container update not expected
|
||||||
calls_made = []
|
calls_made = []
|
||||||
req = Request.blank('/sda1/p/a/c/o',
|
req = Request.blank(
|
||||||
environ={'REQUEST_METHOD': 'POST'},
|
'/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'POST'},
|
||||||
headers={'X-Timestamp': t[2].internal,
|
headers={'X-Timestamp': t[2].internal,
|
||||||
'X-Backend-Storage-Policy': int(policy)})
|
'X-Backend-Storage-Policy-Index': int(policy)})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
mock_container_update):
|
mock_container_update):
|
||||||
@ -601,7 +604,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'X-Timestamp': t[2].internal,
|
'X-Timestamp': t[2].internal,
|
||||||
'Content-Type': 'text/plain',
|
'Content-Type': 'text/plain',
|
||||||
'Content-Type-Timestamp': t[2].internal,
|
'Content-Type-Timestamp': t[2].internal,
|
||||||
'X-Backend-Storage-Policy': int(policy)
|
'X-Backend-Storage-Policy-Index': int(policy)
|
||||||
})
|
})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
@ -617,7 +620,8 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'x-content-type-timestamp': t[2].internal,
|
'x-content-type-timestamp': t[2].internal,
|
||||||
'x-meta-timestamp': t[3].internal,
|
'x-meta-timestamp': t[3].internal,
|
||||||
'x-etag': update_etag})
|
'x-etag': update_etag})
|
||||||
self.assertDictEqual(expected_headers, calls_made[0])
|
self.assertDictEqual(expected_headers, calls_made[0][0])
|
||||||
|
self.assertEqual(policy, calls_made[0][1])
|
||||||
|
|
||||||
# POST with older content-type but newer metadata returns success
|
# POST with older content-type but newer metadata returns success
|
||||||
# and container update is expected
|
# and container update is expected
|
||||||
@ -628,7 +632,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'X-Timestamp': t[4].internal,
|
'X-Timestamp': t[4].internal,
|
||||||
'Content-Type': 'older',
|
'Content-Type': 'older',
|
||||||
'Content-Type-Timestamp': t[1].internal,
|
'Content-Type-Timestamp': t[1].internal,
|
||||||
'X-Backend-Storage-Policy': int(policy)
|
'X-Backend-Storage-Policy-Index': int(policy)
|
||||||
})
|
})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
@ -644,7 +648,8 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'x-content-type-timestamp': t[2].internal,
|
'x-content-type-timestamp': t[2].internal,
|
||||||
'x-meta-timestamp': t[4].internal,
|
'x-meta-timestamp': t[4].internal,
|
||||||
'x-etag': update_etag})
|
'x-etag': update_etag})
|
||||||
self.assertDictEqual(expected_headers, calls_made[0])
|
self.assertDictEqual(expected_headers, calls_made[0][0])
|
||||||
|
self.assertEqual(policy, calls_made[0][1])
|
||||||
|
|
||||||
# POST with same-time content-type and metadata returns 409
|
# POST with same-time content-type and metadata returns 409
|
||||||
# and no container update is expected
|
# and no container update is expected
|
||||||
@ -655,7 +660,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'X-Timestamp': t[4].internal,
|
'X-Timestamp': t[4].internal,
|
||||||
'Content-Type': 'ignored',
|
'Content-Type': 'ignored',
|
||||||
'Content-Type-Timestamp': t[2].internal,
|
'Content-Type-Timestamp': t[2].internal,
|
||||||
'X-Backend-Storage-Policy': int(policy)
|
'X-Backend-Storage-Policy-Index': int(policy)
|
||||||
})
|
})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
@ -674,7 +679,7 @@ class TestObjectController(unittest.TestCase):
|
|||||||
headers={
|
headers={
|
||||||
'X-Timestamp': t[3].internal,
|
'X-Timestamp': t[3].internal,
|
||||||
'Content-Type': 'text/newer',
|
'Content-Type': 'text/newer',
|
||||||
'X-Backend-Storage-Policy': int(policy)
|
'X-Backend-Storage-Policy-Index': int(policy)
|
||||||
})
|
})
|
||||||
|
|
||||||
with mock.patch('swift.obj.server.ObjectController.container_update',
|
with mock.patch('swift.obj.server.ObjectController.container_update',
|
||||||
@ -690,7 +695,8 @@ class TestObjectController(unittest.TestCase):
|
|||||||
'x-content-type-timestamp': t[3].internal,
|
'x-content-type-timestamp': t[3].internal,
|
||||||
'x-meta-timestamp': t[4].internal,
|
'x-meta-timestamp': t[4].internal,
|
||||||
'x-etag': update_etag})
|
'x-etag': update_etag})
|
||||||
self.assertDictEqual(expected_headers, calls_made[0])
|
self.assertDictEqual(expected_headers, calls_made[0][0])
|
||||||
|
self.assertEqual(policy, calls_made[0][1])
|
||||||
|
|
||||||
def test_POST_container_updates_with_replication_policy(self):
|
def test_POST_container_updates_with_replication_policy(self):
|
||||||
self._test_POST_container_updates(POLICIES[0])
|
self._test_POST_container_updates(POLICIES[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user