Pass app service env and improve health diagnostics
This commit is contained in:
parent
7f07ededcf
commit
ea43f96898
|
|
@ -41,6 +41,15 @@ rails e2e spec:
|
|||
alias: postgres
|
||||
- name: $CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA
|
||||
alias: app
|
||||
variables:
|
||||
POSTGRES_URL: postgres://turniere:turniere@postgres:5432/turniere_blackbox
|
||||
POSTGRES_USERNAME: turniere
|
||||
POSTGRES_PASSWORD: turniere
|
||||
SECRET_KEY_BASE: turniere-blackbox-secret-key-base-please-change-in-real-prod
|
||||
MAILGUN_API_KEY: blackbox-test-api-key
|
||||
MAILGUN_DOMAIN: blackbox.example.com
|
||||
RAILS_LOG_TO_STDOUT: "1"
|
||||
RAILS_SERVE_STATIC_FILES: "1"
|
||||
command:
|
||||
- bundle
|
||||
- exec
|
||||
|
|
|
|||
13
tasks.py
13
tasks.py
|
|
@ -7,6 +7,7 @@ import signal
|
|||
import subprocess
|
||||
import time
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
|
@ -46,16 +47,24 @@ def _wait_for_http(base_url=TEST_BASE_URL, timeout=60):
|
|||
deadline = time.time() + timeout
|
||||
healthz_url = f"{base_url}/healthz"
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
last_error = None
|
||||
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
with opener.open(healthz_url) as response:
|
||||
if response.status == 200:
|
||||
return
|
||||
except Exception:
|
||||
last_error = f"unexpected status {response.status}"
|
||||
except urllib.error.HTTPError as error:
|
||||
body = error.read().decode("utf-8", errors="replace")
|
||||
last_error = f"http {error.code}: {body}"
|
||||
time.sleep(0.5)
|
||||
except Exception as error:
|
||||
last_error = repr(error)
|
||||
time.sleep(0.5)
|
||||
|
||||
raise RuntimeError(f"healthcheck did not become ready within {timeout}s: {healthz_url}")
|
||||
detail = f" last error: {last_error}" if last_error else ""
|
||||
raise RuntimeError(f"healthcheck did not become ready within {timeout}s: {healthz_url}.{detail}")
|
||||
|
||||
|
||||
def _docker_compose_cmd(project_name=BLACKBOX_PROJECT, compose_file=BLACKBOX_COMPOSE_FILE):
|
||||
|
|
|
|||
Loading…
Reference in New Issue