From 2440c503307b8e1fe2e741406371730ed690273e Mon Sep 17 00:00:00 2001 From: Aleksey Sabilin Date: Mon, 20 Jul 2026 01:45:10 +0300 Subject: [PATCH] fix: add-host for stand e2e under Docker host network (IFT DNS) --- scripts/run-stand-api-tests.sh | 26 ++++++++++++++++++++++++++ test/api_admins_SUITE.erl | 4 ++-- test/api_users_SUITE.erl | 4 ++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/run-stand-api-tests.sh b/scripts/run-stand-api-tests.sh index b9df704..63fae27 100644 --- a/scripts/run-stand-api-tests.sh +++ b/scripts/run-stand-api-tests.sh @@ -44,6 +44,31 @@ echo " ADMIN_API_HOST=${ADMIN_API_HOST}" echo " WS_HOST=${WS_HOST}" echo " ADMIN_WS_HOST=${ADMIN_WS_HOST}" +# Docker Desktop/WSL: --network=host часто НЕ наследует /etc/hosts стенда, +# из‑за чего CT remote не резолвит *.ift.eventhub.local (health timeout 30s). +docker_add_hosts=() +for url in "${API_HOST}" "${ADMIN_API_HOST}" "${WS_HOST}" "${ADMIN_WS_HOST}"; do + host="$(python3 -c 'from urllib.parse import urlparse; import sys; print(urlparse(sys.argv[1]).hostname or "")' "${url}")" + [[ -n "${host}" ]] || continue + # уже добавили этот host + skip=0 + for existing in "${docker_add_hosts[@]:-}"; do + case "${existing}" in + --add-host="${host}:"*) skip=1; break ;; + esac + done + [[ "${skip}" -eq 1 ]] && continue + ip="$(getent ahostsv4 "${host}" 2>/dev/null | awk '{print $1; exit}' || true)" + if [[ -z "${ip}" ]]; then + ip="$(getent hosts "${host}" 2>/dev/null | awk '{print $1; exit}' || true)" + fi + if [[ -z "${ip}" ]]; then + ip=host-gateway + fi + echo " docker --add-host ${host}:${ip}" + docker_add_hosts+=(--add-host="${host}:${ip}") +done + IMAGE="eventhub-api-tests:local" REG_IMAGE="" if [[ -n "${GITHUB_SHA:-}" ]]; then @@ -90,6 +115,7 @@ if [[ "${have_image}" -ne 1 ]]; then fi docker run --rm --network=host \ + ${docker_add_hosts[@]+"${docker_add_hosts[@]}"} \ -e CT_MODE=remote \ -e "API_HOST=${API_HOST}" \ -e "ADMIN_API_HOST=${ADMIN_API_HOST}" \ diff --git a/test/api_admins_SUITE.erl b/test/api_admins_SUITE.erl index 73f1903..aa6a9ad 100644 --- a/test/api_admins_SUITE.erl +++ b/test/api_admins_SUITE.erl @@ -149,10 +149,10 @@ ct_mode() -> wait_for_remote() -> URL = api_test_runner:get_admin_url() ++ "/admin/health", ct:pal("Waiting for remote API: ~s", [URL]), - wait_for_health(URL, 30). + wait_for_health(URL, 90). wait_for_health(_URL, 0) -> - ct:fail("Remote API did not start within 30 seconds"); + ct:fail("Remote API did not start within 90 seconds"); wait_for_health(URL, Retries) -> case httpc:request(get, {URL, []}, [{timeout, 5000}, {ssl, [{verify, verify_none}]}], []) of {ok, {{_, 200, _}, _, _}} -> ok; diff --git a/test/api_users_SUITE.erl b/test/api_users_SUITE.erl index 196e46f..2ca3bc7 100644 --- a/test/api_users_SUITE.erl +++ b/test/api_users_SUITE.erl @@ -177,10 +177,10 @@ ct_mode() -> wait_for_remote() -> URL = api_test_runner:get_base_url() ++ "/health", ct:pal("Waiting for remote API: ~s", [URL]), - wait_for_health(URL, 30). + wait_for_health(URL, 90). wait_for_health(_URL, 0) -> - ct:fail("Remote API did not start within 30 seconds"); + ct:fail("Remote API did not start within 90 seconds"); wait_for_health(URL, Retries) -> case httpc:request(get, {URL, []}, [{timeout, 5000}, {ssl, [{verify, verify_none}]}], []) of {ok, {{_, 200, _}, _, _}} -> ok;