Skip to content

test(alloydbpg,cloudsqlpg): achieve full parity with legacy tests for custom tools#3014

Open
anubhav756 wants to merge 4 commits intoanubhav-mcp-cloudsqlpgfrom
anubhav-parity
Open

test(alloydbpg,cloudsqlpg): achieve full parity with legacy tests for custom tools#3014
anubhav756 wants to merge 4 commits intoanubhav-mcp-cloudsqlpgfrom
anubhav-parity

Conversation

@anubhav756
Copy link
Copy Markdown
Contributor

Description

This PR completes the migration of AlloyDB and Cloud SQL Postgres integration tests to the MCP framework by achieving full feature parity with the legacy tests, specifically for custom tool configurations.

hanges

  • Updated alloydbpg and cloudsqlpg MCP tests to set up necessary tables and register custom tools (param tools, auth tools, semantic search) via dynamic configuration files, mirroring the legacy test setup.
  • Implemented RunMCPExecuteSqlToolInvokeTest and RunMCPToolInvokeWithTemplateParameters in tests/mcp_tool.go to allow testing advanced custom tools over the JSON-RPC /mcp endpoint.

@anubhav756 anubhav756 self-assigned this Apr 9, 2026
@anubhav756 anubhav756 requested review from a team as code owners April 9, 2026 21:38
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request expands the integration test suite for AlloyDB and CloudSQL Postgres by adding comprehensive test cases for custom tools, execute-sql functionality, and template parameters. The changes introduce new helper functions in tests/mcp_tool.go to facilitate these tests. I have provided feedback regarding the hardcoding of table names in the new helper function and suggested a cleaner way to define SQL statements to avoid unnecessary string manipulation.

}

// RunMCPExecuteSqlToolInvokeTest runs execute-sql tool invoke test cases via MCP.
func RunMCPExecuteSqlToolInvokeTest(t *testing.T, ctx context.Context, createTableStatement, select1Want string, options ...ExecuteSqlOption) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The RunMCPExecuteSqlToolInvokeTest function hardcodes the table name t in several test cases (lines 456, 462, 500). This makes the helper less flexible and can cause race conditions or conflicts if multiple tests run in parallel against the same database. Consider adding a tableName parameter to the function and using it to construct the SQL queries, similar to how RunMCPToolInvokeWithTemplateParameters is implemented on line 549.

// RunMCPExecuteSqlToolInvokeTest runs execute-sql tool invoke test cases via MCP.
func RunMCPExecuteSqlToolInvokeTest(t *testing.T, ctx context.Context, createTableStatement, select1Want string, options ...ExecuteSqlOption) {
configs := &ExecuteSqlTestConfig{
select1Statement: `"SELECT 1"`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The select1Statement is defined with escaped double quotes, which are then trimmed in every test case (e.g., line 444). This adds unnecessary complexity. It would be cleaner to define the SQL statement without quotes and remove the strings.Trim calls.

Suggested change
select1Statement: `"SELECT 1"`,
select1Statement: "SELECT 1",

@anubhav756 anubhav756 requested review from a team as code owners April 10, 2026 09:34
@anubhav756 anubhav756 force-pushed the anubhav-mcp-cloudsqlpg branch from cf13215 to 63b7b9e Compare April 11, 2026 12:51
@anubhav756 anubhav756 force-pushed the anubhav-mcp-cloudsqlpg branch from 63b7b9e to 85a2173 Compare April 13, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant