From 73c3db6d1bbee362570ea37b62da37bb91d3ecca Mon Sep 17 00:00:00 2001 From: David Goetz Date: Wed, 13 Oct 2010 14:30:00 -0700 Subject: [PATCH] making unit tests work a little better --- doc/source/ratelimit.rst | 6 +++--- test/unit/common/middleware/test_ratelimit.py | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/source/ratelimit.rst b/doc/source/ratelimit.rst index 43649e55e5..3f6852dffd 100644 --- a/doc/source/ratelimit.rst +++ b/doc/source/ratelimit.rst @@ -17,7 +17,7 @@ there will be no rate limiting. Configuration available: ======================== ========= =========================================== Option Default Description ----------------------- --------- ------------------------------------------- +------------------------ --------- ------------------------------------------- clock_accuracy 1000 Represents how accurate the proxy servers' system clocks are with each other. 1000 means that all the proxies' clock are @@ -38,8 +38,8 @@ account_blacklist '' Comma separated lists of account names that container_ratelimit_size '' When set with container_limit_x = r: for containers of size x, limit requests per second to r. Will limit GET and HEAD - requests to /account_name/container_name and - PUTs and DELETEs to + requests to /account_name/container_name + and PUTs and DELETEs to /account_name/container_name/object_name ======================== ========= =========================================== diff --git a/test/unit/common/middleware/test_ratelimit.py b/test/unit/common/middleware/test_ratelimit.py index 7b8c91d73c..305a81dc7a 100644 --- a/test/unit/common/middleware/test_ratelimit.py +++ b/test/unit/common/middleware/test_ratelimit.py @@ -204,8 +204,7 @@ class TestRateLimit(unittest.TestCase): ''.join(t.result).startswith('Slow down')] self.assertEquals(len(the_498s), 0) time_took = time.time() - begin - # the 4th request will happen at 1.5 - self.assert_(round(time_took, 1) == 0) + self.assert_(time_took < 1) def test_ratelimit_blacklist(self): current_rate = 2 @@ -280,7 +279,7 @@ class TestRateLimit(unittest.TestCase): the_498s = [t for t in all_results if t.startswith('Slow down')] self.assertEquals(len(the_498s), 2) time_took = time.time() - begin - self.assert_(round(time_took, 1) == 1.5) + self.assert_(1.5 <= round(time_took,1) < 1.7, time_took) def test_ratelimit_max_rate_multiple_acc(self): num_calls = 4 @@ -317,7 +316,7 @@ class TestRateLimit(unittest.TestCase): thread.join() time_took = time.time() - begin # the all 15 threads still take 1.5 secs - self.assert_(round(time_took, 1) == 1.5) + self.assert_(1.5 <= round(time_took,1) < 1.7) def test_ratelimit_acc_vrs_container(self): conf_dict = {'clock_accuracy': 1000,