コード例 #1
0
ファイル: test_api.py プロジェクト: ravello/testmill
 def test_retry_succeed(self):
     api = RavelloClient(retries=4, timeout=5)
     api.connect(env.service_url)
     api.login(env.username, env.password)
     parsed = urlparse.urlsplit(env.service_url)
     ipaddr = socket.gethostbyname(parsed.netloc)
     def timed_block(secs):
         with networkblocker.block_ip(ipaddr):
             time.sleep(secs)
     thread = threading.Thread(target=timed_block, args=(12.5,))
     thread.start()
     # Target IP is blocked for 12.5 seconds. 3 retries of 5 seconds
     # each are done. So on the last retry, this should work.
     api.hello()
     thread.join()
     assert api._total_retries >= 2