fix: LB и на [::1] — localhost на Windows стоил 2 с на запрос; сдвиг цели failover

Найдено первым прогоном из чистого clone: make test-failover (BASE_URL
по умолчанию http://localhost:8080) успел сделать 8 записей за 15 с, и
первая успешная запись после хука пришла на 8,4 с. Windows сначала
стучится на ::1, где порт не был опубликован, и каждое новое соединение
ждёт ~2 с. LB теперь опубликован на 127.0.0.1 и [::1] (оба loopback):
0,013 с на запрос. Тест политики портов допускает только loopback.

collect_evidence: публичный тест всегда выбирает реплику, обслужившую
его первый POST, а последовательность запросов фиксирована — перед
каждым следующим прогоном rotation сдвигается лишними GET, чтобы
по очереди останавливались обе реплики.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexey Bodanyuk
2026-10-19 18:09:12 +03:00
co-authored by Claude Opus 5.5
parent 2846cae118
commit 27087326d0
4 changed files with 16 additions and 5 deletions
+6
View File
@@ -119,7 +119,13 @@ def main() -> int:
# 4. failover: until BOTH replicas have been the stopped one (each run is a real public test)
log = Log("test-failover.txt", "make test-failover with scripts/stop-one: which container is really stopped, restore, repeat")
stopped: set[str] = set()
import urllib.request
for attempt in range(1, 7):
# The public test stops the replica that served its first POST; its request sequence is
# fixed, so with round robin it hits the same replica every time. Shift the rotation by
# (attempt - 1) extra requests so that the other replica becomes the target as well.
for _ in range(attempt - 1):
urllib.request.urlopen("http://127.0.0.1:8080/health/live", timeout=5).read()
before = {r for r in states() if "-api-" in r and " running " in r}
log.note(f"--- run {attempt}; running API replicas BEFORE:\n" + "\n".join(sorted(before)))
log.run([make, "test-failover", f"ACTION_SCRIPT=scripts/stop-one{HOOK}", f"PYTHON={MAKE_PY}"],