Repository navigation
test(mssql): isolate test tables and fix resource leaks in integration tests - #4499
lusosa-googlexwf wants to merge 12 commits into
Conversation
…-toolbox into fix/mssql-test-isolation2
There was a problem hiding this comment.
Code Review
This pull request improves the robustness and concurrency of MSSQL integration tests. Key changes include transitioning to t.Cleanup for resource teardown, using ExecContext instead of QueryContext for DDL/DML statements, introducing dynamic table names for SQL execution tests to prevent conflicts, and refining CleanupMSSQLTables to target specific unique IDs or orphaned tables older than 2 hours. The review feedback highlights two important improvements: escaping the underscore wildcard in SQL LIKE patterns (e.g., t[_]% instead of t_%) to prevent matching unintended tables, and simplifying the string replacement logic for SQL table names to make it more robust.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves the robustness and concurrency safety of MSSQL integration tests. Key changes include refactoring CleanupMSSQLTables to target specific test tables by unique IDs or clean up orphaned test tables older than 2 hours (preventing concurrent CI runs from interfering with each other), replacing defer statements with t.Cleanup for reliable resource cleanup, and dynamically generating and cleaning up table names in RunExecuteSqlToolInvokeTest and RunToolInvokeWithTemplateParameters instead of using a hardcoded table name t. Additionally, SetupMsSQLTable was updated to use ExecContext and properly escape table names during teardown. I have no further feedback to provide as there are no review comments.
|
All MSSQL and Cloud SQL MSSQL integration tests are now passing successfully ( |
Description
Refactors MSSQL integration tests and shared test utilities to ensure complete isolation and prevent resource leaks during concurrent CI runs or on shared test databases.
Key Changes
sp_MSforeachtable). Only drop tables scoped to unique test IDs, or prune orphaned test tables older than 2 hours using server local time (GETDATE()).]]) to prevent SQL syntax errors or injection.tinRunExecuteSqlToolInvokeTestwith unique UUID-based tables and registert.Cleanuphooks.QueryContexttoExecContextinSetupMsSQLTableand trigger teardown on insert failure without shadowing errors.rows.Scanerrors and checkrows.Err()across result set iterations.cmd.Close()) are cleaned up.Tests
go test ./tests/mssql/...PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
review
!if this involve a breaking change