From eacebbb167e2d57d0f12c32914fdbfcb0587b9fe Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 4 Jun 2021 12:51:56 -0700 Subject: [PATCH] Allow floats for a couple more intervals Somehow I missed these on the first go-round. Change-Id: I8baef6ba35a2f59eac30695943a671d53228e75c Related-Change: I91e9bc02d94fe7ea6e89307305705c383087845a --- swift/common/container_sync_realms.py | 2 +- swift/proxy/server.py | 2 +- test/unit/common/test_container_sync_realms.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/swift/common/container_sync_realms.py b/swift/common/container_sync_realms.py index fc0bee8f1c..ce50a6c04e 100644 --- a/swift/common/container_sync_realms.py +++ b/swift/common/container_sync_realms.py @@ -72,7 +72,7 @@ class ContainerSyncRealms(object): % {'conf': self.conf_path, 'error': err}) else: try: - self.mtime_check_interval = conf.getint( + self.mtime_check_interval = conf.getfloat( 'DEFAULT', 'mtime_check_interval') self.next_mtime_check = \ now + self.mtime_check_interval diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 6bd7fbe918..515b87b52f 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -213,7 +213,7 @@ class Application(object): self.trans_id_suffix = conf.get('trans_id_suffix', '') self.post_quorum_timeout = float(conf.get('post_quorum_timeout', 0.5)) self.error_suppression_interval = \ - int(conf.get('error_suppression_interval', 60)) + float(conf.get('error_suppression_interval', 60)) self.error_suppression_limit = \ int(conf.get('error_suppression_limit', 10)) self.recheck_container_existence = \ diff --git a/test/unit/common/test_container_sync_realms.py b/test/unit/common/test_container_sync_realms.py index 77b3ebdc15..b883b66fe6 100644 --- a/test/unit/common/test_container_sync_realms.py +++ b/test/unit/common/test_container_sync_realms.py @@ -20,7 +20,7 @@ import uuid import six -from mock import patch +from mock import ANY, patch from swift.common.container_sync_realms import ContainerSyncRealms from test.debug_logger import debug_logger from test.unit import temptree @@ -177,11 +177,13 @@ mtime_check_interval = invalid logger = debug_logger() fpath = os.path.join(tempdir, fname) csr = ContainerSyncRealms(fpath, logger) - self.assertEqual( - logger.all_log_lines(), - {'error': [ - "Error in '%s' with mtime_check_interval: invalid literal " - "for int() with base 10: 'invalid'" % fpath]}) + logs = logger.all_log_lines() + self.assertEqual(logs, {'error': [ANY]}) + line = logs['error'][0] + self.assertIn( + "Error in '%s' with mtime_check_interval: " + "could not convert string to float:" % fpath, line) + self.assertEqual(csr.mtime_check_interval, 300) def test_get_sig(self):