tests - add ready check for customcert core test

This commit is contained in:
fl0ppy-d1sk 2023-10-27 15:34:28 +02:00
parent c1562bc896
commit 3020c5c8e5
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500

View file

@ -4,6 +4,34 @@ from requests.exceptions import RequestException
from traceback import format_exc
try:
ready = False
retries = 0
while not ready:
with suppress(RequestException):
resp = get(
f"http://www.example.com/ready",
headers={"Host": "www.example.com"},
verify=False,
allow_redirects=True
)
status_code = resp.status_code
text = resp.text
if status_code >= 500:
print("❌ An error occurred with the server, exiting ...", flush=True)
exit(1)
ready = status_code < 400 and text == "ready"
if retries > 10:
print("❌ The service took too long to be ready, exiting ...", flush=True)
exit(1)
elif not ready:
retries += 1
print("⚠️ Waiting for the service to be ready, retrying in 5s ...", flush=True)
sleep(5)
use_custom_ssl = getenv("USE_CUSTOM_SSL", "no") == "yes"
print(