From 983622d51203161681e4741a5815a623a35166a6 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Wed, 16 Nov 2022 18:20:33 +0000 Subject: [PATCH] account_auditor: fix warning string The warning string should refer to account not container. Also, add the account name to the warning string. Change-Id: I6e7058eb9f5ed4298b5055d46dafb66d24ec5d09 --- swift/account/auditor.py | 7 ++++--- test/unit/account/test_auditor.py | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/swift/account/auditor.py b/swift/account/auditor.py index acb7483409..7aa26c0757 100644 --- a/swift/account/auditor.py +++ b/swift/account/auditor.py @@ -41,6 +41,7 @@ class AccountAuditor(DatabaseAuditor): if policy_totals[key] == info[key]: continue return InvalidAccountInfo( - 'The total %(key)s for the container (%(total)s) does not ' - 'match the sum of %(key)s across policies (%(sum)s)' - % {'key': key, 'total': info[key], 'sum': policy_totals[key]}) + 'The total %(key)s for the account %(account)s (%(total)s) ' + 'does not match the sum of %(key)s across policies (%(sum)s)' + % {'key': key, 'account': info.get('account'), + 'total': info[key], 'sum': policy_totals[key]}) diff --git a/test/unit/account/test_auditor.py b/test/unit/account/test_auditor.py index f0ecc9d8fa..37410af736 100644 --- a/test/unit/account/test_auditor.py +++ b/test/unit/account/test_auditor.py @@ -125,8 +125,9 @@ class TestAuditorRealBroker(unittest.TestCase): self.assertEqual(len(error_lines), 1) error_message = error_lines[0] self.assertIn(broker.db_file, error_message) - self.assertIn('container_count', error_message) - self.assertIn('does not match', error_message) + self.assertIn( + 'The total container_count for the account a (3) does not match ' + 'the sum of container_count across policies (2)', error_message) self.assertEqual(test_auditor.logger.get_increment_counts(), {'failures': 1})