From 5795282c9fc9e426857d0c35752160a7633e3abb Mon Sep 17 00:00:00 2001 From: mkosiarc Date: Fri, 6 Sep 2024 15:20:06 +0200 Subject: [PATCH] Revert "Update urllib version" This reverts commit dfeac8636671576c61ac847854c9fc211ba3610a. This is because the urllib version on brew builders is lower than 1.26 and there is not an easy way to enforce/install a version of 1.26.19 Signed-off-by: mkosiarc --- osbs/constants.py | 2 +- osbs/osbs_http.py | 4 ++-- tests/requirements.txt | 2 +- tests/test_retries.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osbs/constants.py b/osbs/constants.py index 53df9a82..18e003f4 100644 --- a/osbs/constants.py +++ b/osbs/constants.py @@ -57,7 +57,7 @@ HTTP_RETRIES_STATUS_FORCELIST = [408, 500, 502, 503, 504] # HTTP methods that we should retry on -HTTP_RETRIES_ALLOWED_METHODS = ['GET', 'PUT', 'POST', 'DELETE'] +HTTP_RETRIES_METHODS_WHITELIST = ['GET', 'PUT', 'POST', 'DELETE'] # requests timeout in seconds HTTP_REQUEST_TIMEOUT = 600 diff --git a/osbs/osbs_http.py b/osbs/osbs_http.py index 0ccb5c94..bde43eca 100644 --- a/osbs/osbs_http.py +++ b/osbs/osbs_http.py @@ -19,7 +19,7 @@ from osbs.exceptions import OsbsException, OsbsNetworkException, OsbsResponseException from osbs.constants import ( HTTP_MAX_RETRIES, HTTP_BACKOFF_FACTOR, HTTP_RETRIES_STATUS_FORCELIST, - HTTP_RETRIES_ALLOWED_METHODS, HTTP_REQUEST_TIMEOUT) + HTTP_RETRIES_METHODS_WHITELIST, HTTP_REQUEST_TIMEOUT) import requests from requests.adapters import HTTPAdapter @@ -111,7 +111,7 @@ def log_error_response_text_hook(resp, *args, **kwargs): read=HTTP_MAX_RETRIES, backoff_factor=HTTP_BACKOFF_FACTOR, status_forcelist=HTTP_RETRIES_STATUS_FORCELIST, - allowed_methods=HTTP_RETRIES_ALLOWED_METHODS, + method_whitelist=HTTP_RETRIES_METHODS_WHITELIST, raise_on_status=False, ) self.session = requests.Session() diff --git a/tests/requirements.txt b/tests/requirements.txt index 8560a4f4..231935c1 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ flexmock>=0.11.0 -urllib3>=1.26.19 +urllib3<1.26 pytest==7.0.1 pytest-cov pytest-html diff --git a/tests/test_retries.py b/tests/test_retries.py index e7d3fd7d..e69e2008 100644 --- a/tests/test_retries.py +++ b/tests/test_retries.py @@ -18,7 +18,7 @@ import requests from urllib3.util import Retry from osbs.exceptions import OsbsNetworkException, OsbsResponseException -from osbs.constants import HTTP_RETRIES_STATUS_FORCELIST, HTTP_RETRIES_ALLOWED_METHODS +from osbs.constants import HTTP_RETRIES_STATUS_FORCELIST, HTTP_RETRIES_METHODS_WHITELIST from osbs.osbs_http import HttpSession, HttpStream from osbs import osbs_http logger = logging.getLogger(__file__) @@ -49,7 +49,7 @@ def has_connection(): reason="requires internet connection") class TestHttpRetries(object): @pytest.mark.parametrize('status_code', HTTP_RETRIES_STATUS_FORCELIST) - @pytest.mark.parametrize('method', HTTP_RETRIES_ALLOWED_METHODS) + @pytest.mark.parametrize('method', HTTP_RETRIES_METHODS_WHITELIST) def test_fail_after_retries(self, s, status_code, method): flexmock(osbs_http).should_receive('Retry').and_return(fake_retry) # latest python-requests throws OsbsResponseException, 2.6.x - OsbsNetworkException