mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-27 08:18:27 -05:00
Compare commits
1 Commits
integratio
...
averikitsc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4cb4e81b4 |
@@ -377,10 +377,10 @@ See [Usage Examples](../reference/cli.md#examples).
|
||||
entries.
|
||||
* **Dataplex Editor** (`roles/dataplex.editor`) to modify entries.
|
||||
* **Tools:**
|
||||
* `dataplex_search_entries`: Searches for entries in Dataplex Catalog.
|
||||
* `dataplex_lookup_entry`: Retrieves a specific entry from Dataplex
|
||||
* `search_entries`: Searches for entries in Dataplex Catalog.
|
||||
* `lookup_entry`: Retrieves a specific entry from Dataplex
|
||||
Catalog.
|
||||
* `dataplex_search_aspect_types`: Finds aspect types relevant to the
|
||||
* `search_aspect_types`: Finds aspect types relevant to the
|
||||
query.
|
||||
|
||||
## Firestore
|
||||
|
||||
@@ -214,15 +214,12 @@ func AddPostgresPrebuiltConfig(t *testing.T, config map[string]any) map[string]a
|
||||
PostgresListDatabaseStatsToolKind = "postgres-list-database-stats"
|
||||
PostgresListRolesToolKind = "postgres-list-roles"
|
||||
PostgresListStoredProcedureToolKind = "postgres-list-stored-procedure"
|
||||
|
||||
|
||||
)
|
||||
|
||||
tools, ok := config["tools"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("unable to get tools from config")
|
||||
}
|
||||
|
||||
tools["list_tables"] = map[string]any{
|
||||
"kind": PostgresListTablesToolKind,
|
||||
"source": "my-instance",
|
||||
@@ -946,8 +943,6 @@ func TestCloudSQLMySQL_IPTypeParsingFromYAML(t *testing.T) {
|
||||
|
||||
// Finds and drops all tables in a postgres database.
|
||||
func CleanupPostgresTables(t *testing.T, ctx context.Context, pool *pgxpool.Pool) {
|
||||
|
||||
t.Logf("in cleanupPostgrestTables");
|
||||
query := `
|
||||
SELECT table_name FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_type = 'BASE TABLE';`
|
||||
@@ -969,31 +964,14 @@ func CleanupPostgresTables(t *testing.T, ctx context.Context, pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
if len(tablesToDrop) == 0 {
|
||||
t.Logf("No tables to drop in 'public' schema")
|
||||
return
|
||||
}
|
||||
t.Logf("Tables to drop in 'public' schema: %s", strings.Join(tablesToDrop, ", "))
|
||||
|
||||
|
||||
dropQuery := fmt.Sprintf("DROP TABLE IF EXISTS %s CASCADE;", strings.Join(tablesToDrop, ", "))
|
||||
|
||||
if _, err := pool.Exec(ctx, dropQuery); err != nil {
|
||||
t.Fatalf("Failed to drop all tables in 'public' schema: %v", err)
|
||||
}
|
||||
|
||||
t.Logf("Dropped tables in 'public' schema: %s", strings.Join(tablesToDrop, ", "))
|
||||
|
||||
|
||||
// // 1. Drop the entire public schema (this kills tables, views, types, etc.)
|
||||
// dropSchema := "DROP SCHEMA public CASCADE;"
|
||||
// // 2. Recreate the empty public schema
|
||||
// createSchema := "CREATE SCHEMA public;"
|
||||
// // 3. Grant permissions back (Postgres default)
|
||||
// grantPublic := "GRANT ALL ON SCHEMA public TO public;"
|
||||
|
||||
// _, err := pool.Exec(ctx, dropSchema + createSchema + grantPublic)
|
||||
// if err != nil {
|
||||
// t.Fatalf("Failed to nuclear-wipe the public schema: %v", err)
|
||||
// }
|
||||
}
|
||||
|
||||
// Finds and drops all tables in a mysql database.
|
||||
|
||||
@@ -81,25 +81,6 @@ func initPostgresConnectionPool(host, port, user, pass, dbname string) (*pgxpool
|
||||
return pool, nil
|
||||
}
|
||||
|
||||
func CreateIsolatedSchema(t *testing.T, ctx context.Context, pool *pgxpool.Pool) (string, func()) {
|
||||
|
||||
schemaName := "test_schema_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
||||
|
||||
_, err := pool.Exec(ctx, fmt.Sprintf("CREATE SCHEMA %q;", schemaName))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create sandbox schema: %v", err)
|
||||
}
|
||||
|
||||
cleanup := func() {
|
||||
// Use Background context to ensure cleanup runs even if the test timed out
|
||||
_, err := pool.Exec(context.Background(), fmt.Sprintf("DROP SCHEMA %q CASCADE;", schemaName))
|
||||
if err != nil {
|
||||
t.Logf("Cleanup warning: failed to drop schema %s: %v", schemaName, err)
|
||||
}
|
||||
}
|
||||
|
||||
return schemaName, cleanup
|
||||
}
|
||||
func TestPostgres(t *testing.T) {
|
||||
sourceConfig := getPostgresVars(t)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
@@ -111,20 +92,9 @@ func TestPostgres(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create postgres connection pool: %s", err)
|
||||
}
|
||||
defer pool.Close()
|
||||
|
||||
//this was conflicting and too slow
|
||||
// cleanup test environment
|
||||
// tests.CleanupPostgresTables(t, ctx, pool)
|
||||
|
||||
schemaName, cleanupSchema := CreateIsolatedSchema(t, ctx, pool)
|
||||
defer cleanupSchema()
|
||||
|
||||
// Force the pool to ONLY use this schema for this test run
|
||||
_, err = pool.Exec(ctx, fmt.Sprintf("SET search_path TO %q;", schemaName))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to set search path: %v", err)
|
||||
}
|
||||
tests.CleanupPostgresTables(t, ctx, pool)
|
||||
|
||||
// create table name with UUID
|
||||
tableNameParam := "param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
||||
|
||||
Reference in New Issue
Block a user