##// END OF EJS Templates
tests: make the routing link tests retry connections. Reduced test failures
marcink -
r2139:665d2e32 default
parent child Browse files
Show More
@@ -37,11 +37,35 b' connection_available = pytest.mark.skipi'
37 not check_connection(), reason="No outside internet connection available")
37 not check_connection(), reason="No outside internet connection available")
38
38
39
39
40 @connection_available
40 import requests
41 def test_connect_redirection_links():
41 from requests.adapters import HTTPAdapter
42 from requests.packages.urllib3.util.retry import Retry
43
42
44
43 for link_data in routing_links.link_config:
45 def requests_retry_session(
44 response = requests.get(link_data['target'])
46 retries=3,
47 backoff_factor=0.3,
48 status_forcelist=(500, 502, 504),
49 session=None,
50 ):
51 session = session or requests.Session()
52 retry = Retry(
53 total=retries,
54 read=retries,
55 connect=retries,
56 backoff_factor=backoff_factor,
57 status_forcelist=status_forcelist,
58 )
59 adapter = HTTPAdapter(max_retries=retry)
60 session.mount('http://', adapter)
61 session.mount('https://', adapter)
62 return session
63
64
65 @connection_available
66 @pytest.mark.parametrize('link_data', routing_links.link_config)
67 def test_connect_redirection_links(link_data):
68 response = requests_retry_session().get(link_data['target'])
45 if link_data['name'] == 'enterprise_license_convert_from_old':
69 if link_data['name'] == 'enterprise_license_convert_from_old':
46 # special case for a page that requires a valid login
70 # special case for a page that requires a valid login
47 assert response.url == 'https://rhodecode.com/login'
71 assert response.url == 'https://rhodecode.com/login'
General Comments 0
You need to be logged in to leave comments. Login now