Merge "Change alignment on compact
output"
This commit is contained in:
commit
59239af2b2
@ -182,9 +182,9 @@ DEFAULT_SHRINK_THRESHOLD = DEFAULT_SHARD_CONTAINER_THRESHOLD * \
|
|||||||
def _print_shard_range(sr, level=0):
|
def _print_shard_range(sr, level=0):
|
||||||
indent = ' ' * level
|
indent = ' ' * level
|
||||||
print(indent + '%r' % sr.name)
|
print(indent + '%r' % sr.name)
|
||||||
print(indent + ' objects: %-9d lower: %r' % (sr.object_count,
|
print(indent + ' objects: %9d lower: %r' % (sr.object_count,
|
||||||
sr.lower_str))
|
sr.lower_str))
|
||||||
print(indent + ' state: %-9s upper: %r' % (sr.state_text, sr.upper_str))
|
print(indent + ' state: %9s upper: %r' % (sr.state_text, sr.upper_str))
|
||||||
|
|
||||||
|
|
||||||
def _load_and_validate_shard_data(args):
|
def _load_and_validate_shard_data(args):
|
||||||
|
@ -693,17 +693,43 @@ class TestManageShardRanges(unittest.TestCase):
|
|||||||
err_lines = err.getvalue().split('\n')
|
err_lines = err.getvalue().split('\n')
|
||||||
self.assert_starts_with(err_lines[0], 'Loaded db broker for ')
|
self.assert_starts_with(err_lines[0], 'Loaded db broker for ')
|
||||||
out_lines = out.getvalue().split('\n')
|
out_lines = out.getvalue().split('\n')
|
||||||
self.assertIn('total of 20 objects', out_lines[0])
|
expected = [
|
||||||
self.assertIn('.shards_a', out_lines[1])
|
'Donor shard range(s) with total of 20 objects:',
|
||||||
self.assertIn('objects: 10', out_lines[2])
|
" '.shards_a",
|
||||||
self.assertIn('state: active', out_lines[3])
|
" objects: 10 lower: 'obj29'",
|
||||||
self.assertIn('.shards_a', out_lines[4])
|
" state: active upper: 'obj39'",
|
||||||
self.assertIn('objects: 10', out_lines[5])
|
" '.shards_a",
|
||||||
self.assertIn('state: active', out_lines[6])
|
" objects: 10 lower: 'obj39'",
|
||||||
self.assertIn('can be compacted into', out_lines[7])
|
" state: active upper: 'obj49'",
|
||||||
self.assertIn('.shards_a', out_lines[8])
|
'can be compacted into acceptor shard range:',
|
||||||
self.assertIn('objects: 10', out_lines[9])
|
" '.shards_a",
|
||||||
self.assertIn('state: active', out_lines[10])
|
" objects: 100001 lower: 'obj49'",
|
||||||
|
" state: active upper: 'obj59'",
|
||||||
|
'Donor shard range(s) with total of 10 objects:',
|
||||||
|
" '.shards_a",
|
||||||
|
" objects: 10 lower: 'obj69'",
|
||||||
|
" state: active upper: 'obj79'",
|
||||||
|
'can be compacted into acceptor shard range:',
|
||||||
|
" '.shards_a",
|
||||||
|
" objects: 100001 lower: 'obj79'",
|
||||||
|
" state: active upper: 'obj89'",
|
||||||
|
'Once applied to the broker these changes will result in '
|
||||||
|
'shard range compaction the next time the sharder runs.',
|
||||||
|
]
|
||||||
|
if user_input == 'y':
|
||||||
|
expected.extend([
|
||||||
|
'Updated 2 shard sequences for compaction.',
|
||||||
|
'Run container-replicator to replicate the changes to '
|
||||||
|
'other nodes.',
|
||||||
|
'Run container-sharder on all nodes to compact shards.',
|
||||||
|
'',
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
expected.extend([
|
||||||
|
'No changes applied',
|
||||||
|
'',
|
||||||
|
])
|
||||||
|
self.assertEqual(expected, [l.split('/', 1)[0] for l in out_lines])
|
||||||
return broker.get_shard_ranges()
|
return broker.get_shard_ranges()
|
||||||
|
|
||||||
broker_ranges = do_compact('n')
|
broker_ranges = do_compact('n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user