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 {