Compare commits

...
3 Commits
Author SHA1 Message Date
DenozordecandCursor d4fbffe000 test(store): isolate firewall client integration from demo seed
quality / changes (push) Successful in 13s
quality / openapi (push) Skipped
quality / web (push) Skipped
quality / commitlint (push) Skipped
quality / docker-check (push) Skipped
quality / go (push) Successful in 1m15s
quality / postgres-integration (push) Successful in 2m6s
quality / legacy-compatibility (1.0.0) (push) Successful in 57s
quality / legacy-compatibility (2.56.2) (push) Successful in 1m10s
quality / bird2 (push) Successful in 24s
CD / quality (push) Successful in 9m1s
CD / publish (push) Failing after 58m14s
Тест ждал tenant со slug demo, а seedDemo создаёт его только в пустой базе. После соседних интеграционных тестов DemoIDs пустой, и проверка падала. Теперь тест создаёт и удаляет собственный tenant.

Co-authored-by: Cursor <[email protected]>
2026-11-02 18:44:02 +07:00
DenozordecandCursor e755974273 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
Интеграционные тесты ходили на 127.0.0.1 внутри контейнера job и сразу получали connection refused. DSN указывает на сервис postgres, скрипт ждёт открытия TCP до 90 секунд.

Co-authored-by: Cursor <[email protected]>
2026-11-02 18:29:41 +07:00
DenozordecandCursor 3e46681263 fix(birddeploy): discard directory close error after sync
quality / changes (push) Successful in 7s
quality / openapi (push) Skipped
quality / web (push) Skipped
quality / commitlint (push) Skipped
quality / docker-check (push) Skipped
quality / go (push) Successful in 2m18s
quality / postgres-integration (push) Failing after 1m14s
quality / legacy-compatibility (1.0.0) (push) Successful in 58s
quality / legacy-compatibility (2.56.2) (push) Successful in 1m10s
quality / bird2 (push) Successful in 24s
CD / quality (push) Failing after 6m13s
CD / publish (push) Skipped
golangci-lint (errcheck) падал на defer f.Close() в syncDir. Ошибка Close явно отбрасывается, результат Sync по-прежнему возвращается вызывающему.

Co-authored-by: Cursor <[email protected]>
2026-11-02 18:21:16 +07:00
4 changed files with 38 additions and 6 deletions

No files matched your search

+3 -1
View File
@@ -361,7 +361,9 @@ jobs:
- name: Run migrations and verify PostgreSQL integration tests executed
env:
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
legacy-compatibility:
+1 -1
View File
@@ -9,6 +9,6 @@ func syncDir(path string) error {
if err != nil {
return err
}
defer f.Close()
defer func() { _ = f.Close() }()
return f.Sync()
}
@@ -8,6 +8,8 @@ import (
"evobgp/internal/authkey"
"evobgp/internal/db"
"evobgp/internal/store"
"github.com/google/uuid"
)
func TestPostgresFirewallClientCreateAndGetIntegration(t *testing.T) {
@@ -21,14 +23,17 @@ func TestPostgresFirewallClientCreateAndGetIntegration(t *testing.T) {
t.Fatal(err)
}
defer pool.Close()
pg, err := NewPostgres(ctx, pool, true)
pg, err := NewPostgres(ctx, pool, false)
if err != nil {
t.Fatal(err)
}
tenant, _, _, _, _ := pg.DemoIDs()
if tenant == "" {
t.Fatal("demo tenant required")
tenant := uuid.NewString()
if _, err := pool.Exec(ctx, `INSERT INTO tenant (id, name, slug) VALUES ($1, $2, $3)`, tenant, "firewall", "fw-"+tenant); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
_, _ = pool.Exec(context.Background(), `DELETE FROM tenant WHERE id = $1`, tenant)
})
tok := "evobgp_fw_pgtest_" + t.Name()
hash := authkey.HashToken(tok)
client, err := pg.CreateFirewallClient(tenant, &store.FirewallClientCreate{
+25
View File
@@ -3,6 +3,31 @@ set -euo pipefail
: "${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() {
local result_file="$1" package="$2" label="$3"
shift 3