From 62b830987d65c3573214d04e50742476097ee9e9 Mon Sep 17 00:00:00 2001 From: Binh Tran Date: Fri, 13 Feb 2026 12:55:53 -0500 Subject: [PATCH] fix: Deflake alloydb omni (#2431) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Improve logic to check that database is up. **IMPORTANT** DO NOT MERGE until I have reverted https://github.com/googleapis/genai-toolbox/pull/2431/commits/f7d7d9e70825009251761dff9723f9f61027a16a ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [x] https://github.com/googleapis/genai-toolbox/issues/2422 - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #2422 Co-authored-by: Averi Kitsch --- tests/alloydbomni/alloydb_omni_integration_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/alloydbomni/alloydb_omni_integration_test.go b/tests/alloydbomni/alloydb_omni_integration_test.go index b634789ce9..a92be273a9 100644 --- a/tests/alloydbomni/alloydb_omni_integration_test.go +++ b/tests/alloydbomni/alloydb_omni_integration_test.go @@ -36,15 +36,17 @@ var ( AlloyDBDatabase = "postgres" ) -// Copied over from postgres.go -func initPostgresConnectionPool(host, port, user, pass, dbname string) (*pgxpool.Pool, error) { - // urlExample := "postgres:dd//username:password@localhost:5432/database_name" - url := &url.URL{ +func buildPostgresURL(host, port, user, pass, dbname string) *url.URL { + return &url.URL{ Scheme: "postgres", User: url.UserPassword(user, pass), Host: fmt.Sprintf("%s:%s", host, port), Path: dbname, } +} + +func initPostgresConnectionPool(host, port, user, pass, dbname string) (*pgxpool.Pool, error) { + url := buildPostgresURL(host, port, user, pass, dbname) pool, err := pgxpool.New(context.Background(), url.String()) if err != nil { return nil, fmt.Errorf("Unable to create connection pool: %w", err) @@ -63,7 +65,8 @@ func setupAlloyDBContainer(ctx context.Context, t *testing.T) (string, string, f "POSTGRES_PASSWORD": AlloyDBPass, }, WaitingFor: wait.ForAll( - wait.ForLog("Post Startup: Successfully reinstalled extensions"), + wait.ForLog("database system was shut down at"), + wait.ForLog("database system is ready to accept connections"), wait.ForExposedPort(), ), }