fix: add timeouts to PayPal sandbox tests and pytest-timeout safety net
PayPal sandbox tests used requests.post/get() with no timeout parameter. When the CI runner at build.unturf.com cannot reach api-m.sandbox.paypal.com, these calls block until TCP timeout (minutes), stalling all xdist workers and causing the 1-hour CI timeout. - Add timeout=10 to all requests calls in PayPal sandbox tests - Add pytest-timeout with 60s default so no single test can hang the suite
This commit is contained in:
parent
c4926a8ab9
commit
cdc6582a8f
3 changed files with 14 additions and 6 deletions
|
|
@ -1773,7 +1773,8 @@ class AuthenticatedFunctionalTests(FunctionalTests):
|
|||
f"{base_url}/v1/oauth2/token",
|
||||
headers={"Accept": "application/json", "Accept-Language": "en_US"},
|
||||
data={"grant_type": "client_credentials"},
|
||||
auth=(paypal_client_id, paypal_secret)
|
||||
auth=(paypal_client_id, paypal_secret),
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
self.assertEqual(auth_response.status_code, 200)
|
||||
|
|
@ -1803,7 +1804,8 @@ class AuthenticatedFunctionalTests(FunctionalTests):
|
|||
f"{base_url}/v1/oauth2/token",
|
||||
headers={"Accept": "application/json", "Accept-Language": "en_US"},
|
||||
data={"grant_type": "client_credentials"},
|
||||
auth=(paypal_client_id, paypal_secret)
|
||||
auth=(paypal_client_id, paypal_secret),
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
self.assertEqual(auth_response.status_code, 200)
|
||||
|
|
@ -1827,7 +1829,8 @@ class AuthenticatedFunctionalTests(FunctionalTests):
|
|||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {access_token}"
|
||||
},
|
||||
json=order_json
|
||||
json=order_json,
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
self.assertEqual(order_response.status_code, 201)
|
||||
|
|
@ -1943,7 +1946,8 @@ class AuthenticatedFunctionalTests(FunctionalTests):
|
|||
f"{base_url}/v1/oauth2/token",
|
||||
headers={"Accept": "application/json", "Accept-Language": "en_US"},
|
||||
data={"grant_type": "client_credentials"},
|
||||
auth=(paypal_client_id, paypal_secret)
|
||||
auth=(paypal_client_id, paypal_secret),
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
access_token = auth_response.json()["access_token"]
|
||||
|
|
@ -1961,7 +1965,8 @@ class AuthenticatedFunctionalTests(FunctionalTests):
|
|||
"amount": {"currency_code": "USD", "value": "5.00"},
|
||||
"description": "Test retrieval order"
|
||||
}]
|
||||
}
|
||||
},
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
order_id = order_response.json()["id"]
|
||||
|
|
@ -1969,7 +1974,8 @@ class AuthenticatedFunctionalTests(FunctionalTests):
|
|||
# Retrieve the order
|
||||
get_response = requests.get(
|
||||
f"{base_url}/v2/checkout/orders/{order_id}",
|
||||
headers={"Authorization": f"Bearer {access_token}"}
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
self.assertEqual(get_response.status_code, 200)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[pytest]
|
||||
testpaths = make_post_sell
|
||||
python_files = test*.py
|
||||
timeout = 60
|
||||
# Uncomment filterwarnings to suppress external library warnings
|
||||
# filterwarnings =
|
||||
# # Ignore datetime.utcnow() deprecation from external libraries
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# testing.
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-timeout # Per-test timeout safety net
|
||||
pytest-xdist # Parallel test execution
|
||||
nose
|
||||
mock
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue