summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-03-15 12:41:26 +0000
committerGerrit Code Review <review@openstack.org>2021-03-15 12:41:26 +0000
commit59239af2b2c9b5d6896f3b2a8f80b569d2a5ac62 (patch)
tree099e10271812286ec4a763c1dd7f93232ff03dfe
parentd43d59e4c6818b186996583a672ec445e35f7693 (diff)
parentc9052f665cb92d63ef30c989a939d9dd7c7e878d (diff)
downloadswift-59239af2b2c9b5d6896f3b2a8f80b569d2a5ac62.tar.gz
Merge "Change alignment on `compact` output"
-rw-r--r--swift/cli/manage_shard_ranges.py4
-rw-r--r--test/unit/cli/test_manage_shard_ranges.py48
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')