Merge "Fix shard_max_row in ContainerBroker.get_replication_info()"
This commit is contained in:
@@ -838,7 +838,7 @@ class ContainerBroker(DatabaseBroker):
|
|||||||
|
|
||||||
def get_replication_info(self):
|
def get_replication_info(self):
|
||||||
info = super(ContainerBroker, self).get_replication_info()
|
info = super(ContainerBroker, self).get_replication_info()
|
||||||
info['shard_max_row'] = self.get_max_row('shard_ranges')
|
info['shard_max_row'] = self.get_max_row(SHARD_RANGE_TABLE)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def _do_get_info_query(self, conn):
|
def _do_get_info_query(self, conn):
|
||||||
|
@@ -2013,6 +2013,41 @@ class TestContainerBroker(unittest.TestCase):
|
|||||||
self.assertEqual(info['reported_object_count'], 2)
|
self.assertEqual(info['reported_object_count'], 2)
|
||||||
self.assertEqual(info['reported_bytes_used'], 1123)
|
self.assertEqual(info['reported_bytes_used'], 1123)
|
||||||
|
|
||||||
|
@with_tempdir
|
||||||
|
def test_get_replication_info(self, tempdir):
|
||||||
|
ts_iter = make_timestamp_iter()
|
||||||
|
db_path = os.path.join(tempdir, 'part', 'suffix', 'hash', 'hash.db')
|
||||||
|
broker = ContainerBroker(
|
||||||
|
db_path, account='myaccount', container='mycontainer')
|
||||||
|
broker.initialize(next(ts_iter).internal, 0)
|
||||||
|
metadata = {'blah': ['val', next(ts_iter).internal]}
|
||||||
|
broker.update_metadata(metadata)
|
||||||
|
expected = broker.get_info()
|
||||||
|
expected['metadata'] = json.dumps(metadata)
|
||||||
|
expected.pop('object_count')
|
||||||
|
expected['count'] = 0
|
||||||
|
expected['max_row'] = -1
|
||||||
|
expected['shard_max_row'] = -1
|
||||||
|
actual = broker.get_replication_info()
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
broker.put_object('o1', next(ts_iter).internal, 123, 'text/plain',
|
||||||
|
'fake etag')
|
||||||
|
expected = broker.get_info()
|
||||||
|
expected['metadata'] = json.dumps(metadata)
|
||||||
|
expected.pop('object_count')
|
||||||
|
expected['count'] = 1
|
||||||
|
expected['max_row'] = 1
|
||||||
|
expected['shard_max_row'] = -1
|
||||||
|
actual = broker.get_replication_info()
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
sr = ShardRange('.shards_a/c', next(ts_iter))
|
||||||
|
broker.merge_shard_ranges(sr)
|
||||||
|
expected['shard_max_row'] = 1
|
||||||
|
actual = broker.get_replication_info()
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
def test_remove_objects(self, tempdir):
|
def test_remove_objects(self, tempdir):
|
||||||
objects = (('undeleted', Timestamp.now().internal, 0, 'text/plain',
|
objects = (('undeleted', Timestamp.now().internal, 0, 'text/plain',
|
||||||
|
Reference in New Issue
Block a user