diff options
author | Tim Burke <tim.burke@gmail.com> | 2021-03-12 11:08:08 -0800 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2021-03-12 11:16:30 -0800 |
commit | c9052f665cb92d63ef30c989a939d9dd7c7e878d (patch) | |
tree | 98c470134e92740493872c9048264d147d4b43a8 | |
parent | a045f90b4d7ccc2da4cd52883c04c176b9ec920f (diff) | |
download | swift-c9052f665cb92d63ef30c989a939d9dd7c7e878d.tar.gz |
Change alignment on `compact` output
Change-Id: I4735c725ad152ca5bed3f64decc101a9fb034469
-rw-r--r-- | swift/cli/manage_shard_ranges.py | 4 | ||||
-rw-r--r-- | test/unit/cli/test_manage_shard_ranges.py | 48 |
2 files changed, 39 insertions, 13 deletions
diff --git a/swift/cli/manage_shard_ranges.py b/swift/cli/manage_shard_ranges.py index 6599c7daa..30d510fb2 100644 --- a/swift/cli/manage_shard_ranges.py +++ b/swift/cli/manage_shard_ranges.py @@ -182,9 +182,9 @@ DEFAULT_SHRINK_THRESHOLD = DEFAULT_SHARD_CONTAINER_THRESHOLD * \ def _print_shard_range(sr, level=0): indent = ' ' * level 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)) - 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): diff --git a/test/unit/cli/test_manage_shard_ranges.py b/test/unit/cli/test_manage_shard_ranges.py index 2f66f3260..d2bedaaf2 100644 --- a/test/unit/cli/test_manage_shard_ranges.py +++ b/test/unit/cli/test_manage_shard_ranges.py @@ -693,17 +693,43 @@ class TestManageShardRanges(unittest.TestCase): err_lines = err.getvalue().split('\n') self.assert_starts_with(err_lines[0], 'Loaded db broker for ') out_lines = out.getvalue().split('\n') - self.assertIn('total of 20 objects', out_lines[0]) - self.assertIn('.shards_a', out_lines[1]) - self.assertIn('objects: 10', out_lines[2]) - self.assertIn('state: active', out_lines[3]) - self.assertIn('.shards_a', out_lines[4]) - self.assertIn('objects: 10', out_lines[5]) - self.assertIn('state: active', out_lines[6]) - self.assertIn('can be compacted into', out_lines[7]) - self.assertIn('.shards_a', out_lines[8]) - self.assertIn('objects: 10', out_lines[9]) - self.assertIn('state: active', out_lines[10]) + expected = [ + 'Donor shard range(s) with total of 20 objects:', + " '.shards_a", + " objects: 10 lower: 'obj29'", + " state: active upper: 'obj39'", + " '.shards_a", + " objects: 10 lower: 'obj39'", + " state: active upper: 'obj49'", + 'can be compacted into acceptor shard range:', + " '.shards_a", + " 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() broker_ranges = do_compact('n') |