making unit tests work a little better

This commit is contained in:
David Goetz
2010-10-13 14:30:00 -07:00
parent 29d3887572
commit 73c3db6d1b
2 changed files with 6 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ there will be no rate limiting. Configuration available:
======================== ========= =========================================== ======================== ========= ===========================================
Option Default Description Option Default Description
---------------------- --------- ------------------------------------------- ------------------------ --------- -------------------------------------------
clock_accuracy 1000 Represents how accurate the proxy servers' clock_accuracy 1000 Represents how accurate the proxy servers'
system clocks are with each other. 1000 system clocks are with each other. 1000
means that all the proxies' clock are 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: container_ratelimit_size '' When set with container_limit_x = r:
for containers of size x, limit requests for containers of size x, limit requests
per second to r. Will limit GET and HEAD per second to r. Will limit GET and HEAD
requests to /account_name/container_name and requests to /account_name/container_name
PUTs and DELETEs to and PUTs and DELETEs to
/account_name/container_name/object_name /account_name/container_name/object_name
======================== ========= =========================================== ======================== ========= ===========================================

View File

@@ -204,8 +204,7 @@ class TestRateLimit(unittest.TestCase):
''.join(t.result).startswith('Slow down')] ''.join(t.result).startswith('Slow down')]
self.assertEquals(len(the_498s), 0) self.assertEquals(len(the_498s), 0)
time_took = time.time() - begin time_took = time.time() - begin
# the 4th request will happen at 1.5 self.assert_(time_took < 1)
self.assert_(round(time_took, 1) == 0)
def test_ratelimit_blacklist(self): def test_ratelimit_blacklist(self):
current_rate = 2 current_rate = 2
@@ -280,7 +279,7 @@ class TestRateLimit(unittest.TestCase):
the_498s = [t for t in all_results if t.startswith('Slow down')] the_498s = [t for t in all_results if t.startswith('Slow down')]
self.assertEquals(len(the_498s), 2) self.assertEquals(len(the_498s), 2)
time_took = time.time() - begin 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): def test_ratelimit_max_rate_multiple_acc(self):
num_calls = 4 num_calls = 4
@@ -317,7 +316,7 @@ class TestRateLimit(unittest.TestCase):
thread.join() thread.join()
time_took = time.time() - begin time_took = time.time() - begin
# the all 15 threads still take 1.5 secs # 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): def test_ratelimit_acc_vrs_container(self):
conf_dict = {'clock_accuracy': 1000, conf_dict = {'clock_accuracy': 1000,