Merge "ring: Prevent IndexErrors in calc_replica_count"
This commit is contained in:
commit
c646b51e9f
@ -36,6 +36,8 @@ from swift.common.ring.utils import tiers_for_dev
|
||||
|
||||
|
||||
def calc_replica_count(replica2part2dev_id):
|
||||
if not replica2part2dev_id:
|
||||
return 0
|
||||
base = len(replica2part2dev_id) - 1
|
||||
extra = 1.0 * len(replica2part2dev_id[-1]) / len(replica2part2dev_id[0])
|
||||
return base + extra
|
||||
|
@ -73,6 +73,11 @@ class TestRingBuilder(unittest.TestCase):
|
||||
self.assertFalse(rb.devs_changed)
|
||||
self.assertEqual(rb.version, 0)
|
||||
self.assertIsNotNone(rb._last_part_moves)
|
||||
rd = rb.get_ring()
|
||||
self.assertEqual(rd.devs, [])
|
||||
self.assertEqual(rd.version, 0)
|
||||
self.assertIsNone(rd.next_part_power)
|
||||
self.assertEqual(rd.replica_count, 0)
|
||||
|
||||
def test_overlarge_part_powers(self):
|
||||
expected_msg = 'part_power must be at most 32 (was 33)'
|
||||
|
Loading…
x
Reference in New Issue
Block a user