Apply remote metadata in _handle_sync_response
We've already got it in the response, may as well apply it now rather than wait for the other end to get around to running its replicators. Change-Id: Ie36a6dd075beda04b9726dfa2bba9ffed025c9ef
This commit is contained in:
parent
b4f37f720a
commit
b640631daf
@ -446,6 +446,8 @@ class Replicator(Daemon):
|
|||||||
elif 200 <= response.status < 300:
|
elif 200 <= response.status < 300:
|
||||||
rinfo = json.loads(response.data)
|
rinfo = json.loads(response.data)
|
||||||
local_sync = broker.get_sync(rinfo['id'], incoming=False)
|
local_sync = broker.get_sync(rinfo['id'], incoming=False)
|
||||||
|
if rinfo.get('metadata', ''):
|
||||||
|
broker.update_metadata(json.loads(rinfo['metadata']))
|
||||||
if self._in_sync(rinfo, info, broker, local_sync):
|
if self._in_sync(rinfo, info, broker, local_sync):
|
||||||
return True
|
return True
|
||||||
# if the difference in rowids between the two differs by
|
# if the difference in rowids between the two differs by
|
||||||
|
@ -90,12 +90,13 @@ class TestDbUsyncReplicator(ReplProbeTest):
|
|||||||
|
|
||||||
expected_meta = {
|
expected_meta = {
|
||||||
'x-container-meta-a': '2',
|
'x-container-meta-a': '2',
|
||||||
'x-container-meta-b': '2',
|
'x-container-meta-b': '3',
|
||||||
'x-container-meta-c': '1',
|
'x-container-meta-c': '1',
|
||||||
'x-container-meta-d': '2',
|
'x-container-meta-d': '2',
|
||||||
|
'x-container-meta-e': '3',
|
||||||
}
|
}
|
||||||
|
|
||||||
# node that got the object updates still doesn't have the meta
|
# node that got the object updates now has the meta
|
||||||
resp_headers = direct_client.direct_head_container(
|
resp_headers = direct_client.direct_head_container(
|
||||||
cnode, cpart, self.account, container)
|
cnode, cpart, self.account, container)
|
||||||
for header, value in expected_meta.items():
|
for header, value in expected_meta.items():
|
||||||
@ -104,14 +105,6 @@ class TestDbUsyncReplicator(ReplProbeTest):
|
|||||||
self.assertNotIn(resp_headers.get('x-container-object-count'),
|
self.assertNotIn(resp_headers.get('x-container-object-count'),
|
||||||
(None, '0', 0))
|
(None, '0', 0))
|
||||||
|
|
||||||
expected_meta = {
|
|
||||||
'x-container-meta-a': '2',
|
|
||||||
'x-container-meta-b': '3',
|
|
||||||
'x-container-meta-c': '1',
|
|
||||||
'x-container-meta-d': '2',
|
|
||||||
'x-container-meta-e': '3',
|
|
||||||
}
|
|
||||||
|
|
||||||
# other nodes still have the meta, as well as objects
|
# other nodes still have the meta, as well as objects
|
||||||
for node in cnodes:
|
for node in cnodes:
|
||||||
resp_headers = direct_client.direct_head_container(
|
resp_headers = direct_client.direct_head_container(
|
||||||
|
@ -1503,7 +1503,9 @@ class TestReplToNode(unittest.TestCase):
|
|||||||
self.assertEqual(self.replicator._repl_to_node(
|
self.assertEqual(self.replicator._repl_to_node(
|
||||||
self.fake_node, self.broker, '0', self.fake_info), True)
|
self.fake_node, self.broker, '0', self.fake_info), True)
|
||||||
metadata = self.broker.metadata
|
metadata = self.broker.metadata
|
||||||
self.assertEqual({}, metadata)
|
self.assertIn("X-Container-Sysmeta-Test", metadata)
|
||||||
|
self.assertEqual("XYZ", metadata["X-Container-Sysmeta-Test"][0])
|
||||||
|
self.assertEqual(now, metadata["X-Container-Sysmeta-Test"][1])
|
||||||
|
|
||||||
def test_repl_to_node_not_found(self):
|
def test_repl_to_node_not_found(self):
|
||||||
self.http = ReplHttp('{"id": 3, "point": -1}', set_status=404)
|
self.http = ReplHttp('{"id": 3, "point": -1}', set_status=404)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user