28 lines
957 B
Python
28 lines
957 B
Python
#!/usr/bin/env python3
|
|
"""Wait for the public API and local telemetry backends, with a shared deadline."""
|
|
import time
|
|
from urllib.error import URLError
|
|
from urllib.request import urlopen
|
|
|
|
pending = {
|
|
'api': 'http://localhost:18083/health/ready',
|
|
'prometheus': 'http://localhost:19090/-/ready',
|
|
'loki': 'http://localhost:13100/ready',
|
|
'tempo': 'http://localhost:13200/ready',
|
|
'grafana': 'http://localhost:13000/api/health',
|
|
}
|
|
deadline = time.monotonic() + 120
|
|
while pending and time.monotonic() < deadline:
|
|
for name, url in list(pending.items()):
|
|
try:
|
|
with urlopen(url, timeout=2) as response:
|
|
if response.status == 200:
|
|
del pending[name]
|
|
except (URLError, TimeoutError, OSError):
|
|
pass
|
|
if pending:
|
|
time.sleep(1)
|
|
if pending:
|
|
raise SystemExit('Readiness timeout: ' + ', '.join(sorted(pending)))
|
|
print('PASS: API and telemetry backends ready')
|