mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-13 16:45:01 -05:00
fix: Deflake alloydb omni (#2431)
## Description
Improve logic to check that database is up.
**IMPORTANT** DO NOT MERGE until I have reverted
f7d7d9e708
## 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 <akitsch@google.com>
This commit is contained in:
@@ -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(),
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user