fix(ci): dial the postgres service instead of job loopback
quality / changes (push) Successful in 7s
quality / commitlint (push) Skipped
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 23s
quality / web (push) Successful in 1m19s
quality / go (push) Successful in 1m16s
quality / postgres-integration (push) Failing after 2m46s
quality / legacy-compatibility (1.0.0) (push) Successful in 1m11s
quality / legacy-compatibility (2.56.2) (push) Successful in 1m34s
quality / bird2 (push) Successful in 26s
CD / quality (push) Failing after 9m9s
CD / publish (push) Skipped
quality / changes (push) Successful in 7s
quality / commitlint (push) Skipped
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 23s
quality / web (push) Successful in 1m19s
quality / go (push) Successful in 1m16s
quality / postgres-integration (push) Failing after 2m46s
quality / legacy-compatibility (1.0.0) (push) Successful in 1m11s
quality / legacy-compatibility (2.56.2) (push) Successful in 1m34s
quality / bird2 (push) Successful in 26s
CD / quality (push) Failing after 9m9s
CD / publish (push) Skipped
Интеграционные тесты ходили на 127.0.0.1 внутри контейнера job и сразу получали connection refused. DSN указывает на сервис postgres, скрипт ждёт открытия TCP до 90 секунд. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
3e46681263
commit
e755974273
2 files changed
+28
-1
No files matched your search
@@ -361,7 +361,9 @@ jobs:
|
|||||||
- name: Run migrations and verify PostgreSQL integration tests executed
|
- name: Run migrations and verify PostgreSQL integration tests executed
|
||||||
env:
|
env:
|
||||||
GOFLAGS: -mod=readonly
|
GOFLAGS: -mod=readonly
|
||||||
EVOBGP_TEST_DATABASE_URL: postgres://evobgp:[email protected]:5432/evobgp_test?sslmode=disable
|
# Job and the postgres service are sibling containers on act_runner.
|
||||||
|
# 127.0.0.1 is the job itself; the service is reachable by its name.
|
||||||
|
EVOBGP_TEST_DATABASE_URL: postgres://evobgp:evobgp_ci@postgres:5432/evobgp_test?sslmode=disable
|
||||||
run: bash scripts/ci/postgres-integration.sh
|
run: bash scripts/ci/postgres-integration.sh
|
||||||
|
|
||||||
legacy-compatibility:
|
legacy-compatibility:
|
||||||
|
|||||||
@@ -3,6 +3,31 @@ set -euo pipefail
|
|||||||
|
|
||||||
: "${EVOBGP_TEST_DATABASE_URL:?PostgreSQL integration tests require EVOBGP_TEST_DATABASE_URL}"
|
: "${EVOBGP_TEST_DATABASE_URL:?PostgreSQL integration tests require EVOBGP_TEST_DATABASE_URL}"
|
||||||
|
|
||||||
|
# The Gitea job container does not publish the service onto its own loopback.
|
||||||
|
# Wait until the DSN host accepts TCP so a slow postmaster is not a test failure.
|
||||||
|
python3 - <<'PY'
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
import time
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
raw = os.environ["EVOBGP_TEST_DATABASE_URL"]
|
||||||
|
parsed = urlparse(raw)
|
||||||
|
host = parsed.hostname or "127.0.0.1"
|
||||||
|
port = parsed.port or 5432
|
||||||
|
deadline = time.time() + 90
|
||||||
|
last = "no attempt"
|
||||||
|
while time.time() < deadline:
|
||||||
|
try:
|
||||||
|
with socket.create_connection((host, port), timeout=2):
|
||||||
|
print(f"postgres tcp open at {host}:{port}", flush=True)
|
||||||
|
raise SystemExit(0)
|
||||||
|
except OSError as exc:
|
||||||
|
last = str(exc)
|
||||||
|
time.sleep(2)
|
||||||
|
raise SystemExit(f"postgres not accepting TCP at {host}:{port} after 90s: {last}")
|
||||||
|
PY
|
||||||
|
|
||||||
assert_passes() {
|
assert_passes() {
|
||||||
local result_file="$1" package="$2" label="$3"
|
local result_file="$1" package="$2" label="$3"
|
||||||
shift 3
|
shift 3
|
||||||
|
|||||||
Reference in new issue
Block a user