Compare commits

...

12 Commits

Author SHA1 Message Date
manuka rahul
de6b78366e Merge branch 'main' into integration-test 2026-01-06 12:22:16 +05:30
manuka rahul
35811a833b Merge branch 'main' into integration-test 2026-01-05 11:04:38 +05:30
manuka rahul
eeedc4b059 Merge branch 'main' into integration-test 2025-12-30 14:49:14 +05:30
rahulpinto19
e66deb9abf tests 2025-12-30 08:55:12 +00:00
rahulpinto19
c60a4af1ea test 2025-12-30 08:47:25 +00:00
manuka rahul
71fdcd2ac8 Merge branch 'main' into integration-test 2025-12-30 11:15:26 +05:30
rahulpinto19
3466e1459e test 2025-12-24 07:54:58 +00:00
manuka rahul
fba3091f9e Implement safety drop for existing table
Added safety drop for existing table before creation.
2025-12-24 12:57:17 +05:30
Srividya Reddy
efbde0dcb1 test(source/postgres): fix list_database_stats integration test (#2235)
## Description
The list_database_stats test fails intermittently when run in parallel
on shared instances. Specifically, the "filter by tablespace" and "sort
by size" test cases fail because they encounter unexpected databases in
the pg_default tablespace created by concurrent test runs.
This PR narrows the scope of these test cases by filtering for specific
database names. This ensures assertions remain isolated to the current
test run regardless of other databases present in the shared
environment.

```
 go test -tags=integration tests/postgres/postgres_integration_test.go
ok      command-line-arguments  14.455s
```

> Should include a concise description of the changes (bug or feature),
it's
> impact, along with a summary of the solution

## PR Checklist

> Thank you for opening a Pull Request! Before submitting your PR, there
are a
> few things you can do to make sure it goes smoothly:

- [x] Make sure you reviewed

[CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md)
- [x] Make sure to open an issue as a

[bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose)
  before writing your code! That way we can discuss the change, evaluate
  designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
- [x] Make sure to add `!` if this involve a breaking change

🛠️ Fixes #<1738>
2025-12-24 07:19:03 +00:00
rahulpinto19
bb24e03475 test 2025-12-24 07:16:52 +00:00
rahulpinto19
f73d466f74 test:add integration tests for collection 2025-12-24 06:47:01 +00:00
rahulpinto19
f8f4c10d35 test: add integration tests for collections 2025-12-24 06:34:58 +00:00
5 changed files with 21 additions and 5 deletions

View File

@@ -446,10 +446,16 @@ func runToolAggregateInvokeTest(t *testing.T, aggregate1Want string, aggregateMa
func setupMongoDB(t *testing.T, ctx context.Context, database *mongo.Database) func(*testing.T) {
collectionName := "test_collection"
//Ensure the collection is clean
if err := database.Collection(collectionName).Drop(ctx); err != nil {
t.Logf("Warning: failed to drop collection before setup: %v", err)
}
// Drop the target collection used in aggregate tests
if err := database.Collection("target_collection").Drop(ctx); err != nil {
t.Logf("Warning: failed to drop target collection before setup: %v", err)
}
documents := []map[string]any{
{"_id": 1, "id": 1, "name": "Alice", "email": ServiceAccountEmail},
{"_id": 14, "id": 2, "name": "FakeAlice", "email": "fakeAlice@gmail.com"},

View File

@@ -93,7 +93,7 @@ func TestPostgres(t *testing.T) {
t.Fatalf("unable to create postgres connection pool: %s", err)
}
// cleanup test environment
// cleanup the collections
tests.CleanupPostgresTables(t, ctx, pool)
// create table name with UUID

View File

@@ -660,7 +660,7 @@ func runCancelBatchTest(t *testing.T, client *dataproc.BatchControllerClient, ct
}
if batch.State != dataprocpb.Batch_SUCCEEDED {
waitForBatch(t, client, ctx, batchName, []dataprocpb.Batch_State{dataprocpb.Batch_CANCELLING, dataprocpb.Batch_CANCELLED}, 2*time.Minute)
waitForBatch(t, client, ctx, batchName, []dataprocpb.Batch_State{dataprocpb.Batch_CANCELLING, dataprocpb.Batch_CANCELLED}, 5*time.Minute)
}
}

View File

@@ -109,6 +109,11 @@ func setupSingleStoreTable(t *testing.T, ctx context.Context, pool *sql.DB, crea
t.Fatalf("unable to connect to test database: %s", err)
}
// Safety drop before creation
_, err = pool.ExecContext(ctx, fmt.Sprintf("DROP TABLE IF EXISTS %s;", tableName))
if err != nil {
t.Fatalf("Warning: failed to drop table %s before creation:%v ", tableName, err)
}
// Create table
_, err = pool.QueryContext(ctx, createStatement)
if err != nil {

View File

@@ -27,7 +27,6 @@ import (
"github.com/google/uuid"
"github.com/googleapis/genai-toolbox/internal/testutils"
"github.com/googleapis/genai-toolbox/tests"
_ "github.com/trinodb/trino-go-client/trino" // Import Trino SQL driver
)
var (
@@ -163,15 +162,21 @@ func setupTrinoTable(t *testing.T, ctx context.Context, pool *sql.DB, createStat
if err != nil {
t.Fatalf("unable to connect to test database: %s", err)
}
//Ensure the collection is clean
_, err = pool.ExecContext(ctx, fmt.Sprintf("DROP TABLE IF EXISTS %s", tableName))
if err != nil {
t.Logf("Warning: failed to drop existing table %s", tableName)
}
// Create table
_, err = pool.QueryContext(ctx, createStatement)
_, err = pool.ExecContext(ctx, createStatement)
if err != nil {
t.Fatalf("unable to create test table %s: %s", tableName, err)
}
// Insert test data
_, err = pool.QueryContext(ctx, insertStatement, params...)
_, err = pool.ExecContext(ctx, insertStatement, params...)
if err != nil {
t.Fatalf("unable to insert test data: %s", err)
}