From 971023e4c8620881cd9b45f3b5f57abd2f4112dc Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 15 May 2020 13:23:17 -0700 Subject: [PATCH] replication: Allow databases_per_second to be a float Sometimes even one database per second is too fast. Change-Id: Iaf11743485e1ad320c82476430f450be0c4f849c Closes-Bug: #1877827 --- swift/common/db_replicator.py | 2 +- test/unit/common/test_db_replicator.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py index 30ffffcb69..2c2f57bd7e 100644 --- a/swift/common/db_replicator.py +++ b/swift/common/db_replicator.py @@ -205,7 +205,7 @@ class Replicator(Daemon): ' to use option %(type)s-replicator/' 'interval.' % {'type': self.server_type}) - self.databases_per_second = int( + self.databases_per_second = float( conf.get('databases_per_second', 50)) self.node_timeout = float(conf.get('node_timeout', 10)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py index f0f4f48cab..5ec577f23f 100644 --- a/test/unit/common/test_db_replicator.py +++ b/test/unit/common/test_db_replicator.py @@ -324,7 +324,11 @@ class TestDBReplicator(unittest.TestCase): # later config should be extended to assert more config options replicator = TestReplicator({'node_timeout': '3.5'}) self.assertEqual(replicator.node_timeout, 3.5) - self.assertEqual(replicator.databases_per_second, 50) + self.assertEqual(replicator.databases_per_second, 50.0) + + replicator = TestReplicator({'databases_per_second': '0.1'}) + self.assertEqual(replicator.node_timeout, 10) + self.assertEqual(replicator.databases_per_second, 0.1) def test_repl_connection(self): node = {'replication_ip': '127.0.0.1', 'replication_port': 80,