ЛР 3 — БВТ-2302 — Сабитов — на 3
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
"""Wait until both real API aliases are observed through the LB."""
|
||||
import os
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
base = os.environ.get('BASE_URL', 'http://localhost:8080')
|
||||
seen = set()
|
||||
deadline = time.monotonic() + 20
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
with urllib.request.urlopen(base + '/health/ready', timeout=2) as reply:
|
||||
seen.add(reply.headers['X-Instance-Id'])
|
||||
except OSError:
|
||||
pass
|
||||
if {'api1', 'api2'} <= seen:
|
||||
print('PASS: both replicas observed through LB')
|
||||
break
|
||||
time.sleep(0.15)
|
||||
else:
|
||||
raise SystemExit('Both API replicas did not return to LB')
|
||||
Reference in New Issue
Block a user