From a6830d6d9f409d8cbf1e3da6ead500dc14c642a9 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Fri, 3 Jul 2026 13:03:40 +1000 Subject: [PATCH] test: wait for postgres readiness log twice (avoid connection-reset flake) --- internal/testsupport/containers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/testsupport/containers.go b/internal/testsupport/containers.go index d4a1dfe..66d491a 100644 --- a/internal/testsupport/containers.go +++ b/internal/testsupport/containers.go @@ -33,7 +33,11 @@ func StartPostgres(ctx context.Context) (dsn string, terminate func(), err error tcpostgres.WithUsername("artifacts"), tcpostgres.WithPassword("artifacts123"), testcontainers.WithWaitStrategy( - wait.ForListeningPort("5432/tcp").WithStartupTimeout(60*time.Second), + // Postgres opens the port, runs init scripts, then restarts, so wait + // for the readiness log to appear twice to avoid connection resets. + wait.ForLog("database system is ready to accept connections"). + WithOccurrence(2). + WithStartupTimeout(60*time.Second), ), ) if err != nil {