diff --git a/zaqar/storage/mongodb/options.py b/zaqar/storage/mongodb/options.py index 627d9b52d..74667601b 100644 --- a/zaqar/storage/mongodb/options.py +++ b/zaqar/storage/mongodb/options.py @@ -75,7 +75,7 @@ _COMMON_OPTIONS = ( group=_deprecated_group), ], help='Database name.'), - cfg.IntOpt('max_attempts', default=1000, + cfg.IntOpt('max_attempts', min=0, default=1000, deprecated_opts=[cfg.DeprecatedOpt( 'max_attempts', group=_deprecated_group), ], diff --git a/zaqar/storage/mongodb/utils.py b/zaqar/storage/mongodb/utils.py index b2d711fdf..198808c30 100644 --- a/zaqar/storage/mongodb/utils.py +++ b/zaqar/storage/mongodb/utils.py @@ -87,8 +87,6 @@ def calculate_backoff(attempt, max_attempts, max_sleep, max_jitter=0): the interval [0, max_sleep), determined linearly according to the ratio attempt / max_attempts, with optional jitter. """ - if max_attempts < 0: - raise ValueError(u'max_attempts must be >= 0') if max_sleep < 0: raise ValueError(u'max_sleep must be >= 0') diff --git a/zaqar/tests/unit/storage/test_impl_mongodb.py b/zaqar/tests/unit/storage/test_impl_mongodb.py index abc635931..6e902cbec 100644 --- a/zaqar/tests/unit/storage/test_impl_mongodb.py +++ b/zaqar/tests/unit/storage/test_impl_mongodb.py @@ -110,8 +110,6 @@ class MongodbUtilsTest(MongodbSetupMixin, testing.TestBase): self.assertRaises(ValueError, utils.calculate_backoff, 0, 10, -2, 0) self.assertRaises(ValueError, utils.calculate_backoff, 0, 10, 2, -1) - self.assertRaises(ValueError, utils.calculate_backoff, -2, -10, 2, 0) - self.assertRaises(ValueError, utils.calculate_backoff, 2, -10, 2, 0) self.assertRaises(ValueError, utils.calculate_backoff, -2, 10, 2, 0) self.assertRaises(ValueError, utils.calculate_backoff, -1, 10, 2, 0) self.assertRaises(ValueError, utils.calculate_backoff, 10, 10, 2, 0)